From bb0c04e6791f48e4b79779b775b407d2e937ae8c Mon Sep 17 00:00:00 2001 From: Alan Richardson Date: Thu, 11 Jun 2026 16:27:01 +0100 Subject: [PATCH 1/3] fix testenv site page header rendering --- scripts/create-testenv.mjs | 47 ++++++++------------ tests/integration/create-testenv-seo.test.js | 44 +++++++++++++++++- 2 files changed, 62 insertions(+), 29 deletions(-) diff --git a/scripts/create-testenv.mjs b/scripts/create-testenv.mjs index 6032a53b..24543c34 100644 --- a/scripts/create-testenv.mjs +++ b/scripts/create-testenv.mjs @@ -64,7 +64,7 @@ function runCommand(command, args, options = {}) { if (result.status !== 0) { throw new Error( - `Command failed: ${command} ${args.join(' ')} (status ${result.status ?? 1}${result.signal ? `, signal ${result.signal}` : ''})`, + `Command failed: ${command} ${args.join(' ')} (status ${result.status ?? 1}${result.signal ? `, signal ${result.signal}` : ''})` ); } } @@ -191,10 +191,7 @@ function upsertHeadStyle(html, markerAttribute, styleTag) { function applySeoDirectivesToHtml( html, - { - canonicalUrl = ROOT_CANONICAL_URL, - robotsDirectives = TESTENV_ROBOTS_DIRECTIVES, - } = {}, + { canonicalUrl = ROOT_CANONICAL_URL, robotsDirectives = TESTENV_ROBOTS_DIRECTIVES } = {} ) { let nextHtml = html; @@ -495,13 +492,17 @@ const TESTENV_HIDE_HEADER_STYLE = ` } `; -async function hideTopHeaderInBuiltPage(pagePath) { - const html = await readFile(pagePath, 'utf8'); +function hideTopHeaderInBuiltHtml(html) { if (html.includes('data-testenv-hide-header')) { - return; + return html; } - const nextHtml = html.replace('', `${TESTENV_HIDE_HEADER_STYLE}\n `); + return html.replace('', `${TESTENV_HIDE_HEADER_STYLE}\n `); +} + +async function hideTopHeaderInBuiltPage(pagePath) { + const html = await readFile(pagePath, 'utf8'); + const nextHtml = hideTopHeaderInBuiltHtml(html); await writeFile(pagePath, nextHtml, 'utf8'); } @@ -541,11 +542,7 @@ async function createTemporaryDocsAppPlaceholder() { } async function removeTemporaryDocsAppPlaceholder() { - await writeFile( - docsAppPlaceholderPath, - '

This will be overwritten during the npm build.

', - 'utf8', - ); + await writeFile(docsAppPlaceholderPath, '

This will be overwritten during the npm build.

', 'utf8'); } async function main() { @@ -578,26 +575,19 @@ async function main() { await createTemporaryDocsAppPlaceholder(); try { - runCommand( - 'pnpm', - ['--dir', 'docs-src', 'exec', 'docusaurus', 'build', '--out-dir', '../testenv/site'], - { - env: { - DOCS_BASE_URL: fullSiteBaseUrl, - DOCS_SITE_URL: 'https://eviltester.github.io', - DOCS_TEST_BUILD: 'true', - DOCS_TEST_CANONICAL_SITE_URL: TESTENV_CANONICAL_SITE_URL, - }, + runCommand('pnpm', ['--dir', 'docs-src', 'exec', 'docusaurus', 'build', '--out-dir', '../testenv/site'], { + env: { + DOCS_BASE_URL: fullSiteBaseUrl, + DOCS_SITE_URL: 'https://eviltester.github.io', + DOCS_TEST_BUILD: 'true', + DOCS_TEST_CANONICAL_SITE_URL: TESTENV_CANONICAL_SITE_URL, }, - ); + }); } finally { await removeTemporaryDocsAppPlaceholder(); } await copyWebBuildIntoDirectory(tempWebDir, fullSiteDir); - await hideTopHeaderInBuiltPage(path.join(fullSiteDir, 'app.html')); - await hideTopHeaderInBuiltPage(path.join(fullSiteDir, 'generator.html')); - await hideTopHeaderInBuiltPage(path.join(fullSiteDir, 'combinatorial.html')); await rm(tempWebDir, { recursive: true, force: true, @@ -627,6 +617,7 @@ export { createLlmsTxt, createSiteRobotsTxt, createTestenvRobotsTxt, + hideTopHeaderInBuiltHtml, renderIndexPage, }; diff --git a/tests/integration/create-testenv-seo.test.js b/tests/integration/create-testenv-seo.test.js index 218bd648..ba9a97fc 100644 --- a/tests/integration/create-testenv-seo.test.js +++ b/tests/integration/create-testenv-seo.test.js @@ -5,6 +5,7 @@ import { createLlmsTxt, createSiteRobotsTxt, createTestenvRobotsTxt, + hideTopHeaderInBuiltHtml, renderIndexPage, } from '../../scripts/create-testenv.mjs'; @@ -47,7 +48,9 @@ describe('create-testenv SEO helpers', () => { }); test('injects the test environment indicator into rewritten html pages', () => { - const html = applySeoDirectivesToHtml('Storybook'); + const html = applySeoDirectivesToHtml( + 'Storybook' + ); expect(html).toContain('data-testenv-indicator'); expect(html).toContain('content: "Test Environment"'); @@ -57,4 +60,43 @@ describe('create-testenv SEO helpers', () => { expect(html).toContain('box-shadow: none;'); expect(html).toContain('font: 700 6px/1.2 Arial, Helvetica, sans-serif;'); }); + + test('site page SEO rewrite preserves the visible navbar while adding the test environment indicator', () => { + const sourceHtml = ` + + + App + +
AnyWayData
+ + + `; + + const html = applySeoDirectivesToHtml(sourceHtml, { + canonicalUrl: `${TESTENV_CANONICAL_SITE_URL}/app.html`, + }); + + expect(html).toContain('data-testenv-indicator'); + expect(html).toContain('class="header"'); + expect(html).not.toContain('data-testenv-hide-header'); + expect(html).toContain(''); + }); + + test('standalone app pages can be rewritten to hide the top header', () => { + const sourceHtml = ` + + + Standalone App + +
AnyWayData
+ + + `; + + const html = hideTopHeaderInBuiltHtml(sourceHtml); + + expect(html).toContain('data-testenv-hide-header'); + expect(html).toContain('.header {'); + expect(html).toContain('display: none !important;'); + }); }); From b796c2c60eabc2d86b8ffcdfb2f6f725555c7d9c Mon Sep 17 00:00:00 2001 From: Alan Richardson Date: Fri, 12 Jun 2026 10:45:28 +0100 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/create-testenv.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/create-testenv.mjs b/scripts/create-testenv.mjs index 24543c34..3ff734b1 100644 --- a/scripts/create-testenv.mjs +++ b/scripts/create-testenv.mjs @@ -503,6 +503,11 @@ function hideTopHeaderInBuiltHtml(html) { async function hideTopHeaderInBuiltPage(pagePath) { const html = await readFile(pagePath, 'utf8'); const nextHtml = hideTopHeaderInBuiltHtml(html); + + if (nextHtml === html) { + return; + } + await writeFile(pagePath, nextHtml, 'utf8'); } From 6bc3f2bed11969bea6fc83a41003a3a4e0345311 Mon Sep 17 00:00:00 2001 From: Alan Richardson Date: Fri, 12 Jun 2026 10:46:21 +0100 Subject: [PATCH 3/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/integration/create-testenv-seo.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/create-testenv-seo.test.js b/tests/integration/create-testenv-seo.test.js index ba9a97fc..71d5f079 100644 --- a/tests/integration/create-testenv-seo.test.js +++ b/tests/integration/create-testenv-seo.test.js @@ -61,7 +61,7 @@ describe('create-testenv SEO helpers', () => { expect(html).toContain('font: 700 6px/1.2 Arial, Helvetica, sans-serif;'); }); - test('site page SEO rewrite preserves the visible navbar while adding the test environment indicator', () => { + test('SEO rewrite keeps existing headers intact while adding the test environment indicator', () => { const sourceHtml = `