ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m20s
release / desktop (Linux и Windows в релиз) (push) Successful in 19m22s
ci / ts / ts (packages + web) (push) Successful in 3m9s
release / release (версия и заметки) (push) Successful in 10s
release / android (APK в релиз) (push) Successful in 4m7s
release / prune (старые файлы и прогоны) (push) Successful in 11s
46 lines
2.8 KiB
TypeScript
46 lines
2.8 KiB
TypeScript
import axe from 'axe-core';
|
|
import { expect, test } from '@playwright/test';
|
|
|
|
for (const width of [390, 1280]) {
|
|
test(`notification history scrolls inside the dialog at ${width}px`, async ({ page }, info) => {
|
|
await page.setViewportSize({ width, height: 900 });
|
|
await page.addInitScript(() => {
|
|
localStorage.setItem('pipu.locale', 'ru');
|
|
localStorage.setItem('pipu.e2e.notifications', '1');
|
|
});
|
|
await page.goto('/login');
|
|
await page.getByLabel('Логин', { exact: true }).fill('alice');
|
|
await page.getByRole('textbox', { name: 'Пароль', exact: true }).fill('alice-password');
|
|
await page.getByRole('button', { name: 'Войти', exact: true }).click();
|
|
await page.getByRole('button', { name: 'Меню профиля', exact: true }).click();
|
|
await page.getByRole('menuitem', { name: 'Уведомления 4', exact: true }).click();
|
|
const dialog = page.getByRole('dialog', { name: 'Уведомления', exact: true });
|
|
const list = dialog.getByRole('region', { name: 'Уведомления', exact: true });
|
|
await expect(list.getByRole('article')).toHaveCount(28);
|
|
const box = (await dialog.boundingBox())!;
|
|
expect(box.height).toBeLessThanOrEqual(680);
|
|
expect(box.width).toBeLessThanOrEqual(Math.min(600, width - (width < 768 ? 24 : 32)));
|
|
const close = dialog.getByRole('button', { name: 'Закрыть', exact: true });
|
|
const closeBefore = (await close.boundingBox())!;
|
|
await list.evaluate(element => { element.scrollTop = element.scrollHeight; });
|
|
await expect(close).toBeVisible();
|
|
expect((await close.boundingBox())!.y).toBe(closeBefore.y);
|
|
await list.evaluate(element => { element.scrollTop = 0; });
|
|
await page.addScriptTag({ content: axe.source });
|
|
const violations = await page.evaluate(async (selector) => {
|
|
const result = await (window as unknown as { axe: typeof axe }).axe.run(document.querySelector(selector)!, { runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa'] } });
|
|
return result.violations.map(violation => ({ id: violation.id, nodes: violation.nodes.map(node => node.target) }));
|
|
}, '[role="dialog"]');
|
|
expect(violations).toEqual([]);
|
|
await page.screenshot({ path: info.outputPath('notifications.png'), fullPage: true });
|
|
await dialog.getByRole('button', { name: 'Непрочитанные 4', exact: true }).click();
|
|
await expect(list.getByRole('article')).toHaveCount(4);
|
|
await list.getByRole('button', { name: 'Прочитано', exact: true }).first().click();
|
|
await expect(list.getByRole('article')).toHaveCount(3);
|
|
await dialog.getByRole('button', { name: 'Все', exact: true }).click();
|
|
await expect(list.getByRole('article')).toHaveCount(28);
|
|
await close.click();
|
|
await expect(dialog).toBeHidden();
|
|
});
|
|
}
|