Render repository content through theme contracts
This commit is contained in:
@@ -49,7 +49,10 @@ test("reference repository theme renders declared routes and only declared asset
|
||||
const result = new BuildEngine(output).build(input);
|
||||
assert.equal(result.success, true);
|
||||
assert.match(input.siteDefinition.commit, /^[0-9a-f]{40}$/);
|
||||
assert.equal(input.contentItems.length, 3);
|
||||
assert.ok(fs.existsSync(path.join(result.outputDirectory, "index.html")));
|
||||
assert.ok(fs.existsSync(path.join(result.outputDirectory, "articles/index.html")));
|
||||
assert.ok(fs.existsSync(path.join(result.outputDirectory, "articles/repository-rendering/index.html")));
|
||||
assert.ok(fs.existsSync(path.join(result.outputDirectory, "projects/index.html")));
|
||||
assert.ok(fs.existsSync(path.join(result.outputDirectory, "project/website-engine-control-plane/index.html")));
|
||||
assert.ok(fs.existsSync(path.join(result.outputDirectory, "project/website-engine-control-plane/demo.html")));
|
||||
@@ -62,6 +65,9 @@ test("reference repository theme renders declared routes and only declared asset
|
||||
assert.equal(manifest.siteDefinition.commit, input.siteDefinition.commit);
|
||||
assert.equal(manifest.theme.commit, input.theme.snapshot.commit);
|
||||
assert.equal(manifest.artifactBuildId, input.artifactBuildId);
|
||||
assert.match(fs.readFileSync(path.join(result.outputDirectory, "index.html"), "utf8"), /renders this homepage from committed Markdown/);
|
||||
assert.match(fs.readFileSync(path.join(result.outputDirectory, "articles/repository-rendering/index.html"), "utf8"), /Every build resolves one exact Git commit/);
|
||||
assert.match(fs.readFileSync(path.join(result.outputDirectory, "project/website-engine-control-plane/index.html"), "utf8"), /joins its allowlisted declaration/);
|
||||
assert.doesNotMatch(fs.readFileSync(path.join(result.outputDirectory, "index.html"), "utf8"), /fonts\.googleapis|tailwindcss\.com/);
|
||||
} finally { manager.dispose(); }
|
||||
}));
|
||||
@@ -152,6 +158,21 @@ test("project declaration controls the project route and standalone publication"
|
||||
} finally { manager.dispose(); }
|
||||
}));
|
||||
|
||||
|
||||
test("project declarations cannot silently shadow non-project content", () => withRepository((root, output) => {
|
||||
fs.rmSync(path.join(root, "packages/site-definition/projects/control-plane.md"));
|
||||
fs.writeFileSync(path.join(root, "packages/site-definition/projects/.gitkeep"), "");
|
||||
const article = path.join(root, "packages/site-definition/articles/welcome.md");
|
||||
fs.writeFileSync(article, fs.readFileSync(article, "utf8").replace("route: /articles/repository-rendering/", "route: /project/website-engine-control-plane/"));
|
||||
commit(root, "create route collision");
|
||||
const { manager, input } = load(root, "route-collision");
|
||||
try {
|
||||
const result = new BuildEngine(output).build(input);
|
||||
assert.equal(result.success, false);
|
||||
assert.ok(result.validationReport.errors.some((error) => error.code === "E_ROUTE_COLLISION"));
|
||||
} finally { manager.dispose(); }
|
||||
}));
|
||||
|
||||
test("declared standalone files are copied byte-for-byte", () => withRepository((root, output) => {
|
||||
const { manager, input } = load(root, "publication");
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user