fix(home): oferta leva ao formulário, ofertas logo depois da vitrine
O botão das ofertas rola até o contato com o tipo marcado e não quebra mais as âncoras; ofertas com o que você recebe e primeiro passo, logo depois da vitrine; bloco de IA fora da home; cartão largo da SEV no hero do celular; separador da faixa de clientes só entre itens; favicon de 13 para 1,8 KB; pré-carregamento só no hover e nunca de /#... fora da home; X do menu e cabeçalho opaco; WhatsApp com "o case"; /ia com 3 passos e modelo de relatório ilustrativo; Sobre alinhado ao currículo; CSP Report-Only com os domínios do Ads.
This commit is contained in:
1 parent
fc44a69fb3
commit
9e2d65a926
51 files changed
+1730
-420
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import HoverPrefetchLink from "./HoverPrefetchLink";
|
||||
|
||||
jest.mock("next/navigation", () => ({ usePathname: jest.fn() }));
|
||||
|
||||
jest.mock("next/link", () => ({
|
||||
__esModule: true,
|
||||
default: ({
|
||||
@@ -19,6 +22,10 @@ jest.mock("next/link", () => ({
|
||||
|
||||
const link = () => screen.getByRole("link", { name: "Cases" });
|
||||
|
||||
beforeEach(() => {
|
||||
jest.mocked(usePathname).mockReturnValue("/");
|
||||
});
|
||||
|
||||
it("does not prefetch when the page opens", () => {
|
||||
render(<HoverPrefetchLink href="/cases">Cases</HoverPrefetchLink>);
|
||||
|
||||
@@ -79,3 +86,95 @@ it("only prefetches the link that was reached, not its siblings", () => {
|
||||
"false",
|
||||
);
|
||||
});
|
||||
|
||||
describe("links para um ponto da home", () => {
|
||||
it.each([["/#contact"], ["/#process"], ["/?tipo=site#contact"]])(
|
||||
"never prefetches %s from another page, even on hover, focus or touch (it would pull the whole home)",
|
||||
(href) => {
|
||||
jest.mocked(usePathname).mockReturnValue("/privacidade");
|
||||
render(<HoverPrefetchLink href={href}>Cases</HoverPrefetchLink>);
|
||||
|
||||
expect(link()).toHaveAttribute("data-prefetch", "false");
|
||||
fireEvent.mouseEnter(link());
|
||||
fireEvent.focus(link());
|
||||
fireEvent.touchStart(link());
|
||||
expect(link()).toHaveAttribute("data-prefetch", "false");
|
||||
},
|
||||
);
|
||||
|
||||
it("never prefetches an object href with the home path and a hash from another page", () => {
|
||||
jest.mocked(usePathname).mockReturnValue("/cases");
|
||||
render(
|
||||
<HoverPrefetchLink href={{ pathname: "/", hash: "contact" }}>
|
||||
Cases
|
||||
</HoverPrefetchLink>,
|
||||
);
|
||||
|
||||
fireEvent.mouseEnter(link());
|
||||
expect(link()).toHaveAttribute("data-prefetch", "false");
|
||||
});
|
||||
|
||||
it("stops prefetching a home anchor that was reached on the home once the visitor moves to another page (the header does not remount)", () => {
|
||||
jest.mocked(usePathname).mockReturnValue("/");
|
||||
const { rerender } = render(
|
||||
<HoverPrefetchLink href="/#contact">Cases</HoverPrefetchLink>,
|
||||
);
|
||||
fireEvent.mouseEnter(link());
|
||||
expect(link()).toHaveAttribute("data-prefetch", "null");
|
||||
|
||||
jest.mocked(usePathname).mockReturnValue("/cases");
|
||||
rerender(<HoverPrefetchLink href="/#contact">Cases</HoverPrefetchLink>);
|
||||
expect(link()).toHaveAttribute("data-prefetch", "false");
|
||||
});
|
||||
|
||||
it("keeps the hover prefetch for a home anchor while on the home itself (it is the same page)", () => {
|
||||
jest.mocked(usePathname).mockReturnValue("/");
|
||||
render(<HoverPrefetchLink href="/#contact">Cases</HoverPrefetchLink>);
|
||||
|
||||
fireEvent.mouseEnter(link());
|
||||
expect(link()).toHaveAttribute("data-prefetch", "null");
|
||||
});
|
||||
|
||||
it("keeps the hover prefetch for a link to another page, and for the home without a hash, from anywhere", () => {
|
||||
jest.mocked(usePathname).mockReturnValue("/privacidade");
|
||||
render(
|
||||
<>
|
||||
<HoverPrefetchLink href="/cases">Cases</HoverPrefetchLink>
|
||||
<HoverPrefetchLink href="/">Início</HoverPrefetchLink>
|
||||
<HoverPrefetchLink href="/cases/sev-modaintima#video">
|
||||
Vídeo
|
||||
</HoverPrefetchLink>
|
||||
<HoverPrefetchLink href={{ pathname: "/servicos", hash: "x" }}>
|
||||
Serviços
|
||||
</HoverPrefetchLink>
|
||||
</>,
|
||||
);
|
||||
|
||||
for (const name of ["Cases", "Início", "Vídeo", "Serviços"]) {
|
||||
const item = screen.getByRole("link", { name });
|
||||
fireEvent.mouseEnter(item);
|
||||
expect(item).toHaveAttribute("data-prefetch", "null");
|
||||
}
|
||||
});
|
||||
|
||||
it("still runs the caller's handlers on a home anchor seen from another page", () => {
|
||||
jest.mocked(usePathname).mockReturnValue("/privacidade");
|
||||
const onMouseEnter = jest.fn();
|
||||
render(
|
||||
<HoverPrefetchLink href="/#contact" onMouseEnter={onMouseEnter}>
|
||||
Cases
|
||||
</HoverPrefetchLink>,
|
||||
);
|
||||
|
||||
fireEvent.mouseEnter(link());
|
||||
expect(onMouseEnter).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("prefetches as usual when the router is unknown (no pathname)", () => {
|
||||
jest.mocked(usePathname).mockReturnValue(null as unknown as string);
|
||||
render(<HoverPrefetchLink href="/#contact">Cases</HoverPrefetchLink>);
|
||||
|
||||
fireEvent.mouseEnter(link());
|
||||
expect(link()).toHaveAttribute("data-prefetch", "null");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user