fix: restore portfolio loader and safe consent revocation

This commit is contained in:
Evandro Fonseca Junior committed 2026-09-04 21:40:35 -03:00
1 parent bff3e4d735
commit a4e5e5c048
4 files changed
+315 -13

No files matched your search

+27
View File
@@ -223,4 +223,31 @@ describe("GoogleAnalytics consent", () => {
).not.toBeInTheDocument();
});
});
it("reports when revocation cannot be persisted", async () => {
const user = userEvent.setup();
localStorage.setItem(CONSENT_KEY, "granted");
jest.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
throw new Error("storage blocked");
});
render(<GoogleAnalytics />);
await screen.findByTestId("google-analytics-script");
await user.click(
screen.getByRole("button", { name: "Preferências de analytics" }),
);
await user.click(screen.getByRole("button", { name: "Revogar analytics" }));
expect(
screen.getByRole("alert", {
name: "Falha ao salvar a revogação",
}),
).toHaveTextContent(
"Não foi possível salvar a revogação. Tente novamente para concluir.",
);
expect(analyticsWindow[GA_DISABLE_KEY]).not.toBe(true);
expect(
screen.getByRole("button", { name: "Revogar analytics" }),
).toBeVisible();
});
});