mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-08 15:06:08 +02:00
fix: personal server invite link omitted base URL (#2900)
* fix: personal server invite link omitted base URL * fix: respect `baseURL` when building invite URL * test: add simple unit test for <RegistrationLink> * clean up test Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
This commit is contained in:
parent
ae97d5c314
commit
2a0873c954
@ -0,0 +1,65 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`components/sidebar/RegistrationLink renders with signupToken in URL query param 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="Modal bottom-right"
|
||||
>
|
||||
<div
|
||||
class="toolbar hideOnWidescreen"
|
||||
>
|
||||
<button
|
||||
aria-label="Close"
|
||||
class="IconButton"
|
||||
title="Close"
|
||||
type="button"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="RegistrationLink"
|
||||
>
|
||||
<div
|
||||
class="row"
|
||||
>
|
||||
Share this link for others to create accounts:
|
||||
</div>
|
||||
<div
|
||||
class="row"
|
||||
>
|
||||
<a
|
||||
class="shareUrl"
|
||||
href="http://localhost/register?t=abc123"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
http://localhost/register?t=abc123
|
||||
</a>
|
||||
<button
|
||||
class="Button filled size--small"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
Copy link
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="row"
|
||||
>
|
||||
<button
|
||||
class="Button emphasis--secondary size--small"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
Regenerate token
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
43
webapp/src/components/sidebar/registrationLink.test.tsx
Normal file
43
webapp/src/components/sidebar/registrationLink.test.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React from 'react'
|
||||
import configureStore from 'redux-mock-store'
|
||||
|
||||
import {Provider as ReduxProvider} from 'react-redux'
|
||||
|
||||
import {render} from '@testing-library/react'
|
||||
|
||||
import {wrapIntl} from '../../testUtils'
|
||||
|
||||
import RegistrationLink from './registrationLink'
|
||||
|
||||
describe('components/sidebar/RegistrationLink', () => {
|
||||
const mockStore = configureStore([])
|
||||
const state = {
|
||||
teams: {
|
||||
current: {
|
||||
id: 'team-id',
|
||||
signupToken: 'abc123'
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
test('renders with signupToken in URL query param', () => {
|
||||
const store = mockStore(state)
|
||||
|
||||
const component = wrapIntl(
|
||||
<ReduxProvider store={store}>
|
||||
<RegistrationLink
|
||||
onClose={() => {}}
|
||||
/>
|
||||
</ReduxProvider>,
|
||||
)
|
||||
const {container} = render(component)
|
||||
expect(container).toMatchSnapshot()
|
||||
|
||||
const anchor = container.querySelector('.shareUrl')
|
||||
const url = new URL(anchor?.getAttribute('href') as string)
|
||||
expect(url.searchParams.get('t')).toStrictEqual(state.teams.current.signupToken)
|
||||
})
|
||||
})
|
@ -44,7 +44,7 @@ const RegistrationLink = (props: Props) => {
|
||||
}
|
||||
}
|
||||
|
||||
const registrationUrl = Utils.buildURL('/register?t=' + signupToken, true)
|
||||
const registrationUrl = `${Utils.getBaseURL(true).replace(/\/$/, '')}/register?t=${signupToken}`
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
Loading…
Reference in New Issue
Block a user