-
Notifications
You must be signed in to change notification settings - Fork 392
feat(clerk-js,types): Display organization slug based on environment settings #6903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+271
−40
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7d33993
Update FAPI resource
LauraBeatris 89c8d32
Update types
LauraBeatris a698776
Conditionally display field on `CreateOrganization` form
LauraBeatris 5a737ba
Deprecate `hideSlug` prop
LauraBeatris 5f10792
Conditionally display field on `TaskChooseOrganization` form
LauraBeatris 17a7312
Add UI tests
LauraBeatris 463110e
Add changeset
LauraBeatris 9114833
Fix unit tests
LauraBeatris bd59a62
Update JSDocs according to Dashboard UI
LauraBeatris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
'@clerk/types': patch | ||
--- | ||
|
||
Display organization slug based on environment settings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,35 +80,169 @@ describe('CreateOrganization', () => { | |
expect(getByRole('heading', { name: 'Create organization', level: 1 })).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders component without slug field', async () => { | ||
const { wrapper, fixtures, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
describe('with `hideSlug` prop', () => { | ||
it('renders component without slug field', async () => { | ||
const { wrapper, fixtures, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
}); | ||
}); | ||
|
||
fixtures.clerk.createOrganization.mockReturnValue( | ||
Promise.resolve( | ||
getCreatedOrg({ | ||
maxAllowedMemberships: 1, | ||
slug: 'new-org-1722578361', | ||
}), | ||
), | ||
); | ||
|
||
props.setProps({ hideSlug: true }); | ||
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, { | ||
wrapper, | ||
}); | ||
|
||
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument(); | ||
|
||
await userEvent.type(getByLabelText(/Name/i), 'new org'); | ||
await userEvent.click(getByRole('button', { name: /create organization/i })); | ||
|
||
await waitFor(() => { | ||
expect(queryByText(/Invite new members/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
|
||
fixtures.clerk.createOrganization.mockReturnValue( | ||
Promise.resolve( | ||
getCreatedOrg({ | ||
maxAllowedMemberships: 1, | ||
slug: 'new-org-1722578361', | ||
}), | ||
), | ||
); | ||
describe('with organization slug configured on environment', () => { | ||
it('when disabled, renders component without slug field', async () => { | ||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationSlug(false); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
}); | ||
}); | ||
|
||
props.setProps({ hideSlug: true }); | ||
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, { | ||
wrapper, | ||
fixtures.clerk.createOrganization.mockReturnValue( | ||
Promise.resolve( | ||
getCreatedOrg({ | ||
maxAllowedMemberships: 1, | ||
slug: 'new-org-1722578361', | ||
}), | ||
), | ||
); | ||
|
||
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, { | ||
wrapper, | ||
}); | ||
|
||
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument(); | ||
|
||
await userEvent.type(getByLabelText(/Name/i), 'new org'); | ||
await userEvent.click(getByRole('button', { name: /create organization/i })); | ||
|
||
await waitFor(() => { | ||
expect(queryByText(/Invite new members/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('when enabled, renders component slug field', async () => { | ||
const { wrapper, fixtures } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationSlug(true); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
}); | ||
}); | ||
|
||
fixtures.clerk.createOrganization.mockReturnValue( | ||
Promise.resolve( | ||
getCreatedOrg({ | ||
maxAllowedMemberships: 1, | ||
slug: 'new-org-1722578361', | ||
}), | ||
), | ||
); | ||
|
||
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, { | ||
wrapper, | ||
}); | ||
|
||
expect(queryByLabelText(/Slug/i)).toBeInTheDocument(); | ||
|
||
await userEvent.type(getByLabelText(/Name/i), 'new org'); | ||
await userEvent.click(getByRole('button', { name: /create organization/i })); | ||
|
||
await waitFor(() => { | ||
expect(queryByText(/Invite new members/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument(); | ||
it('when enabled and `hideSlug` prop is passed, renders component without slug field', async () => { | ||
const { wrapper, fixtures, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationSlug(true); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
}); | ||
}); | ||
|
||
await userEvent.type(getByLabelText(/Name/i), 'new org'); | ||
await userEvent.click(getByRole('button', { name: /create organization/i })); | ||
fixtures.clerk.createOrganization.mockReturnValue( | ||
Promise.resolve( | ||
getCreatedOrg({ | ||
maxAllowedMemberships: 1, | ||
slug: 'new-org-1722578361', | ||
}), | ||
), | ||
); | ||
|
||
props.setProps({ hideSlug: true }); | ||
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, { | ||
wrapper, | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(queryByText(/Invite new members/i)).toBeInTheDocument(); | ||
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument(); | ||
|
||
await userEvent.type(getByLabelText(/Name/i), 'new org'); | ||
await userEvent.click(getByRole('button', { name: /create organization/i })); | ||
|
||
await waitFor(() => { | ||
expect(queryByText(/Invite new members/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('when disabled and `hideSlug` prop is passed, renders component without slug field', async () => { | ||
const { wrapper, fixtures, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationSlug(false); // Environment disables slug | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
}); | ||
}); | ||
|
||
fixtures.clerk.createOrganization.mockReturnValue( | ||
Promise.resolve( | ||
getCreatedOrg({ | ||
maxAllowedMemberships: 1, | ||
slug: 'new-org-1722578361', | ||
}), | ||
), | ||
); | ||
|
||
props.setProps({ hideSlug: true }); | ||
const { userEvent, getByRole, queryByText, queryByLabelText, getByLabelText } = render(<CreateOrganization />, { | ||
wrapper, | ||
}); | ||
|
||
expect(queryByLabelText(/Slug/i)).not.toBeInTheDocument(); | ||
|
||
await userEvent.type(getByLabelText(/Name/i), 'new org'); | ||
await userEvent.click(getByRole('button', { name: /create organization/i })); | ||
|
||
await waitFor(() => { | ||
expect(queryByText(/Invite new members/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ describe('OrganizationList', () => { | |
it('hides the personal account with no data to list', async () => { | ||
const { wrapper, props } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationSlug(true); | ||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
organization_memberships: [{ name: 'Org1', id: '1', role: 'admin' }], | ||
|
@@ -210,6 +211,7 @@ describe('OrganizationList', () => { | |
it('display CreateOrganization within OrganizationList', async () => { | ||
const { wrapper } = await createFixtures(f => { | ||
f.withOrganizations(); | ||
f.withOrganizationSlug(true); | ||
LauraBeatris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
f.withUser({ | ||
email_addresses: ['[email protected]'], | ||
create_organization_enabled: true, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.