Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 470
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
7d3399389c8d32a6987765a737ba5f1079217a7312463110e9114833bd59a62File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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: ['test@clerk.com'], | ||
| describe('with `hideSlug` prop', () => { | ||
| it('renders component without slug field', async () => { | ||
| const { wrapper, fixtures, props } = await createFixtures(f => { | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
| email_addresses: ['test@clerk.com'], | ||
| }); | ||
| }); | ||
| 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: ['test@clerk.com'], | ||
| }); | ||
| }); | ||
| 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: ['test@clerk.com'], | ||
| }); | ||
| }); | ||
| 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: ['test@clerk.com'], | ||
| }); | ||
| }); | ||
| 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: ['test@clerk.com'], | ||
| }); | ||
| }); | ||
| 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(); | ||
| }); | ||
| }); | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 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: ['test@clerk.com'], | ||
| 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.
Uh oh!There was an error while loading. Please reload this page. | ||
| f.withUser({ | ||
| email_addresses: ['test@clerk.com'], | ||
| create_organization_enabled: true, | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.