Page test: no overlapping, clipped or wrapped labels at 1440 and 820 px
This commit is contained in:
+50
-1
@@ -1,5 +1,6 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { expect, Page, test } from '@playwright/test';
|
||||
import { layoutProblems } from './layout';
|
||||
|
||||
/** Every page loads from the API with no failed request and no console error. */
|
||||
function watch(page: Page): string[] {
|
||||
@@ -139,7 +140,7 @@ test('gobernanza: a version with its reports, its curves, and promotion refused
|
||||
}) => {
|
||||
const problems = watch(page);
|
||||
await page.goto('/gobernanza/cama');
|
||||
await expect(page.getByRole('heading', { name: 'survival' })).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Supervivencia' })).toBeVisible();
|
||||
const version = page.locator('tr', { hasText: 'v1' });
|
||||
await expect(version.getByRole('link', { name: 'Validación técnica' })).toBeVisible();
|
||||
await version.getByRole('button', { name: 'Ver gráficas' }).click();
|
||||
@@ -283,3 +284,51 @@ for (const domain of ['cacu', 'cama', 'tea']) {
|
||||
).toBeVisible();
|
||||
});
|
||||
}
|
||||
|
||||
/** Waits for a page's data: no loading indicator left. */
|
||||
async function loaded(page: Page): Promise<void> {
|
||||
await expect(page.locator('app-loading, mat-progress-bar')).toHaveCount(0, {
|
||||
timeout: 5 * 60_000,
|
||||
});
|
||||
await page.waitForTimeout(1000); // plots finish drawing
|
||||
}
|
||||
|
||||
for (const width of [1440, 820]) {
|
||||
test(`layout at ${width} px: no page has overlapping, clipped or wrapped labels`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
const found: string[] = [];
|
||||
const check = async (where: string) => {
|
||||
await loaded(page);
|
||||
for (const p of await layoutProblems(page)) found.push(`${where}: ${p}`);
|
||||
};
|
||||
for (const domain of ['cacu', 'cama', 'tea']) {
|
||||
await page.goto(`/indicadores/${domain}`);
|
||||
const tabs = page.locator('.mdc-tab');
|
||||
for (let i = 0; i < (await tabs.count()); i++) {
|
||||
await tabs.nth(i).click();
|
||||
await check(`${domain} tab ${i + 1}`);
|
||||
}
|
||||
// the record of the risk list's first patient
|
||||
await tabs.nth(2).click();
|
||||
await loaded(page);
|
||||
const first = page.locator('table a[href*="/pacientes/"]').first();
|
||||
if (await first.count()) {
|
||||
await first.click();
|
||||
await check(`${domain} record`);
|
||||
}
|
||||
await page.goto(`/gobernanza/${domain}`);
|
||||
await check(`${domain} gobernanza`);
|
||||
}
|
||||
await page.goto('/conectar');
|
||||
await check('conectar');
|
||||
await page.goto('/revision');
|
||||
const tabs = page.locator('.mdc-tab');
|
||||
for (let i = 0; i < (await tabs.count()); i++) {
|
||||
await tabs.nth(i).click();
|
||||
await check(`revision tab ${i + 1}`);
|
||||
}
|
||||
expect(found).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user