(frontend) add copy link button

Add a copy link button to the doc
visibility component. This button will
copy the link of the doc to the clipboard.
This commit is contained in:
Anthony LC
2024-09-06 18:03:30 +02:00
committed by Anthony LC
parent 4321511631
commit 37db31a8d5
4 changed files with 53 additions and 0 deletions

View File

@@ -33,6 +33,28 @@ test.describe('Doc Visibility', () => {
await expect(row.getByRole('cell').nth(0)).toHaveText('Public');
});
test('It checks the copy link button', async ({ page, browserName }) => {
// eslint-disable-next-line playwright/no-skipped-test
test.skip(
browserName === 'webkit',
'navigator.clipboard is not working with webkit and playwright',
);
await createDoc(page, 'My button copy doc', browserName, 1);
await page.getByRole('button', { name: 'Share' }).click();
await page.getByRole('button', { name: 'Copy link' }).click();
await expect(page.getByText('Link Copied !')).toBeVisible();
const handle = await page.evaluateHandle(() =>
navigator.clipboard.readText(),
);
const clipboardContent = await handle.jsonValue();
expect(clipboardContent).toMatch(page.url());
});
});
test.describe('Doc Visibility: Not loggued', () => {