tests(e2e): Explicitly generate screenshots

As per https://codeberg.org/forgejo/forgejo/pulls/6400, the after hook runs for every test, resulting in duplicated screenshots.

Not all tests are supposed to generate screenshots, especially because they could be flaky (also see 206d4cfb7a ).
Additionally, the implicit behaviour might have caused confusion, so we now create screenshots explicitly, adding the statements from the tests that already generated screenshots.
This commit is contained in:
Otto Richter 2025-01-14 22:13:31 +01:00
parent c81e5fe123
commit a975b6ab94
12 changed files with 27 additions and 19 deletions

View file

@ -8,7 +8,7 @@
// @watch end
import {expect} from '@playwright/test';
import {test} from './utils_e2e.ts';
import {save_visual, test} from './utils_e2e.ts';
test('copy src file path to clipboard', async ({page}, workerInfo) => {
test.skip(['Mobile Safari', 'webkit'].includes(workerInfo.project.name), 'Apple clipboard API addon - starting at just $499!');
@ -19,6 +19,7 @@ test('copy src file path to clipboard', async ({page}, workerInfo) => {
await page.click('[data-clipboard-text]');
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
expect(clipboardText).toContain('README.md');
await save_visual(page);
});
test('copy diff file path to clipboard', async ({page}, workerInfo) => {
@ -30,4 +31,6 @@ test('copy diff file path to clipboard', async ({page}, workerInfo) => {
await page.click('[data-clipboard-text]');
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
expect(clipboardText).toContain('README.md');
await expect(page.getByText('Copied')).toBeVisible();
await save_visual(page);
});