mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-19 15:14:40 +09:00
The Firefox mermaid e2e test fails intermittently with `Clipboard read operation is not allowed.`, for example in https://github.com/go-gitea/gitea/actions/runs/41281998298/job/124776072700. Firefox rejects `readText()` when it overlaps the page's still pending clipboard write, and `expect.poll` does not retry errors thrown by its callback, so one overlapping read fails the test. https://github.com/go-gitea/gitea/pull/39838 only removed the paste prompt, not this rejection. - A new `assertClipboardText` helper treats a rejected read as a mismatch so it is polled again - The bot token copy test had the same race and uses it too _Written by Claude (Opus 5.5)._
29 lines
1.5 KiB
TypeScript
29 lines
1.5 KiB
TypeScript
import {env} from 'node:process';
|
|
import {expect, test} from '@playwright/test';
|
|
import {apiCreateRepo, apiCreateIssue, assertClipboardText, assertNoJsError, randomString} from './utils.ts';
|
|
|
|
test('mermaid diagram in issue', async ({page, request}) => {
|
|
const repoName = `e2e-mermaid-${randomString(8)}`;
|
|
const owner = env.GITEA_TEST_E2E_USER;
|
|
await apiCreateRepo(request, {name: repoName, autoInit: false});
|
|
const source = 'flowchart TD\n Alpha --> Beta --> Gamma\n Alpha --> Node1 & Node2 & Node3 & Node4 & Node5 & Node6 & Node7 & Node8';
|
|
const {index} = await apiCreateIssue(request, {owner, repo: repoName, title: 'mermaid test', body: `\`\`\`mermaid\n${source}\n\`\`\`\n`});
|
|
await page.goto(`/${owner}/${repoName}/issues/${index}`);
|
|
|
|
const svg = page.frameLocator('iframe.markup-content-iframe').locator('svg');
|
|
await expect(svg).toContainText(/Alpha[\s\S]*Beta[\s\S]*Gamma/);
|
|
const [iframeWidth, iframeHeight, svgWidth, svgHeight] = await page.locator('iframe.markup-content-iframe').evaluate((iframe: HTMLIFrameElement) => {
|
|
const iframeRect = iframe.getBoundingClientRect();
|
|
const svgRect = iframe.contentDocument!.querySelector('svg')!.getBoundingClientRect();
|
|
return [iframeRect.width, iframeRect.height, svgRect.width, svgRect.height];
|
|
});
|
|
expect(svgWidth).toBeCloseTo(iframeWidth, 0);
|
|
expect(svgHeight).toBeCloseTo(iframeHeight, 0);
|
|
|
|
await svg.hover();
|
|
await page.locator('.code-copy').click();
|
|
await assertClipboardText(page, source);
|
|
|
|
await assertNoJsError(page);
|
|
});
|