#!/usr/bin/env node "use strict"; /** * Laadt de plugin zoals LNReader dat doet: custom require-allowlist, * `new Function`, en daarna popularNovels / searchNovels / parseNovel / * parseChapter. De index komt van een lokale HTTP-server (testdata of * public/). parseChapter, searchNovels, popularNovels en parseNovel * gebruiken gemockte Reddit-JSON, vallen terug op Arctic Shift en daarna * op de statische index; optioneel een live verzoek als HFY_LIVE=1. */ const fs = require("fs"); const http = require("http"); const path = require("path"); const zlib = require("zlib"); const ROOT = path.resolve(__dirname, ".."); const PLUGIN = fs.readFileSync(path.join(ROOT, "plugin", "hfy-novels.js"), "utf8"); const LIVE_COVER_REDDIT = "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/covers/reddit.png?rev=master"; const LIVE_COVER_ARCTIC = "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/covers/arctic-shift.png?rev=master"; const NovelStatus = { Completed: "Completed", Ongoing: "Ongoing", OnHiatus: "On Hiatus", Unknown: "Unknown", }; const FilterTypes = { Picker: "Picker", Switch: "Switch", CheckboxGroup: "CheckboxGroup" }; function mimeFor(file, asImg) { if (file.endsWith(".svg")) return asImg ? "image/svg+xml" : "text/plain; charset=utf-8"; if (file.endsWith(".json")) return "text/plain; charset=utf-8"; // BlueGit serveert raw ook als text/plain if (file.endsWith(".js")) return "text/plain; charset=utf-8"; if (file.endsWith(".png")) return "image/png"; return "application/octet-stream"; } function startServer(rootDir, chapterHandler, redditHandler) { return new Promise((resolve, reject) => { const server = http.createServer((req, res) => { const url = new URL(req.url, "http://127.0.0.1"); if (url.pathname.startsWith("/api/posts/ids") || url.pathname.startsWith("/api/posts/search") || url.pathname.startsWith("/api/subreddits/wikis")) { return chapterHandler(url, res); } if (redditHandler && /\/r\/HFY\//i.test(url.pathname)) { return redditHandler(url, res, req); } if (redditHandler && url.pathname.startsWith("/api/info")) { return redditHandler(url, res, req); } // ?rev=master zoals BlueGit raw-URLs; voor het bestand negeren we de query. let rel = decodeURIComponent(url.pathname).replace(/^\/+/, ""); const file = path.join(rootDir, rel); if (!file.startsWith(path.resolve(rootDir))) { res.writeHead(403); res.end("forbidden"); return; } fs.readFile(file, (err, data) => { if (err) { res.writeHead(404, { "Content-Type": "text/plain" }); res.end("404 " + rel); return; } const asImg = url.searchParams.get("as") === "img"; res.writeHead(200, { "Content-Type": mimeFor(file, asImg) }); res.end(data); }); }); server.listen(0, "127.0.0.1", () => { const { port } = server.address(); resolve({ server, port, url: "http://127.0.0.1:" + port }); }); server.on("error", reject); }); } function redditListingFor(id) { return [ { kind: "Listing", data: { children: [ { kind: "t3", data: { id, title: "The Last Terran - Part 1", author: "WriterOne", selftext: "It begins.\n\n[Next](https://www.reddit.com/r/HFY/comments/aaa222/x/)", selftext_html: "

It begins.

