mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-11-09 15:33:31 +00:00
25 lines
1.5 KiB
JavaScript
25 lines
1.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile, readdir, access } from "node:fs/promises";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const blog = resolve(root, "dist/blog");
|
|
const contents = await readdir(blog, {withFileTypes:true});
|
|
assert.equal(contents.filter((entry) => entry.isDirectory()).length, 0, "Generated article routes must be removed");
|
|
const html = await readFile(resolve(blog, "index.html"), "utf8");
|
|
assert.match(html, /id="root" data-prerendered/);
|
|
assert.match(html, /<h1>Blog<\/h1>/);
|
|
assert.match(html, /No posts yet\./);
|
|
assert.doesNotMatch(html, /class="blog-card"|class="blog-filters"|BlogPosting|\/tutorials|assets\/blog\//);
|
|
assert.match(html, /<a href="\/blog">Blog<\/a>/);
|
|
assert.match(html, /recordly-mark\.svg/);
|
|
assert.equal((html.match(/<link rel="canonical"/g)||[]).length, 1);
|
|
assert.match(html, /<link rel="canonical" href="[^"]+\/blog"/);
|
|
const schema = JSON.parse(html.match(/<script type="application\/ld\+json" data-blog-schema>(.*?)<\/script>/s)[1]);
|
|
assert.equal(schema["@type"], "CollectionPage");
|
|
assert.deepEqual(schema.mainEntity.itemListElement, []);
|
|
const sitemap = await readFile(resolve(root,"dist/sitemap.xml"), "utf8");
|
|
assert.doesNotMatch(sitemap, /\/tutorials|\/blog\//);
|
|
await assert.rejects(access(resolve(root, "dist/tutorials")));
|
|
console.log("Passed: empty Blog, direct navigation, blue logo, clean metadata, and no generated article or tutorial routes.");
|