Hero e movimento - cena 3D em tempo real com os blocos da marca (kit feito no Blender, 3d/blocos.py): marca, tela, integrações e dados; segue a rolagem, tem vida em repouso, reage ao cursor e, parada no topo, passa sozinha pelos estados com legenda - três níveis de aparelho (full, lite, static); sem WebGL fica o pôster - título novo: "Sites e sistemas sob medida para o jeito que a sua empresa trabalha." - faixa de clientes com o ramo, linha do primeiro passo, hero alinhado às seções - rótulos digitados, entrada dos blocos, cortina de blocos entre páginas e capa compartilhada entre a lista de cases e o case Ofertas - atendimento no WhatsApp com IA e nota fiscal para a reforma tributária (páginas de serviço, cartões da home, formulário e aviso com data de validade) - página /ia atualizada, com fontes - peças 3D em loop nos cartões e topos de página (3d/pecas.py) Design - hover por papel (bloco nos botões, barra nos links), rótulos sem caixa alta - um destino por rótulo: "Falar sobre meu projeto" leva ao formulário, "Chamar no WhatsApp" abre o WhatsApp - logo montado em blocos, 404 redesenhado, grades sem célula vazia - ícones do PWA e manifesto novos Specs em specs/, contexto de design em DESIGN.md e PRODUCT.md.
148 lines
4.8 KiB
TypeScript
148 lines
4.8 KiB
TypeScript
import { render, screen, within } from "@testing-library/react";
|
|
import { setNavigation } from "@/__mocks__/next/navigation";
|
|
import { caseStudies, type ServiceOffer } from "@/lib/site-content";
|
|
import { ServiceOfferCards } from "./ServiceOfferCards";
|
|
|
|
/**
|
|
* Testes de caminhos-base de ServiceOfferCards / OfferCard (CC 4): id de case que existe | que não existe (ignorado);
|
|
* com cases | sem cases (a lista de links some); com observação | sem observação.
|
|
*/
|
|
|
|
beforeEach(() => {
|
|
setNavigation({ pathname: "/servicos" });
|
|
});
|
|
|
|
function offer(overrides: Partial<ServiceOffer["proof"]>): ServiceOffer {
|
|
return {
|
|
id: "site",
|
|
name: "Oferta de teste",
|
|
whatsappSubject: "uma oferta de teste",
|
|
summary: "Resumo.",
|
|
href: "/servicos/criacao-de-sites",
|
|
deliverables: ["Um", "Dois", "Três"],
|
|
firstStep: "Primeira conversa. Depois, escopo e proposta por escrito.",
|
|
proof: { label: "Veja funcionando", caseIds: [], ...overrides },
|
|
};
|
|
}
|
|
|
|
const card = () => screen.getByRole("article");
|
|
|
|
describe("ServiceOfferCards", () => {
|
|
it("path: cases that exist and a note -> a link per case in the order given, then the note", () => {
|
|
render(
|
|
<ServiceOfferCards
|
|
offers={[
|
|
offer({ caseIds: ["sev-modaintima", "lavacao-047"], note: "Nota." }),
|
|
]}
|
|
/>,
|
|
);
|
|
|
|
const links = within(card()).getAllByRole("link", { name: /^Ver case / });
|
|
expect(links.map((link) => link.getAttribute("href"))).toEqual([
|
|
"/cases/sev-modaintima",
|
|
"/cases/lavacao-047",
|
|
]);
|
|
expect(within(card()).getByText("Nota.")).toBeVisible();
|
|
});
|
|
|
|
it("path: an id with no case behind it -> skipped, the real cases around it stay", () => {
|
|
render(
|
|
<ServiceOfferCards
|
|
offers={[
|
|
offer({ caseIds: ["nao-existe", "lavacao-047", "tambem-nao"] }),
|
|
]}
|
|
/>,
|
|
);
|
|
|
|
const links = within(card()).getAllByRole("link", { name: /^Ver case / });
|
|
expect(links.map((link) => link.getAttribute("href"))).toEqual([
|
|
"/cases/lavacao-047",
|
|
]);
|
|
});
|
|
|
|
it("path: only ids with no case -> no list of cases at all, the label and the service link stay", () => {
|
|
render(<ServiceOfferCards offers={[offer({ caseIds: ["nao-existe"] })]} />);
|
|
|
|
expect(
|
|
within(card()).queryAllByRole("link", { name: /^Ver case / }),
|
|
).toEqual([]);
|
|
expect(within(card()).queryAllByRole("listitem")).toHaveLength(3);
|
|
expect(within(card()).getByText("Veja funcionando")).toBeVisible();
|
|
expect(
|
|
within(card()).getByRole("link", { name: /Ver o serviço|Ver serviço/ }),
|
|
).toHaveAttribute("href", "/servicos/criacao-de-sites");
|
|
});
|
|
|
|
it("path: no cases and a note (the review offer) -> only the note under the label", () => {
|
|
render(
|
|
<ServiceOfferCards
|
|
offers={[
|
|
offer({
|
|
caseIds: [],
|
|
label: "Veja como funciona",
|
|
note: "A página mostra o que você recebe.",
|
|
}),
|
|
]}
|
|
/>,
|
|
);
|
|
|
|
expect(within(card()).getByText("Veja como funciona")).toBeVisible();
|
|
expect(
|
|
within(card()).getByText("A página mostra o que você recebe."),
|
|
).toBeVisible();
|
|
expect(
|
|
within(card()).queryAllByRole("link", { name: /^Ver case / }),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("path: cases and no note -> no empty paragraph for the note", () => {
|
|
const { container } = render(
|
|
<ServiceOfferCards offers={[offer({ caseIds: ["lavacao-047"] })]} />,
|
|
);
|
|
|
|
expect(container.querySelectorAll("article p")).toHaveLength(2);
|
|
});
|
|
|
|
it("path: every real case id of the real offers resolves to a case (no silently dropped proof)", () => {
|
|
const { serviceOffers } =
|
|
jest.requireActual<typeof import("@/lib/site-content")>(
|
|
"@/lib/site-content",
|
|
);
|
|
const known = new Set(caseStudies.map(({ id }) => id));
|
|
|
|
for (const { proof } of serviceOffers)
|
|
for (const id of proof.caseIds) expect(known.has(id)).toBe(true);
|
|
});
|
|
|
|
it.each([
|
|
// cinco ofertas (as de hoje): 3 + 2, os dois da última linha dividem a linha
|
|
[5, ["2", "2", "2", "3", "3"]],
|
|
// quatro: 3 + 1, o que sobra ocupa a linha inteira
|
|
[4, ["2", "2", "2", "6"]],
|
|
// três: uma linha cheia
|
|
[3, ["2", "2", "2"]],
|
|
])(
|
|
"path: %i offers -> no empty cell on the last row of the 6-column grid",
|
|
(count, spans) => {
|
|
const ids: ServiceOffer["id"][] = [
|
|
"site",
|
|
"sistema",
|
|
"whatsapp",
|
|
"revisao",
|
|
"fiscal",
|
|
];
|
|
const offers = ids
|
|
.slice(0, count)
|
|
.map((id): ServiceOffer => ({ ...offer({}), id }));
|
|
const { container } = render(<ServiceOfferCards offers={offers} />);
|
|
|
|
expect(container.firstElementChild).toHaveClass("lg:grid-cols-6");
|
|
expect(
|
|
Array.from(container.querySelectorAll("article")).map(
|
|
(card) => card.className.match(/lg:col-span-(\d)/)?.[1],
|
|
),
|
|
).toEqual(spans);
|
|
},
|
|
);
|
|
});
|