Files
iptvnator/tools/testing/website-guides.test.mjs
T
4grayandClaude Fable 5.1 6cfdaf5900 feat(website): add the Stalker portal setup guide with mock-backed screenshots
Publish "How to Connect a Stalker or Ministra Portal to IPTVnator": the
portal URL shapes discovery accepts, MAC normalization, the optional
serial/device-ID/signature fields and the pinning rules behind the
"generate device IDs" toggle, what endpoint discovery does on Add, the
sections a portal source gets, Account info, and a troubleshooting list
built from the app's own refusal messages, plus a seven-question FAQ.
The guide is cross-linked from the download pages and llms.txt.

Guide screenshots come from the capture script. Shots that walk into a
Stalker portal start the stalker-mock-server and seed its marketing-demo
portal for that run only, so release shots never gain a third source
card. The frame guard allowlists exactly that scenario's MAC and keeps
rejecting every other MAC-shaped string.

To keep the live-TV frame free of third-party images, the fictional live
channel list and the channel-logo SVG renderer move into
@iptvnator/shared/marketing-fixtures; both mocks now serve
/assets/marketing/logo/<slug>.svg, the Stalker marketing-demo scenario
builds its ITV categories, channels and schedule from those fixtures
instead of faker names with picsum logos, and the mock resolves asset
URLs on get_all_channels too, which is the response the app renders
the channel list from.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 07:20:56 +02:00

64 lines
2.4 KiB
JavaScript

import { access, readFile } from 'node:fs/promises';
import { test } from 'node:test';
import assert from 'node:assert/strict';
/**
* Structural checks for guide posts: they must carry FAQPage structured data
* next to the BlogPosting entry, link to the download hub, and reference only
* screenshots that the build actually shipped.
*/
const distRoot = new URL('../../dist/apps/website/', import.meta.url);
const SITE = 'https://4gray.github.io/iptvnator';
const GUIDES = [
{
slug: 'xtream-codes-setup-guide',
screenshots: [
'blog/guides/screenshots/guide-xtream-add-playlist-dark.png',
'blog/guides/screenshots/guide-xtream-auto-detect-dark.png',
'blog/guides/screenshots/guide-xtream-live-dark.png',
],
},
{
slug: 'stalker-portal-setup-guide',
screenshots: [
'blog/guides/screenshots/guide-stalker-add-playlist-dark.png',
'blog/guides/screenshots/guide-stalker-live-dark.png',
],
},
];
const readDist = (relativePath) => readFile(new URL(relativePath, distRoot), 'utf8');
function extractJsonLd(html) {
const blocks = [...html.matchAll(/<script type="application\/ld\+json">([\s\S]*?)<\/script>/g)];
assert.ok(blocks.length > 0, 'Expected at least one JSON-LD script block.');
return blocks.flatMap((match) => JSON.parse(match[1]));
}
for (const guide of GUIDES) {
test(`${guide.slug}: BlogPosting and FAQPage structured data`, async () => {
const html = await readDist(`blog/${guide.slug}/index.html`);
const schema = extractJsonLd(html);
assert.ok(schema.some((entry) => entry['@type'] === 'BlogPosting'), 'Expected a BlogPosting entry.');
const faq = schema.find((entry) => entry['@type'] === 'FAQPage');
assert.ok(faq, 'Expected a FAQPage entry.');
assert.ok(faq.mainEntity.length >= 5, 'Expected at least five FAQ questions.');
assert.match(html, /Frequently asked questions/);
assert.match(html, new RegExp(`<link rel="canonical" href="${SITE}/blog/${guide.slug}/"`));
});
test(`${guide.slug}: links to the download hub and ships its screenshots`, async () => {
const html = await readDist(`blog/${guide.slug}/index.html`);
assert.match(html, /href="\/iptvnator\/download\/"/);
for (const screenshot of guide.screenshots) {
assert.match(html, new RegExp(`src="/iptvnator/${screenshot.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}"`));
await access(new URL(screenshot, distRoot));
}
});
}