tests(e2e): Test new repo dialog and behaviour

- screenshots and basic accessibility scan of collapsed and expanded sections
  - the dropdowns do not pass the accessibility checks, but I haven't found an easy fix
  - I manually confirmed the dropdown behaviour via orca and firefox, though
This commit is contained in:
Otto Richter 2024-12-27 22:57:24 +01:00
parent 8d32ca32c2
commit 8d829a97b2
3 changed files with 152 additions and 0 deletions

View file

@ -81,6 +81,14 @@ export async function save_visual(page: Page) {
await page.locator('.flex-item-body > relative-time').filter({hasText: /now|minute/}).evaluateAll((nodes) => {
for (const node of nodes) node.outerHTML = 'relative time in repo';
});
// dynamically generated UUIDs
await page.getByText('dyn-id-').evaluateAll((nodes) => {
for (const node of nodes) node.innerHTML = node.innerHTML.replaceAll(/dyn-id-[a-f0-9-]+/g, 'dynamic-id');
});
// repeat above, work around https://github.com/microsoft/playwright/issues/34152
await page.getByText('dyn-id-').evaluateAll((nodes) => {
for (const node of nodes) node.innerHTML = node.innerHTML.replaceAll(/dyn-id-[a-f0-9-]+/g, 'dynamic-id');
});
await page.locator('relative-time').evaluateAll((nodes) => {
for (const node of nodes) node.outerHTML = 'time element';
});
@ -97,6 +105,8 @@ export async function save_visual(page: Page) {
page.locator('#repo_migrating'),
// update order of recently created repos is not fully deterministic
page.locator('.flex-item-main').filter({hasText: 'relative time in repo'}),
// dynamic IDs in fixed-size inputs
page.locator('input[value*="dyn-id-"]'),
],
});
}
@ -122,3 +132,8 @@ export async function create_temp_user(browser: Browser, workerInfo: TestInfo, r
return {context: await login_user(browser, workerInfo, username), username};
}
// returns a random string with a pattern that can be filtered for screenshots automatically
export function dynamic_id() {
return `dyn-id-${globalThis.crypto.randomUUID()}`;
}