Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/frontend_smoke/botoes.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { coletarErros, esperarSemErros, roteiroBotoes, IDS_CONTRATO } from './helpers.mjs';
import { coletarErros, esperarSemErros, roteiroBotoes, IDS_CONTRATO, ALTURA_MIN_TOQUE } from './helpers.mjs';

test('cenário 1 — botões Solicitar A/B/C e Reiniciar funcionam', async ({ page }) => {
const erros = coletarErros(page);
Expand Down Expand Up @@ -29,7 +29,7 @@ test('botões de controle: ícones SVG (sem emoji), ≥ 44 px, ajuda ligada por
const b = page.locator(`#${id}`);
await expect(b.locator('svg.ico')).toHaveCount(1);
expect(await b.innerText()).not.toMatch(/\p{Extended_Pictographic}/u);
expect((await b.boundingBox()).height).toBeGreaterThanOrEqual(44);
expect((await b.boundingBox()).height).toBeGreaterThanOrEqual(ALTURA_MIN_TOQUE);
}
for (const id of ['btn-solicitar-a', 'btn-solicitar-b', 'btn-solicitar-c']) {
await expect(page.locator(`#${id}`)).toHaveAttribute('aria-describedby', 'ajuda-controle');
Expand Down
5 changes: 5 additions & 0 deletions test/frontend_smoke/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export async function roteiroBotoes(page) {
}

/** IDs usados por frontend/js/app.js (objeto els) e diagrama3d.js — contrato congelado (§3.3). */
// Alvo de toque mínimo (WCAG 2.5.5: 44 × 44 px). O boundingBox do navegador
// devolve frações (ex.: 43.99998 px para min-height: 44px com layout em
// subpixel), então a comparação aceita 0,01 px de arredondamento.
export const ALTURA_MIN_TOQUE = 44 - 0.01;

export const IDS_CONTRATO = [
'mqtt-status', 'gateway-status', 'server-time', 'annun-estado', 'annun-estado-v',
'annun-estoque', 'annun-estoque-v', 'estado-atual', 'peca-solicitada', 'uptime',
Expand Down
8 changes: 4 additions & 4 deletions test/frontend_smoke/mobile.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Cenário 6 (spec §7.2): 375 px sem rolagem horizontal, barra inferior e alvos ≥ 44 px.
import { test, expect } from '@playwright/test';
import { coletarErros, esperarSemErros } from './helpers.mjs';
import { coletarErros, esperarSemErros, ALTURA_MIN_TOQUE } from './helpers.mjs';

test.use({ viewport: { width: 375, height: 812 }, isMobile: true, hasTouch: true });

Expand All @@ -16,15 +16,15 @@ test('cenário 6 — sem rolagem horizontal, seletor como barra inferior, alvos
const nav = await page.locator('nav.seletor').boundingBox();
expect(nav.y + nav.height).toBeGreaterThan(812 - 2); // colada na base da tela
for (const t of await page.locator('a.seletor-tecla').all()) {
expect((await t.boundingBox()).height).toBeGreaterThanOrEqual(44);
expect((await t.boundingBox()).height).toBeGreaterThanOrEqual(ALTURA_MIN_TOQUE);
}
}

await page.goto('/#/');
for (const id of ['btn-solicitar-a', 'btn-solicitar-b', 'btn-solicitar-c', 'btn-reset']) {
const b = page.locator(`#${id}`);
await b.scrollIntoViewIfNeeded();
expect((await b.boundingBox()).height).toBeGreaterThanOrEqual(44);
expect((await b.boundingBox()).height).toBeGreaterThanOrEqual(ALTURA_MIN_TOQUE);
}

// Controles da cena recolhidos atrás de um botão.
Expand All @@ -39,7 +39,7 @@ test('cenário 6 — sem rolagem horizontal, seletor como barra inferior, alvos
for (const alvo of await page.locator('#arq-controles .arq-btn, #arq-controles .arq-check').all()) {
if (!(await alvo.isVisible())) continue;
const altura = (await alvo.boundingBox()).height;
expect(altura, `"${(await alvo.textContent()).trim()}" com ${altura} px`).toBeGreaterThanOrEqual(44);
expect(altura, `"${(await alvo.textContent()).trim()}" com ${altura} px`).toBeGreaterThanOrEqual(ALTURA_MIN_TOQUE);
}
esperarSemErros(erros);
});
4 changes: 2 additions & 2 deletions test/frontend_smoke/navegacao.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { coletarErros, esperarSemErros } from './helpers.mjs';
import { coletarErros, esperarSemErros, ALTURA_MIN_TOQUE } from './helpers.mjs';

const VISTAS = ['#view-principal', '#view-status', '#view-arquitetura'];

Expand Down Expand Up @@ -72,7 +72,7 @@ test('cenário 3b — seletor de vistas: teclas, aria-current e contador LOG', a
test('teclas do seletor têm ≥ 44 px de altura', async ({ page }) => {
await page.goto('/');
for (const t of await page.locator('a.seletor-tecla').all()) {
expect((await t.boundingBox()).height).toBeGreaterThanOrEqual(44);
expect((await t.boundingBox()).height).toBeGreaterThanOrEqual(ALTURA_MIN_TOQUE);
}
});

Expand Down
Loading