From 60de68a2303381e46f650edd9cf5aa87a4665242 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Tue, 14 Jul 2026 01:05:11 -0300 Subject: [PATCH] feat(homolog): L4c fluxo criar/revogar API key pela UI --- tests/homolog/ui/api-key-flow.spec.ts | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/homolog/ui/api-key-flow.spec.ts diff --git a/tests/homolog/ui/api-key-flow.spec.ts b/tests/homolog/ui/api-key-flow.spec.ts new file mode 100644 index 0000000000..8c8bf19141 --- /dev/null +++ b/tests/homolog/ui/api-key-flow.spec.ts @@ -0,0 +1,31 @@ +import { test, expect } from "@playwright/test"; + +// Locators confirmados em +// src/app/(dashboard)/dashboard/api-manager/ApiManagerPageClient.tsx (rota real da +// tela de keys é /dashboard/api-manager, não /dashboard/api-keys): +// - botão "Create API Key" (t("createKey")) abre o modal; o submit do modal tem o mesmo texto +// - = "e.g. Production Key" +// - após criar, abre o "Created Key Modal" (t("keyCreated")) — fechar pelo botão t("done")="Done" +// - cada key vira uma linha div.grid-cols-12; o botão de deletar tem title={t("deleteKey")}="Delete key" +// - handleDeleteKey usa window.confirm(t("deleteConfirm")) — não é modal de UI, +// precisa do listener page.on("dialog", ...). +const KEY_NAME = `homolog-ui-${Date.now()}`; + +test("cria e revoga uma API key pela UI", async ({ page }) => { + page.on("dialog", (dialog) => dialog.accept()); + + await page.goto("/dashboard/api-manager"); + await page.getByRole("button", { name: "Create API Key" }).first().click(); + await page.getByPlaceholder("e.g. Production Key").fill(KEY_NAME); + // segundo "Create API Key" é o submit do modal (o primeiro é o botão que o abriu) + await page.getByRole("button", { name: "Create API Key" }).last().click(); + + // fecha o modal "API Key Created" + await page.getByRole("button", { name: "Done" }).click(); + const row = page.locator("div.grid-cols-12", { hasText: KEY_NAME }); + await expect(row).toHaveCount(1); + + // revoga a mesma key (cleanup — a suíte não deixa lixo na VPS) + await row.getByTitle("Delete key").click(); + await expect(page.locator("div.grid-cols-12", { hasText: KEY_NAME })).toHaveCount(0); +});