Skip to content
Merged
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
11 changes: 10 additions & 1 deletion frontend/src/v2/__tests__/V2DevicesPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,14 @@ test('lists a device without exposing its bearer and revokes it in place', async
expect(screen.queryByText(/cm_[a-f0-9]/)).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Revoke' }));
await waitFor(() => expect(axios.delete).toHaveBeenCalledWith('/api/auth/devices/d1'));
expect(await screen.findByText('Revoked')).toBeInTheDocument();
expect(await screen.findByText(/^Revoked/)).toBeInTheDocument();
});

test('a revoked device shows its revoked date and no Revoke button', async () => {
axios.get.mockResolvedValue({ data: { devices: [{ id: 'd2', label: 'old-laptop · commonly-cli', createdAt: '2026-08-31T00:00:00.000Z', lastUsedAt: null, revokedAt: '2026-10-20T09:30:00.000Z' }] } });
render(<V2DevicesPanel />);

expect(await screen.findByText('old-laptop · commonly-cli')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Revoke' })).not.toBeInTheDocument();
expect(screen.getByText(/^Revoked/)).toHaveTextContent(new Date('2026-10-20T09:30:00.000Z').toLocaleString());
});
2 changes: 1 addition & 1 deletion frontend/src/v2/components/V2DevicesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const V2DevicesPanel: React.FC<V2DevicesPanelProps> = ({ showHeading = true }) =
{!loading && devices.length > 0 && <div className="v2-devices__list">
{devices.map((device) => <article className="v2-devices__item" key={device.id}>
<div><strong>{device.label}</strong><span>Created {dateLabel(device.createdAt)} · Last used {dateLabel(device.lastUsedAt)}</span></div>
{device.revokedAt ? <span className="v2-devices__revoked">Revoked</span> : <button type="button" onClick={() => void revoke(device)}>Revoke</button>}
{device.revokedAt ? <span className="v2-devices__revoked">Revoked {dateLabel(device.revokedAt)}</span> : <button type="button" onClick={() => void revoke(device)}>Revoke</button>}
</article>)}
</div>}
</section>
Expand Down
Loading