Files
evandro c7d09d63d4
CI / audit (push) Successful in 10m38s
CI / verify (push) Successful in 13m10s
CI / deploy (push) Successful in 1m50s
CI / e2e (push) Successful in 18m48s
feat(site): blocos 3D da marca, novas ofertas e hero mais abrangente
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.
2026-11-10 03:48:25 -03:00

186 lines
5.7 KiB
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import ts from "typescript";
import {
isCoarsePointer,
isMobileViewport,
isSaveData,
prefersReducedMotion,
sceneTier,
} from "./device";
/**
* Testes de caminhos-base de lib/device.ts (complemento de device.test.ts): matches() sem matchMedia,
* cada condição de sceneTier isolada (inclusive os limites), isSaveData e o ambiente sem window/navigator
* (servidor). O servidor é simulado transpilando o fonte e executando-o com `window` e `navigator` indefinidos,
* porque o jsdom não deixa esconder esses globais.
*/
type DeviceModule = typeof import("./device");
const originalMatchMedia = window.matchMedia;
function mockMedia(active: string[]) {
window.matchMedia = jest.fn().mockImplementation((query: string) => ({
matches: active.includes(query),
media: query,
addEventListener() {},
removeEventListener() {},
}));
}
function mockNavigator(values: Record<string, unknown>) {
for (const [key, value] of Object.entries(values))
Object.defineProperty(navigator, key, { configurable: true, value });
}
function loadOnServer(globals: { window?: unknown; navigator?: unknown }) {
const source = readFileSync(join(process.cwd(), "lib/device.ts"), "utf8");
const { outputText } = ts.transpileModule(source, {
compilerOptions: { module: ts.ModuleKind.CommonJS },
});
const loaded = { exports: {} as DeviceModule };
new Function("module", "exports", "window", "navigator", outputText)(
loaded,
loaded.exports,
globals.window,
globals.navigator,
);
return loaded.exports;
}
beforeEach(() => {
mockMedia([]);
mockNavigator({
hardwareConcurrency: 8,
deviceMemory: undefined,
connection: undefined,
});
});
afterEach(() => {
window.matchMedia = originalMatchMedia;
});
describe("matches() (through the media helpers)", () => {
it("path: matchMedia is not available -> every media hint is false", () => {
// @ts-expect-error simula um navegador sem matchMedia
window.matchMedia = undefined;
expect(isCoarsePointer()).toBe(false);
expect(prefersReducedMotion()).toBe(false);
expect(isMobileViewport()).toBe(false);
expect(sceneTier()).toBe("full");
});
it("path: matchMedia answers false for the query -> false", () => {
expect(isCoarsePointer()).toBe(false);
});
it("path: matchMedia answers true only for the asked query -> only that hint is true", () => {
mockMedia(["(prefers-reduced-motion: reduce)"]);
expect(prefersReducedMotion()).toBe(true);
expect(isCoarsePointer()).toBe(false);
expect(isMobileViewport()).toBe(false);
});
});
describe("isSaveData()", () => {
it.each([
["connection is missing", undefined],
["connection has no saveData", {}],
["saveData is false", { saveData: false }],
["saveData is a truthy non-boolean", { saveData: "true" }],
])("path: %s -> false", (_label, connection) => {
mockNavigator({ connection });
expect(isSaveData()).toBe(false);
});
it("path: saveData is exactly true -> true", () => {
mockNavigator({ connection: { saveData: true } });
expect(isSaveData()).toBe(true);
});
});
describe("sceneTier(): limites de cada condição, uma de cada vez", () => {
it.each([
["5 cores", { hardwareConcurrency: 5 }],
["8 GB of memory", { hardwareConcurrency: 8, deviceMemory: 8 }],
["5 GB of memory", { hardwareConcurrency: 8, deviceMemory: 5 }],
["cores reported as text", { hardwareConcurrency: "2" }],
["memory reported as text", { deviceMemory: "2" }],
["cores reported as null", { hardwareConcurrency: null }],
])(
"path: %s -> full power (just above the limit or not a number)",
(_label, hints) => {
mockNavigator(hints);
expect(sceneTier()).toBe("full");
},
);
it.each([
["exactly 4 cores", { hardwareConcurrency: 4 }],
["exactly 4 GB", { deviceMemory: 4 }],
["0.5 GB", { deviceMemory: 0.5 }],
["1 core", { hardwareConcurrency: 1 }],
])("path: %s -> static", (_label, hints) => {
mockNavigator(hints);
expect(sceneTier()).toBe("static");
});
it("path: touch on a capable phone -> lite, never full", () => {
mockMedia(["(pointer: coarse)"]);
mockNavigator({ hardwareConcurrency: 16, deviceMemory: 16 });
expect(sceneTier()).toBe("lite");
});
it("path: several conditions true at once -> still just static", () => {
mockMedia(["(pointer: coarse)", "(prefers-reduced-motion: reduce)"]);
mockNavigator({
hardwareConcurrency: 2,
deviceMemory: 2,
connection: { saveData: true },
});
expect(sceneTier()).toBe("static");
});
});
describe("without window and navigator (server)", () => {
it("path: no window -> media hints are false", () => {
const device = loadOnServer({ window: undefined, navigator: undefined });
expect(device.isCoarsePointer()).toBe(false);
expect(device.prefersReducedMotion()).toBe(false);
expect(device.isMobileViewport()).toBe(false);
});
it("path: no navigator -> save data is off and the scene is static", () => {
const device = loadOnServer({ window: undefined, navigator: undefined });
expect(device.isSaveData()).toBe(false);
expect(device.sceneTier()).toBe("static");
});
it("path: a navigator without window (runtime that exposes only navigator) -> hints still read", () => {
const device = loadOnServer({
window: undefined,
navigator: { hardwareConcurrency: 16, connection: { saveData: true } },
});
expect(device.isSaveData()).toBe(true);
expect(device.sceneTier()).toBe("static");
const capable = loadOnServer({
window: undefined,
navigator: { hardwareConcurrency: 16 },
});
expect(capable.sceneTier()).toBe("full");
});
});