101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
import { caseStudies, getRelatedServices, servicePages } from "./site-content";
|
|
|
|
const detailedIds = ["as-servicos", "nutriscan", "twins-lab"] as const;
|
|
const immutableGitHubBlobUrl =
|
|
/^https:\/\/github\.com\/[^/]+\/[^/]+\/blob\/[0-9a-f]{40}\/.+$/;
|
|
|
|
function getDetail(id: (typeof detailedIds)[number]) {
|
|
const detail = caseStudies.find((item) => item.id === id)?.detail;
|
|
expect(detail).toBeDefined();
|
|
if (!detail) throw new Error(`Missing detail for ${id}`);
|
|
return detail;
|
|
}
|
|
|
|
it("limits detailed content to the three evidenced cases", () => {
|
|
expect(
|
|
caseStudies
|
|
.filter(({ detail }) => detail !== undefined)
|
|
.map(({ id }) => id)
|
|
.sort(),
|
|
).toEqual([...detailedIds].sort());
|
|
});
|
|
|
|
it("uses unique source IDs and immutable GitHub commit URLs", () => {
|
|
for (const id of detailedIds) {
|
|
const { sources } = getDetail(id);
|
|
const sourceIds = sources.map(({ id }) => id);
|
|
expect(new Set(sourceIds).size).toBe(sourceIds.length);
|
|
|
|
for (const { url } of sources) {
|
|
expect(url).toMatch(immutableGitHubBlobUrl);
|
|
}
|
|
}
|
|
});
|
|
|
|
it("requires sources for factual statements and resolves every source ID", () => {
|
|
for (const id of detailedIds) {
|
|
const detail = getDetail(id);
|
|
const sourceIds = new Set(detail.sources.map(({ id }) => id));
|
|
const factualStatements = [
|
|
detail.answer,
|
|
detail.challenge,
|
|
...detail.implementation,
|
|
];
|
|
|
|
for (const statement of [...factualStatements, ...detail.boundaries]) {
|
|
expect(
|
|
statement.sourceIds.every((sourceId) => sourceIds.has(sourceId)),
|
|
).toBe(true);
|
|
}
|
|
for (const statement of factualStatements) {
|
|
expect(statement.sourceIds.length).toBeGreaterThan(0);
|
|
}
|
|
}
|
|
|
|
expect(
|
|
getDetail("as-servicos").boundaries.map(({ sourceIds }) => sourceIds),
|
|
).toEqual([[]]);
|
|
|
|
for (const id of ["nutriscan", "twins-lab"] as const) {
|
|
expect(
|
|
getDetail(id).boundaries.every(({ sourceIds }) => sourceIds.length > 0),
|
|
).toBe(true);
|
|
}
|
|
expect(getDetail("nutriscan").boundaries[0]?.sourceIds).toContain(
|
|
"nutri-readme",
|
|
);
|
|
});
|
|
|
|
it("derives the exact related service set from the existing relationship", () => {
|
|
expect(
|
|
getRelatedServices("twins-lab")
|
|
.map(({ slug }) => slug)
|
|
.sort(),
|
|
).toEqual(
|
|
[
|
|
"consultoria-nextjs",
|
|
"integracao-hardware-software-iot",
|
|
"arquitetura-de-software",
|
|
].sort(),
|
|
);
|
|
});
|
|
|
|
it("gives every service a direct answer and consulting CTA", () => {
|
|
for (const service of servicePages) {
|
|
expect(service.answer.trim().length).toBeGreaterThan(40);
|
|
expect(service.ctaIntent).toBe("consulting");
|
|
expect(service.ctaHref).toBe("/#contact");
|
|
}
|
|
});
|
|
|
|
it("resolves every declared related case ID", () => {
|
|
const caseIds = new Set(caseStudies.map(({ id }) => id));
|
|
const unresolved = servicePages.flatMap(({ slug, relatedCaseIds }) =>
|
|
relatedCaseIds
|
|
.filter((caseId) => !caseIds.has(caseId))
|
|
.map((caseId) => ({ slug, caseId })),
|
|
);
|
|
|
|
expect(unresolved).toEqual([]);
|
|
});
|