diff --git a/frontend-modern/browser-tests/README.md b/frontend-modern/browser-tests/README.md index 6474961e41..d9628bab61 100644 --- a/frontend-modern/browser-tests/README.md +++ b/frontend-modern/browser-tests/README.md @@ -64,7 +64,7 @@ fixtures once, before browser execution, from `frontend-modern`: ```sh node browser-tests/build-publication-fixtures.mjs -node --test browser-tests/publication-fixture-server.test.cjs +npm run test -- browser-tests/publication-fixture-server.test.mjs ``` The four corresponding browser runners use the resulting static bundles in diff --git a/frontend-modern/browser-tests/publication-fixture-server.test.cjs b/frontend-modern/browser-tests/publication-fixture-server.test.mjs similarity index 96% rename from frontend-modern/browser-tests/publication-fixture-server.test.cjs rename to frontend-modern/browser-tests/publication-fixture-server.test.mjs index 9701c8960e..7fa142727a 100644 --- a/frontend-modern/browser-tests/publication-fixture-server.test.cjs +++ b/frontend-modern/browser-tests/publication-fixture-server.test.mjs @@ -1,17 +1,17 @@ -const assert = require('node:assert/strict'); -const fs = require('node:fs'); -const http = require('node:http'); -const os = require('node:os'); -const path = require('node:path'); -const { afterEach, test } = require('node:test'); -const { +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import http from 'node:http'; +import os from 'node:os'; +import path from 'node:path'; +import { afterEach, test } from 'vitest'; +import { createPublicationFixtureServer, loadPublicationFixture, runtimePaths, entryPaths, harnessPaths, hash, -} = require('./publication-fixture-server.cjs'); +} from './publication-fixture-server.cjs'; const temporary = []; afterEach(() => { diff --git a/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts b/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts index 418e659446..64f08acbc9 100644 --- a/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts +++ b/frontend-modern/src/utils/__tests__/notificationPrivacyHelp.test.ts @@ -12,7 +12,7 @@ const article = (name: string): HTMLElement => { element.innerHTML = renderDocMarkdown(read(`docs/${name}.md`), name); return element; }; -const sectionText = (name: string, start: string, end: string): string => { +const sectionArticle = (name: string, start: string, end: string): HTMLElement => { const source = read(`docs/${name}.md`).split(start)[1]?.split(end)[0]; expect( source, @@ -20,8 +20,10 @@ const sectionText = (name: string, start: string, end: string): string => { ).toBeDefined(); const element = document.createElement('article'); element.innerHTML = renderDocMarkdown(source!, name); - return element.textContent!.replace(/\s+/g, ' ').trim(); + return element; }; +const sectionText = (name: string, start: string, end: string): string => + sectionArticle(name, start, end).textContent!.replace(/\s+/g, ' ').trim(); const recoveryText = (): string => sectionText( 'TROUBLESHOOTING', @@ -76,6 +78,18 @@ describe('notification evidence privacy help', () => { WEBHOOKS: article('WEBHOOKS'), TROUBLESHOOTING: article('TROUBLESHOOTING'), }; + const entryPoints: Record = { + WEBHOOKS: sectionArticle( + 'WEBHOOKS', + '**Retries and retained failures.**', + '**Correlation header.**', + ), + TROUBLESHOOTING: sectionArticle( + 'TROUBLESHOOTING', + '#### Recover retained delivery failures', + '#### Emails not sending', + ), + }; const cases = [ [ 'TROUBLESHOOTING', @@ -91,7 +105,7 @@ describe('notification evidence privacy help', () => { ], ]; for (const [from, to, href, label] of cases) { - const link = guides[from].querySelector(`a[href="${href}"]`); + const link = entryPoints[from].querySelector(`a[href="${href}"]`); expect(link?.textContent).toBe(label); expect(guides[to].querySelector(href.slice(href.indexOf('#')))).not.toBeNull(); }