test(dashboard): reactivate request logger coverage (#13843)

* test(dashboard): reactivate request logger coverage

* test(dashboard): assert the request-logger modal by its own label

The drift this PR unblocks is real — the next-intl mock lost its `useLocale`
export in #7935, so the suite died on `No "useLocale" export is defined`.
Restoring it is the actual fix.

The dialog assertions were also loosened to `[role="dialog"]`, and that part
was not needed: 20 components under src/ render that role, so the selector
stops proving this particular modal is the one on screen. Measured — keeping
only the `useLocale` fix and restoring a precise selector still passes 6/6.

Now asserting `[aria-label="ariaLabel"]`, which is what RequestLoggerDetail.tsx:469
renders (the mock returns the key rather than the translation).

---------

Co-authored-by: Paco Cartones <pacocartones@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
Paco Cartones
2026-09-17 22:52:34 +02:00
committed by GitHub
parent 1ea87603c0
commit 9688032451
3 changed files with 8 additions and 11 deletions

View File

@@ -2,12 +2,6 @@
"_comment": "Inventário dos arquivos de teste excluídos do Vitest. Toda entrada precisa de uma issue de rastreio ABERTA. Gate: npm run check:vitest-exclusions. Contexto: #13204.",
"_measured": "2026-09-10 — cada arquivo rodado isoladamente com as exclusões removidas",
"excluded": [
{
"file": "tests/unit/ui/request-logger-autorefresh-visibility-3972.test.tsx",
"issue": "#13204",
"measured": "2026-09-10",
"status": "Tests 1 failed | 5 passed (6)"
},
{
"file": "tests/unit/ui/logs-page-detail-modal-reopen-on-close.test.tsx",
"issue": "#13204",

View File

@@ -24,6 +24,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("next-intl", () => ({
useTranslations: () => (key: string) => key,
useLocale: () => "en",
}));
vi.mock("next/navigation", () => ({
@@ -67,6 +68,9 @@ function deferredResponse() {
}
beforeEach(() => {
(
globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
).IS_REACT_ACT_ENVIRONMENT = true;
callLogsRequests = 0;
if (!globalThis.localStorage) {
const store = new Map<string, string>();
@@ -163,14 +167,14 @@ describe("RequestLoggerV2 detail modal lifecycle", () => {
await act(async () => {
row?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
});
expect(container.querySelector('[aria-label="Request log detail"]')).not.toBeNull();
expect(container.querySelector('[aria-label="ariaLabel"]')).not.toBeNull();
await act(async () => {
container
.querySelector<HTMLButtonElement>('[aria-label="Close detail modal"]')
.querySelector<HTMLButtonElement>('[aria-label="close"]')
?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
});
expect(container.querySelector('[aria-label="Request log detail"]')).toBeNull();
expect(container.querySelector('[aria-label="ariaLabel"]')).toBeNull();
await act(async () => {
detail.resolve(
@@ -189,7 +193,7 @@ describe("RequestLoggerV2 detail modal lifecycle", () => {
await detail.promise;
});
expect(container.querySelector('[aria-label="Request log detail"]')).toBeNull();
expect(container.querySelector('[aria-label="ariaLabel"]')).toBeNull();
});
});

View File

@@ -38,7 +38,6 @@ export default defineConfig({
"tests/e2e/ecosystem.test.ts",
"tests/e2e/protocol-clients.test.ts",
// ── Pre-existing failures tracked by #8618 ───────────────────────────────
"tests/unit/ui/request-logger-autorefresh-visibility-3972.test.tsx", // #13204 — falha real; remover esta exclusão quando consertado
"tests/unit/ui/logs-page-detail-modal-reopen-on-close.test.tsx", // #13204 — falha real; remover esta exclusão quando consertado
"tests/unit/ui/agent-card.test.tsx", // #13204 — falha real; remover esta exclusão quando consertado
"src/app/(dashboard)/dashboard/cache/__tests__/CacheTrends.test.tsx", // #13204 — falha real; remover esta exclusão quando consertado