", permalink: "/r/HFY/comments/" + id + "/", }, }, ], }, }, { kind: "Listing", data: { children: [] } }, ]; } function loginHtml() { return "reddit.com: Log inLog in to Reddit to continue. log in"; } function blockHtml() { return "
Request blocked. reason=lor2
"; } function defaultRedditHandler(mode) { return function redditHandler(url, res) { const m = url.pathname.match(/\/comments\/([0-9a-z]{4,10})\//i); if (!m) { res.writeHead(404, { "Content-Type": "text/plain" }); res.end("no default reddit mock for " + url.pathname); return; } const id = m[1].toLowerCase(); if (mode === "ok") { res.writeHead(200, { "Content-Type": "application/json; charset=utf-8" }); res.end(JSON.stringify(redditListingFor(id))); return; } if (mode === "403") { res.writeHead(403, { "Content-Type": "text/html; charset=utf-8" }); res.end(blockHtml()); return; } if (mode === "login-html") { res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); res.end(loginHtml()); return; } res.writeHead(500, { "Content-Type": "text/plain" }); res.end("reddit mock error"); }; } function defaultChapterHandler(url, res) { if (!url.pathname.startsWith("/api/posts/ids")) { res.writeHead(404, { "Content-Type": "text/plain" }); res.end("no default arctic mock for " + url.pathname); return; } const ids = url.searchParams.get("ids") || ""; const id = ids.split(",")[0]; const fixture = { data: [ { id, title: "The Last Terran - Part 1", author: "WriterOne", selftext: "It begins.\n\n[Next](https://www.reddit.com/r/HFY/comments/aaa222/x/)", selftext_html: "

It begins.

", permalink: "/r/HFY/comments/" + id + "/", }, ], }; res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify(fixture)); } function wrapResponse(res) { return { ok: res.ok, status: res.status, headers: res.headers, async text() { return await res.text(); }, async json() { const text = await res.text(); return JSON.parse(text); }, url: res.url, }; } function makeFetchApi(origin) { return async function fetchApi(url, init) { let target = String(url); // Stuur Reddit-JSON naar de lokale testhost, zodat we 200/403/login kunnen simuleren. if (/^https?:\/\/(www\.|old\.)?reddit\.com\//i.test(target)) { const parsed = new URL(target); target = origin + parsed.pathname + parsed.search; } const res = await fetch(target, init); return wrapResponse(res); }; } function loadPlugin(storageMap, fetchApi) { const allow = { "@libs/fetch": { fetchApi, fetchText: async (u, i) => (await fetchApi(u, i)).text() }, "@libs/filterInputs": { FilterTypes }, "@libs/defaultCover": { defaultCover: "https://example.invalid/cover.png" }, "@libs/novelStatus": { NovelStatus }, "@libs/storage": { storage: { get(key) { return storageMap[key]; }, set(key, value, expires) { storageMap[key] = value; if (expires != null) { storageMap[key + "__expires"] = expires; } }, }, }, }; const pluginModule = { exports: {} }; const fn = new Function("exports", "require", "module", PLUGIN); fn(pluginModule.exports, (name) => { if (!allow[name]) { throw new Error("blocked require: " + name); } return allow[name]; }, pluginModule); const plugin = pluginModule.exports.default; if (!plugin) { throw new Error("geen default export"); } for (const method of ["popularNovels", "searchNovels", "parseNovel", "parseChapter"]) { if (typeof plugin[method] !== "function") { throw new Error("plugin mist " + method); } } return plugin; } function assert(cond, msg) { if (!cond) { throw new Error("FAIL: " + msg); } } function wikiIndexPayload(markdown) { return { kind: "wikipage", data: { content_md: markdown, revision_date: 1700000000 } }; } function listingOf(posts) { return { kind: "Listing", data: { children: posts.map((p) => ({ kind: "t3", data: p })), after: null, }, }; } function samplePost(id, title, author, extras) { const extra = extras || {}; return Object.assign( { id, title, author, created_utc: extra.created_utc || 1700000000, permalink: "/r/HFY/comments/" + id + "/", selftext: extra.selftext || "", selftext_html: extra.selftext_html || "", link_flair_text: extra.flair || "OC-Series", over_18: !!extra.over_18, is_self: true, }, extra.more || {}, ); } async function testLiveCatalog(origin, fixtureRoot, fetchApi, assert) { const wikiIndex = fs.readFileSync(path.join(ROOT, "testdata", "wiki", "index.md"), "utf8"); const wikiTerran = fs.readFileSync(path.join(ROOT, "testdata", "wiki", "pages", "the_last_terran.md"), "utf8"); const state = { redditMode: "ok", arcticMode: "ok", wikiHits: 0, searchHits: 0, arcticSearchHits: 0, arcticWikiHits: 0, infoHits: 0 }; function redditHandler(url, res) { if (state.redditMode === "403") { res.writeHead(403, { "Content-Type": "text/html; charset=utf-8" }); res.end(blockHtml()); return; } if (state.redditMode === "error") { res.writeHead(500, { "Content-Type": "text/plain" }); res.end("reddit mock error"); return; } if (/\/wiki\/series\/the_last_terran/i.test(url.pathname)) { state.wikiHits += 1; res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify(wikiIndexPayload(wikiTerran))); return; } if (/\/wiki\/series/i.test(url.pathname)) { state.wikiHits += 1; res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify(wikiIndexPayload(wikiIndex))); return; } if (/\/search\.json$/i.test(url.pathname)) { state.searchHits += 1; const q = (url.searchParams.get("q") || "").toLowerCase(); const posts = []; if (q.indexOf("terran") !== -1 || q.indexOf("writerone") !== -1) { posts.push( samplePost("aaa111", "[OC] The Last Terran - Part 1", "WriterOne", { flair: "OC-FirstOfSeries", selftext: "[Next](https://www.reddit.com/r/HFY/comments/aaa222/x/)", }), ); } if (q.indexOf("star") !== -1 || q.indexOf("boat") !== -1) { posts.push( samplePost("ddd001", "[OC] Star Boat - Part 1", "Skipper", { flair: "OC-FirstOfSeries", selftext: "[Next](https://www.reddit.com/r/HFY/comments/ddd002/x/)", created_utc: 1700345600, }), ); posts.push( samplePost("ddd002", "Star Boat - Part 2", "Skipper", { flair: "OC-Series", selftext: "[Prev](https://www.reddit.com/r/HFY/comments/ddd001/x/)", created_utc: 1700432000, }), ); } res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify(listingOf(posts))); return; } if (/\/new\.json$/i.test(url.pathname)) { state.searchHits += 1; res.writeHead(200, { "Content-Type": "application/json" }); res.end( JSON.stringify( listingOf([ samplePost("ddd001", "[OC] Star Boat - Part 1", "Skipper", { flair: "OC-FirstOfSeries", created_utc: 1700345600, }), samplePost("meta999", "[META] Weekly thread", "ModAccount", { flair: "Meta", created_utc: 1700345700 }), samplePost("aaa444", "The Last Terran - Part 4", "WriterOne", { flair: "OC-Series", created_utc: 1700259200, }), ]), ), ); return; } if (url.pathname.startsWith("/api/info") || /\/comments\/[0-9a-z]+\//i.test(url.pathname)) { state.infoHits += 1; const ids = []; if (url.searchParams.get("id")) { url.searchParams.get("id").split(",").forEach((raw) => ids.push(raw.replace(/^t3_/, "").toLowerCase())); } else { const m = url.pathname.match(/\/comments\/([0-9a-z]{4,10})\//i); if (m) ids.push(m[1].toLowerCase()); } const posts = ids.map((id) => { if (id === "aaa222") { return samplePost(id, "The Last Terran - Part 2", "WriterOne", { selftext: "[Prev](https://www.reddit.com/r/HFY/comments/aaa111/x/) | [Next](https://www.reddit.com/r/HFY/comments/aaa333/x/)", }); } if (id === "aaa333") { return samplePost(id, "The Last Terran Chapter 3", "WriterOne", { selftext: "[Previous](/r/HFY/comments/aaa222/)", }); } return samplePost(id, "The Last Terran - Part 1", "WriterOne", { flair: "OC-FirstOfSeries", selftext: "[Next](https://www.reddit.com/r/HFY/comments/aaa222/x/)", }); }); res.writeHead(200, { "Content-Type": "application/json" }); if (/\/comments\//i.test(url.pathname)) { res.end(JSON.stringify(redditListingFor(ids[0] || "aaa111"))); } else { res.end(JSON.stringify(listingOf(posts))); } return; } res.writeHead(404, { "Content-Type": "text/plain" }); res.end("no reddit mock for " + url.pathname); } function arcticHandler(url, res) { if (url.pathname.startsWith("/api/subreddits/wikis")) { state.arcticWikiHits += 1; if (state.arcticMode === "fail") { res.writeHead(500, { "Content-Type": "text/plain" }); res.end("arctic wiki fail"); return; } const paths = url.searchParams.get("paths") || ""; const content = /the_last_terran/.test(paths) ? wikiTerran : wikiIndex; res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({ data: [{ path: paths, content }] })); return; } if (url.pathname.startsWith("/api/posts/search")) { state.arcticSearchHits += 1; if (state.arcticMode === "fail") { res.writeHead(500, { "Content-Type": "text/plain" }); res.end("arctic search fail"); return; } const q = ((url.searchParams.get("query") || "") + " " + (url.searchParams.get("title") || "")).toLowerCase(); const posts = []; if (!q.trim() || q.indexOf("star") !== -1 || q.indexOf("boat") !== -1) { posts.push( samplePost("ddd001", "[OC] Star Boat - Part 1", "Skipper", { flair: "OC-FirstOfSeries", created_utc: 1700345600, }), ); } res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({ data: posts })); return; } if (url.pathname.startsWith("/api/posts/ids")) { return defaultChapterHandler(url, res); } res.writeHead(404); res.end("no arctic mock"); } const started = await startServer(fixtureRoot, arcticHandler, redditHandler); const liveFetch = makeFetchApi(started.url); try { const storageMap = { indexBaseUrl: origin, indexRev: "", chapterSourceUrl: started.url, chapterSource: "auto", }; const plugin = loadPlugin(storageMap, liveFetch); state.wikiHits = 0; const popular = await plugin.popularNovels(1, { showLatestNovels: false, filters: {} }); assert(popular.some((n) => n.name === "The Last Terran"), "live wiki-index levert The Last Terran"); assert(popular.some((n) => n.path.indexOf("the_last_terran") !== -1 || n.path === "wiki/the_last_terran"), "wiki-pad zonder first-id"); const hitsAfterFirst = state.wikiHits; assert(hitsAfterFirst >= 1, "wiki-index is bij Reddit opgehaald"); const popularAgain = await plugin.popularNovels(1, { filters: {} }); assert(popularAgain.some((n) => n.name === "The Last Terran"), "cache levert opnieuw de wiki-index"); assert(state.wikiHits === hitsAfterFirst, "tweede popularNovels gebruikt de wiki-cache"); const liveCover = popular.find((n) => n.name === "The Last Terran").cover; assertLiveCover(liveCover, "reddit", "live wiki-cover"); assert( popularAgain.find((n) => n.name === "The Last Terran").cover === liveCover, "gecachte wiki-index houdt de Reddit-cover", ); const latest = await plugin.popularNovels(1, { showLatestNovels: true, filters: {} }); assert(latest.some((n) => /Star Boat/i.test(n.name)), "Latest/Nieuw toont recente OC-reeks"); assertLiveCover(latest.find((n) => /Star Boat/i.test(n.name)).cover, "reddit", "Latest-cover"); assert(latest.every((n) => !/Weekly thread/i.test(n.name)), "Meta-posts blijven buiten Nieuw"); const viaFilter = await plugin.popularNovels(1, { filters: { catalog: { value: "new" } } }); assert(viaFilter.some((n) => /Star Boat/i.test(n.name)), "filter Nieuw toont recente OC-posts"); const search = await plugin.searchNovels("terran", 1); assert(search.some((n) => /Last Terran/i.test(n.name)), "searchNovels groepeert wiki + Part 1"); const star = await plugin.searchNovels("Star Boat", 1); assert(star.length === 1 && /Star Boat/i.test(star[0].name), "losse Part 1+2 worden één novel"); assert(star[0].path === "series/ddd001", "nieuwe reeks gebruikt het eerste deel als id"); assertLiveCover(star[0].cover, "reddit", "live zoek-cover zonder index-PNG"); const novel = await plugin.parseNovel("wiki/the_last_terran"); assert(novel.name === "The Last Terran", "parseNovel gebruikt de wiki-titel"); assert(novel.author === "WriterOne", "parseNovel leest de auteur uit de wiki"); assert(novel.chapters.length === 3, "parseNovel volgt de wiki-TOC"); assert(novel.chapters[0].path === "chapter/aaa111", "eerste hoofdstukpad"); assert(novel.chapters[2].path === "chapter/aaa333", "laatste TOC-hoofdstuk"); assertLiveCover(novel.cover, "reddit", "parseNovel live-cover (wiki, geen statische PNG)"); const indexed = await plugin.parseNovel("series/aaa111"); assert(indexed.cover && indexed.cover.indexOf("/covers/") !== -1, "parseNovel van een indexreeks houdt de statische cover"); assert(indexed.cover.indexOf("data:") === -1, "indexcover is geen data-URI"); delete storageMap.wikiSeriesIndex; state.redditMode = "403"; state.arcticMode = "ok"; state.arcticWikiHits = 0; const plugin403 = loadPlugin(storageMap, liveFetch); const popular403 = await plugin403.popularNovels(1, { filters: {} }); assert(popular403.some((n) => n.name === "The Last Terran"), "403 valt terug op Arctic Shift-wiki"); assert(state.arcticWikiHits >= 1, "403 roept Arctic Shift-wiki aan"); assertLiveCover( popular403.find((n) => n.name === "The Last Terran").cover, "arctic", "403-wiki-cover", ); const search403 = await plugin403.searchNovels("Star Boat", 1); assert(search403.some((n) => /Star Boat/i.test(n.name)), "zoeken valt bij 403 terug op Arctic Shift"); assertLiveCover(search403.find((n) => /Star Boat/i.test(n.name)).cover, "arctic", "403-zoek-cover"); const novel403 = await plugin403.parseNovel("wiki/the_last_terran"); assertLiveCover(novel403.cover, "arctic", "parseNovel 403-cover"); delete storageMap.wikiSeriesIndex; state.redditMode = "403"; state.arcticMode = "fail"; const pluginStatic = loadPlugin(storageMap, liveFetch); const popularStatic = await pluginStatic.popularNovels(1, { filters: {} }); assert(popularStatic.some((n) => n.path === "series/aaa111"), "na Reddit+Arctic Shift volgt de statische index"); const staticItem = popularStatic.find((n) => n.path === "series/aaa111"); assert(staticItem.cover && staticItem.cover.indexOf("/covers/") !== -1, "statische catalogus houdt eigen covers"); const searchStatic = await pluginStatic.searchNovels("terran", 1); assert(searchStatic.length === 1 && searchStatic[0].path === "series/aaa111", "zoeken valt terug op de statische index"); console.log("✔️ live catalogus: wiki, Nieuw, zoeken, parseNovel, 403→Arctic Shift→index"); } finally { started.server.close(); } } function assertLiveCover(uri, source, label) { const expected = source === "arctic" ? LIVE_COVER_ARCTIC : LIVE_COVER_REDDIT; assert(typeof uri === "string" && uri === expected, label + " is de vaste " + source + "-cover-URL"); assert(/^https:\/\//.test(uri), label + " is een https-URL"); assert(uri.indexOf("data:") === -1, label + " is geen data-URI"); } function assertPngFile(file, label) { const buf = fs.readFileSync(file); assert(buf[0] === 0x89 && buf.toString("ascii", 1, 4) === "PNG", label + " heeft PNG-signatuur"); assert(buf[4] === 0x0d && buf[5] === 0x0a && buf[6] === 0x1a && buf[7] === 0x0a, label + " heeft geldige PNG-header"); const width = buf.readUInt32BE(16); const height = buf.readUInt32BE(20); assert(width === 240 && height === 360, label + " is 240x360"); assert(buf.length < 20 * 1024, label + " is een klein bestand"); } function testLiveCoverFiles() { for (const name of ["reddit.png", "arctic-shift.png"]) { const src = path.join(ROOT, "plugin", "covers", name); const dist = path.join(ROOT, ".dist", "covers", name); assert(fs.existsSync(src), name + " staat in plugin/covers"); assert(fs.existsSync(dist), name + " staat in .dist/covers"); assertPngFile(src, "bron " + name); assertPngFile(dist, "dist " + name); assert(Buffer.compare(fs.readFileSync(src), fs.readFileSync(dist)) === 0, name + " is gelijk gekopieerd"); } console.log("✔️ vaste broncovers: reddit.png en arctic-shift.png (240x360, klein PNG)"); } async function main() { const fixtureRoot = path.join(ROOT, "testdata", "index-fixture"); const redditState = { mode: "ok", redditHits: 0, arcticHits: 0 }; const chapterHandler = (reqUrl, res) => { redditState.arcticHits += 1; return defaultChapterHandler(reqUrl, res); }; const redditHandler = (reqUrl, res) => { redditState.redditHits += 1; return defaultRedditHandler(redditState.mode)(reqUrl, res); }; const { server, url } = await startServer(fixtureRoot, chapterHandler, redditHandler); const fetchApi = makeFetchApi(url); const failures = []; try { const storageMap = { indexBaseUrl: url, indexRev: "", // geen ?rev= nodig op de testhost chapterSourceUrl: url, chapterSource: "auto", }; const plugin = loadPlugin(storageMap, fetchApi); assert(plugin.id === "hfyNovels", "id"); assert(plugin.name === "HFY Novels", "name"); assert(plugin.version === "0.3.2", "version"); assert(plugin.site === "https://www.reddit.com/r/HFY/", "site"); assert(plugin.pluginSettings && plugin.pluginSettings.indexBaseUrl, "pluginSettings"); assert(plugin.filters && plugin.filters.catalog, "filter Nieuw/wiki"); assert(plugin.pluginSettings.chapterSource && plugin.pluginSettings.chapterSource.type === "Select", "bron-instelling is Select"); assert(typeof plugin.resolveUrl === "function", "resolveUrl"); assert(plugin.resolveUrl("chapter/aaa111") === "https://www.reddit.com/r/HFY/comments/aaa111/", "resolveUrl hoofdstuk"); assert(plugin.resolveUrl("series/aaa111", true) === "https://www.reddit.com/r/HFY/comments/aaa111/", "resolveUrl reeks"); assert(plugin.resolveUrl("wiki/the_last_terran", true) === "https://www.reddit.com/r/HFY/wiki/series/the_last_terran/", "resolveUrl wiki"); testLiveCoverFiles(); const popular = await plugin.popularNovels(1, { showLatestNovels: false, filters: {} }); assert(Array.isArray(popular) && popular.length >= 1, "popularNovels geeft items"); assert(popular[0].name && popular[0].path, "NovelItem heeft name+path"); assert(popular[0].cover && popular[0].cover.indexOf("/covers/") !== -1, "cover-URL wijst naar covers/"); const coverIsSvg = /\.svg(\?|$)/i.test(popular[0].cover); if (coverIsSvg) { assert(popular[0].cover.indexOf("as=img") !== -1, "SVG-cover heeft as=img"); } const coverRes = await fetch(popular[0].cover); assert(coverRes.ok, "cover is ophaalbaar"); const coverBuf = Buffer.from(await coverRes.arrayBuffer()); if (coverIsSvg) { const coverBody = coverBuf.toString("utf8"); assert(coverBody.indexOf(" !n.path.includes("ccc001")), "NSFW standaard verborgen in catalogus"); const latest = await plugin.popularNovels(1, { showLatestNovels: true, filters: {} }); assert(latest.length >= 1, "showLatestNovels werkt via zoekindex"); const oneshots = await plugin.popularNovels(1, { filters: { kind: { value: "oneshot" }, nsfw: { value: "hide" } }, }); assert(oneshots.length === 1 && oneshots[0].name === "A Short Hello", "filter oneshot"); const nsfw = await plugin.popularNovels(1, { filters: { kind: { value: "all" }, nsfw: { value: "show" } }, }); assert(nsfw.some((n) => n.path.includes("ccc001")), "NSFW zichtbaar met filter"); const search = await plugin.searchNovels("terran", 1); assert(search.length === 1 && search[0].path === "series/aaa111", "searchNovels op titel"); const byAuthor = await plugin.searchNovels("WriterTwo", 1); assert(byAuthor.length === 1, "searchNovels op auteur"); assert((await plugin.searchNovels("", 1)).length === 0, "lege zoekterm"); const novel = await plugin.parseNovel("series/aaa111"); assert(novel.path === "series/aaa111", "SourceNovel.path gelijk aan input"); assert(novel.author === "WriterOne", "auteur"); assert(novel.cover && novel.cover.indexOf("/covers/") !== -1, "parseNovel heeft een cover-URL"); assert(novel.chapters.length === 3, "3 hoofdstukken"); assert(novel.chapters[0].path === "chapter/aaa111", "hoofdstukpad"); assert(novel.chapters[0].chapterNumber === 1, "hoofdstuknummer"); assert(novel.status === NovelStatus.Ongoing || novel.status === NovelStatus.OnHiatus || novel.status === NovelStatus.Unknown, "status enum"); redditState.mode = "ok"; redditState.redditHits = 0; redditState.arcticHits = 0; const html = await plugin.parseChapter("chapter/aaa111"); assert(/It begins/.test(html), "parseChapter bevat tekst"); assert(/

/.test(html), "parseChapter heeft titel"); assert(!/