fix: resolve final workbench re-review findings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import { fireEvent, render, screen, within } from '@testing-library/svelte';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { fireEvent, render, screen, waitFor, within } from '@testing-library/svelte';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import ProjectWorkbench from './ProjectWorkbench.svelte';
|
||||
|
||||
describe('ProjectWorkbench', () => {
|
||||
@@ -88,6 +88,11 @@ describe('ProjectWorkbench', () => {
|
||||
});
|
||||
|
||||
it('provides Copy link feedback and disables unavailable archive actions', async () => {
|
||||
const originalClipboard = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText: vi.fn().mockResolvedValue(undefined) } as Clipboard,
|
||||
});
|
||||
render(ProjectWorkbench, { props: { currentUser: { account: 'david@example.com' } } });
|
||||
const inspector = screen.getByLabelText('Object inspector');
|
||||
|
||||
@@ -96,7 +101,13 @@ describe('ProjectWorkbench', () => {
|
||||
await fireEvent.click(within(inspector).getByRole('button', { name: 'More' }));
|
||||
await fireEvent.click(within(inspector).getByRole('button', { name: 'Copy link' }));
|
||||
|
||||
expect(within(inspector).getByRole('status')).toHaveTextContent('Link copied to clipboard.');
|
||||
await waitFor(() => expect(within(inspector).getByRole('status')).toHaveTextContent('Link copied to clipboard.'));
|
||||
expect(within(inspector).getByRole('button', { name: 'Archive is unavailable in this preview' })).toBeDisabled();
|
||||
|
||||
if (originalClipboard) {
|
||||
Object.defineProperty(navigator, 'clipboard', originalClipboard);
|
||||
} else {
|
||||
Reflect.deleteProperty(navigator, 'clipboard');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user