Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/passkey-add-pending.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ describe('Passkey action errors', () => {
});
});

describe('Adding a passkey', () => {
it('shows the Add button pending while the passkey request runs', async () => {
serveAccounts();
await renderWithClerk(<UserProfilePasskeysSection />);
const creation = holdRequests('post', '/v1/me/passkeys');
const user = userEvent.setup();

try {
await user.click(screen.getByRole('button', { name: 'Add passkey' }));
await waitFor(() => expect(creation.requests).toHaveLength(1));
expect(screen.getByRole('button', { name: 'Add passkey' })).toHaveAttribute('aria-busy', 'true');
await waitFor(() => expect(screen.getByRole('progressbar')).toBeVisible());
} finally {
creation.fail('form_param_invalid', 'Credential failed');
}
await waitFor(() => expect(screen.getByRole('button', { name: 'Add passkey' })).toBeEnabled());
await waitFor(() => expect(screen.queryByRole('progressbar')).toBeNull());
});
});

describe('Changing the active passkey account', () => {
it('clears the previous account Add error after a user switch', async () => {
serveAccounts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Ref } from 'react';
import type { ConfirmController } from '../../../blocks/confirm';
import { Confirmation } from '../../../blocks/confirmation';
import { ReverificationDialog } from '../../../blocks/reverification';
import { Button } from '../../../components/button';
import { SubmitButton } from '../../../components/button';
import type { DialogFocusTarget } from '../../../components/dialog';
import { Field } from '../../../components/field';
import { Icon } from '../../../components/icon';
Expand Down Expand Up @@ -69,14 +69,15 @@ export function UserProfilePasskeysSectionView({
</Section.Content>
{onAdd ? (
<Section.Actions>
<Button
<SubmitButton
ref={addButtonRef}
type='button'
aria-label={m.addLabel}
color='neutral'
size='sm'
variant='outline'
isPending={isAdding && !addReverification?.visible}
disabled={isAdding}
aria-busy={isAdding}
onClick={onAdd}
>
<Icon
Expand All @@ -85,7 +86,7 @@ export function UserProfilePasskeysSectionView({
size='sm'
/>
{m.add}
</Button>
</SubmitButton>
</Section.Actions>
) : null}
</Section.Header>
Expand Down
Loading