+12








fcd7c979df
Co-authored-by: Artur <145776561+arturict@users.noreply.github.com> Co-authored-by: arturict <arturict@users.noreply.github.com> Co-authored-by: Thomas <thomas@ajnart.fr> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com> Co-authored-by: Danura30082 <danura30082+github@gmail.com> Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com> Co-authored-by: ajnart <thomas@ajnart.fr> Co-authored-by: ajnart <thomas@ajnart.dev> Co-authored-by: chenjun <chenjun@foxmail.com> Co-authored-by: Wikibear <wikibear@users.noreply.github.com> Co-authored-by: Bergasha <bergasha@gmail.com> Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com> Co-authored-by: Lucas Araujo <lucas.lra@gmail.com> Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com> Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social> Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com> Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com> Co-authored-by: thrawnx <tight.bulb9384@fastmail.com> Co-authored-by: Chris <58918656+nordada@users.noreply.github.com> Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com> Co-authored-by: Yanis <naamaneyanis@gmail.com> Co-authored-by: Wikibear <me@sej.de> Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
60 lines
3.0 KiB
JavaScript
60 lines
3.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
|
|
const baseUrl = process.env.WORKSHOP_TEST_URL;
|
|
if (!baseUrl) throw new Error("WORKSHOP_TEST_URL is required");
|
|
|
|
const indexResponse = await fetch(`${baseUrl}/api/search?q=board`);
|
|
assert.equal(indexResponse.status, 200, "PocketBase must serve the static search index under /api/search");
|
|
assert.equal((await indexResponse.json()).type, "advanced");
|
|
|
|
const compressedIndex = await fetch(`${baseUrl}/api/search`, { headers: { "Accept-Encoding": "gzip" } });
|
|
assert.equal(compressedIndex.headers.get("content-encoding"), "gzip", "large static indexes must be compressed");
|
|
assert.match(compressedIndex.headers.get("vary"), /Accept-Encoding/i);
|
|
const plainIndex = await fetch(`${baseUrl}/api/search`, { headers: { "Accept-Encoding": "identity" } });
|
|
assert.equal(plainIndex.headers.get("content-encoding"), null);
|
|
const indexText = await plainIndex.text();
|
|
assert.equal(await compressedIndex.text(), indexText, "compression must preserve the exported index");
|
|
const declinedIndex = await fetch(`${baseUrl}/api/search`, { headers: { "Accept-Encoding": "br, gzip; q=0" } });
|
|
assert.equal(declinedIndex.headers.get("content-encoding"), null, "an explicitly refused encoding must not be used");
|
|
assert.equal(await declinedIndex.text(), indexText);
|
|
|
|
for (const path of ["/llms.txt", "/llms-full.txt", "/llms.mdx/docs/content.md"]) {
|
|
const response = await fetch(`${baseUrl}${path}`);
|
|
assert.equal(response.status, 200, path);
|
|
assert.match(await response.text(), /^# /, `${path} must serve Markdown rather than the homepage`);
|
|
}
|
|
|
|
const missing = await fetch(`${baseUrl}/docs/this-page-does-not-exist`);
|
|
assert.equal(missing.status, 404);
|
|
const missingHtml = await missing.text();
|
|
// The shared static 404 shell waits for hydration to distinguish missing pages
|
|
// from dynamic Workshop detail routes without flashing a false not-found state.
|
|
assert.match(missingHtml, /aria-label="Loading submission"/);
|
|
assert.match(missingHtml, /name="robots" content="noindex"/);
|
|
|
|
const missingApi = await fetch(`${baseUrl}/api/this-endpoint-does-not-exist`);
|
|
assert.equal(missingApi.status, 404);
|
|
assert.match(missingApi.headers.get("content-type"), /application\/json/);
|
|
await missingApi.arrayBuffer();
|
|
|
|
const admin = await fetch(`${baseUrl}/workshop/admin/`);
|
|
assert.equal(admin.status, 200);
|
|
assert.match(await admin.text(), /Workshop moderation/);
|
|
|
|
const missingItem = await fetch(`${baseUrl}/workshop/nonexistentitem`);
|
|
assert.equal(missingItem.status, 404);
|
|
assert.match(await missingItem.text(), /name="robots" content="noindex"/);
|
|
|
|
for (const method of ["GET", "HEAD"]) {
|
|
const headers = { "Accept-Encoding": "gzip" };
|
|
const redirect = await fetch(`${baseUrl}/docs?example=1`, { method, headers, redirect: "manual" });
|
|
assert.equal(redirect.status, 301);
|
|
assert.equal(redirect.headers.get("location"), "/docs/?example=1");
|
|
await redirect.arrayBuffer();
|
|
const page = await fetch(`${baseUrl}/docs/`, { method, headers });
|
|
assert.equal(page.status, 200);
|
|
await page.arrayBuffer();
|
|
}
|
|
|
|
console.log("PocketBase static export routes passed");
|