import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import { validateFullDocumentEdit } from "./server.mjs"; const original = ` Stagewar

Text

`; const removedMenuItem = original.replace(/
  • /, "
  • "); assert.equal(validateFullDocumentEdit(original, removedMenuItem), ""); assert.match(validateFullDocumentEdit(original, "
    fragment
    "), /full HTML document/i); assert.match( validateFullDocumentEdit(original, original.replace("", '')), /cannot add or modify executable scripts/i ); assert.match( validateFullDocumentEdit(original, original.replace("site.js", "changed.js")), /cannot add or modify executable scripts/i ); assert.match( validateFullDocumentEdit(original, original.replace("

    Text

    ", "

    Text

    ")), /cannot add or modify executable scripts/i ); assert.equal(validateFullDocumentEdit(original, original.replace("Stagewar", "Edited")), ""); const [serverSource, appSource, htmlSource] = await Promise.all([ readFile(new URL("./server.mjs", import.meta.url), "utf8"), readFile(new URL("./public/app.js", import.meta.url), "utf8"), readFile(new URL("./public/index.html", import.meta.url), "utf8") ]); assert.match(serverSource, /scope === "document"/); assert.match(serverSource, /manualFullHtmlEdit: true/); assert.match(serverSource, /acwpb_theme_validate_full_document_edit/); assert.match(serverSource, /_acwpb_recovered_full_html_enabled/); assert.match(serverSource, /Save full HTML/); assert.match(serverSource, /acwpb-full-html-source/); assert.match(appSource, /currentEditScope/); assert.match(htmlSource, /id="codeEditorScope"/); assert.match(htmlSource, /id="fullHtmlConfirmCheckbox"/); console.log("Full HTML editor tests passed: 15/15");