diff --git a/backend/package-lock.json b/backend/package-lock.json index eac38f1..0a2317a 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1271,9 +1271,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", - "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz", + "integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==", "funding": [ { "type": "individual", diff --git a/e2e/tests/assistants.e2e.mjs b/e2e/tests/assistants.e2e.mjs index dce6df5..cd21063 100644 --- a/e2e/tests/assistants.e2e.mjs +++ b/e2e/tests/assistants.e2e.mjs @@ -97,11 +97,23 @@ test("Chat: mobile não transborda e o campo de pergunta é acessível por tecla await page.goto(`${APP}/chat`); await expect(page.getByLabel("Sua pergunta")).toBeVisible(); await assertNoHorizontalOverflow(page, "chat mobile"); - await page.getByRole("button", { name: "Nova conversa" }).focus(); - await page.keyboard.press("Tab"); - await page.keyboard.press("Tab"); - const focused = await page.evaluate(() => document.activeElement?.id || document.activeElement?.tagName); - assert.ok(focused); + const sidebarToggle = page.getByRole("button", { name: "Conversas e projeto", exact: true }); + await expect(sidebarToggle).toHaveAttribute("aria-expanded", "false"); + assert.equal(await page.getByRole("button", { name: "Nova conversa", exact: true }).isVisible(), false); + await sidebarToggle.focus(); + await page.keyboard.press("Enter"); + await expect(page.getByRole("button", { name: "Ocultar conversas e projeto", exact: true })).toHaveAttribute("aria-expanded", "true"); + await expect(page.getByRole("button", { name: "Nova conversa", exact: true })).toBeVisible(); + await page.keyboard.press("Enter"); + await expect(sidebarToggle).toHaveAttribute("aria-expanded", "false"); + for (let step = 0; step < 12; step += 1) { + await page.keyboard.press("Tab"); + if (await page.evaluate(() => document.activeElement?.id === "chat-question")) break; + } + assert.equal(await page.evaluate(() => document.activeElement?.id), "chat-question"); + await page.keyboard.type("Pergunta digitada pelo teclado"); + assert.equal(await page.getByLabel("Sua pergunta").inputValue(), "Pergunta digitada pelo teclado"); + await assertNoHorizontalOverflow(page, "chat mobile com painel recolhido"); } finally { await context.close(); } diff --git a/e2e/tests/hierarchy-ui.e2e.mjs b/e2e/tests/hierarchy-ui.e2e.mjs index 72a8730..ac700cd 100644 --- a/e2e/tests/hierarchy-ui.e2e.mjs +++ b/e2e/tests/hierarchy-ui.e2e.mjs @@ -45,7 +45,7 @@ test("Épico → feature → PBI pela interface: validação, qualidade em tempo await expect(page.getByText("Login válido")).toBeVisible(); await page.getByRole("button", { name: "Marcar como concluído" }).click(); - await expect(page.getByText(/Concluído/i).first()).toBeVisible(); + await expect(page.getByText("concluido", { exact: true }).first()).toBeVisible(); } finally { await context.close(); } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 7757b3a..ec626a4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -18,15 +18,17 @@ export const App: React.FC = () => { const { session, logout } = useAuth(); const [pathname, setPathname] = useState(window.location.pathname); + const [menuOpen, setMenuOpen] = useState(false); + const isAdmin = session.user?.role === "admin"; const activeTab = isProjectPath(pathname) ? "projects" : (Object.keys(routes) as Array).find((key) => routes[key] === pathname) || "projects"; - const setActiveTab = (tab: keyof typeof routes) => navigate(routes[tab]); + const setActiveTab = (tab: keyof typeof routes) => { setMenuOpen(false); navigate(routes[tab]); }; useEffect(() => { - const update = () => setPathname(window.location.pathname); + const update = () => { setPathname(window.location.pathname); setMenuOpen(false); }; window.addEventListener("popstate", update); return () => window.removeEventListener("popstate", update); }, []); @@ -38,7 +40,8 @@ export const App: React.FC = () => { S•NAPSE -