fix: resolve final workbench re-review findings

This commit is contained in:
2026-07-19 20:36:29 +08:00
parent e289b1dbb0
commit 2d82705679
10 changed files with 246 additions and 20 deletions

View File

@@ -0,0 +1,36 @@
import '@testing-library/jest-dom/vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/svelte';
import { afterEach, describe, expect, it } from 'vitest';
import CustomLinkChannel from './CustomLinkChannel.svelte';
const channel = {
id: 'project-custom-link',
projectID: 1,
type: 'custom_link' as const,
title: 'Roadmap Board',
icon: 'link',
url: 'https://example.com/roadmap',
sortOrder: 1,
};
const originalClipboard = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
afterEach(() => {
cleanup();
if (originalClipboard) {
Object.defineProperty(navigator, 'clipboard', originalClipboard);
} else {
Reflect.deleteProperty(navigator, 'clipboard');
}
});
describe('CustomLinkChannel', () => {
it('reports unavailable clipboard access without showing URL copied', async () => {
Reflect.deleteProperty(navigator, 'clipboard');
render(CustomLinkChannel, { props: { channel } });
await fireEvent.click(screen.getByRole('button', { name: 'Copy URL' }));
await waitFor(() => expect(screen.getByText('Copy unavailable in this browser.')).toBeInTheDocument());
expect(screen.queryByText('URL copied.')).not.toBeInTheDocument();
});
});