mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-06-22 10:02:15 +00:00
chore(e2e): refactor "Toggle visibility" org-members test (#12871)
This test fails very often in CI. This should hopefully improve it. With a downclocked CPU I've got 2 errors in 10 tries. After adding ``` await page.waitForLoadState(); ``` I got no errors in 20 tries. But my testing methodology is unreliable so there's no guarantee that this helps: * `Locator.click()` documentation says that it already waits by default for caused navigation to finish * I added some `date` time measurement and `waitForLoadState` was clocking in about 5-15 ms, which shouldn't be causing the issue for `expect` that times out in 3000ms ...but e2e issues were `element(s) not found` on timeout, not wrong state, so my assumption is that somehow it is asserting the wrong snapshot of a page that isn't fully loaded Additionally, I've converted _revertion_ logic to _make consistent before testing_, which is better at handling test retries in case that the _revertion_ part of the code was never ran in previous failure. In such case test retry is guaranteed to fail as well, at least when testing locally, not sure about CI. Additionally, a completely unrelated comment fix in Playwright config. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12871 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
parent
667479c7b0
commit
eb76582261
2 changed files with 11 additions and 9 deletions
|
|
@ -8,7 +8,7 @@ const BASE_URL = process.env.GITEA_URL?.replace?.(/\/$/g, '') || 'http://localho
|
|||
*/
|
||||
export default {
|
||||
testDir: './tests/e2e/',
|
||||
testMatch: /.*\.test\.e2e\.ts/, // Match any .test.e2e.js files
|
||||
testMatch: /.*\.test\.e2e\.ts/, // Match any .test.e2e.ts files
|
||||
|
||||
// you can adjust this value locally to match your machine's power,
|
||||
// or pass `--workers x` to playwright
|
||||
|
|
|
|||
|
|
@ -19,18 +19,20 @@ test('Toggle visibility', async ({page}) => {
|
|||
// Button "Make visible" for user2's row
|
||||
const showUser2 = page.locator('.link-action[data-url="/org/org3/members/action/public?uid=2"]');
|
||||
|
||||
await expect(hideUser2).toBeVisible();
|
||||
await expect(showUser2).toBeHidden();
|
||||
await hideUser2.click();
|
||||
if (await hideUser2.isHidden()) {
|
||||
// Bring page to a consistent state before testing
|
||||
await showUser2.click();
|
||||
await expect(hideUser2).toBeVisible();
|
||||
await expect(showUser2).toBeHidden();
|
||||
}
|
||||
|
||||
// Button action was flipped
|
||||
// Click button to make user2 hidden
|
||||
await hideUser2.click();
|
||||
await page.waitForLoadState();
|
||||
|
||||
// Verify that button action was flipped
|
||||
await expect(hideUser2).toBeHidden();
|
||||
await expect(showUser2).toBeVisible();
|
||||
|
||||
// Revert for repeatability
|
||||
await showUser2.click();
|
||||
await expect(hideUser2).toBeVisible();
|
||||
await expect(showUser2).toBeHidden();
|
||||
});
|
||||
|
||||
test('Leave org', async ({page}) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue