Skip to content

[codex] Fix testenv site page header rendering#186

Merged
eviltester merged 3 commits into
masterfrom
codex/185-improve-test-env-rendering
Jun 12, 2026
Merged

[codex] Fix testenv site page header rendering#186
eviltester merged 3 commits into
masterfrom
codex/185-improve-test-env-rendering

Conversation

@eviltester

@eviltester eviltester commented Jun 11, 2026

Copy link
Copy Markdown
Owner

What changed

  • keep the generated testenv root pages headerless for distraction-free standalone previews
  • preserve the normal navbar on copied /site/*.html pages in the full-site test environment
  • add regression coverage for both rendering paths in the testenv SEO integration tests

Why this changed

The test environment builder was hiding the top header on both the standalone root pages and the copied /site/ pages. That removed the expected navbar from /site/app.html, /site/generator.html, and related pages even though those pages should behave like the published site and keep the test-environment badge.

Impact

Reviewers can now use the /site/*.html pages with normal navigation intact, while the standalone experiment pages still stay minimal.

Validation

  • pnpm test -- --runTestsByPath tests/integration/create-testenv-seo.test.js
  • pnpm run verify:ui
  • pnpm run verify:local

Summary by CodeRabbit

  • Tests

    • Enhanced integration test coverage for SEO directives and header management
    • Added tests verifying markup preservation and header-hiding functionality
  • Refactor

    • Improved code structure and maintainability in test environment setup scripts
    • Streamlined helper function organization

Copilot AI review requested due to automatic review settings June 11, 2026 15:37
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@eviltester, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 40 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 18bf57c1-328e-4192-ac41-9f904c1f0af9

📥 Commits

Reviewing files that changed from the base of the PR and between bb0c04e and 6bc3f2b.

📒 Files selected for processing (2)
  • scripts/create-testenv.mjs
  • tests/integration/create-testenv-seo.test.js
📝 Walkthrough

Walkthrough

This PR extracts header-hiding logic into a reusable helper function, refactors file-level header hiding to always persist changes, and expands integration test coverage for SEO directives and header hiding. The script also includes minor formatting improvements to error messages, parameter defaults, and build configuration.

Changes

SEO Directives and Header Hiding

Layer / File(s) Summary
Header hiding helper extraction and export
scripts/create-testenv.mjs
New hideTopHeaderInBuiltHtml(html) helper applies data-testenv-hide-header markup and CSS rules to HTML; hideTopHeaderInBuiltPage(pagePath) updated to always read, transform (or no-op when marker exists), and write back. Helper is exported for test use.
Test integration for SEO and header hiding
tests/integration/create-testenv-seo.test.js, scripts/create-testenv.mjs
Tests import the new hideTopHeaderInBuiltHtml helper; existing applySeoDirectivesToHtml test is reformatted for clarity; two new tests verify that site pages preserve visible headers with test indicators while standalone app HTML receives header-hiding markup and CSS.
Supporting formatting and refactoring
scripts/create-testenv.mjs
Minor updates: error message formatting in runCommand, applySeoDirectivesToHtml parameter destructuring simplified to single-line defaults, createTemporaryDocsAppPlaceholder file write call streamlined, and Docusaurus build env object reformatted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A header hides when tests arrive,
New helpers make the scripts come alive,
Tests verify the markup's neat,
With cleanup touches, code's complete!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary fix: preventing the test environment from incorrectly hiding headers on site pages. This matches the main objective of preserving navbar visibility on /site/ pages while keeping standalone pages headerless.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/185-improve-test-env-rendering

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the test environment build pipeline so that standalone root pages (/app.html, /generator.html, etc.) remain headerless for focused previews, while the copied full-site pages under /site/*.html retain the normal navbar. It also adds regression coverage around the two rendering paths.

Changes:

  • Stop injecting the “hide header” style into the copied /site/*.html pages while keeping it for the standalone root pages.
  • Extract a reusable hideTopHeaderInBuiltHtml helper (used by the file-based mutator and tests).
  • Extend the testenv SEO integration tests to cover both “SEO rewrite” and “header hiding” behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/integration/create-testenv-seo.test.js Adds regression tests for header hiding vs. SEO rewriting behavior.
scripts/create-testenv.mjs Refactors header-hiding into an HTML helper and stops hiding headers on /site/*.html pages.

Comment thread scripts/create-testenv.mjs
Comment thread tests/integration/create-testenv-seo.test.js Outdated
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes the test-environment builder so that header-hiding is applied only to the root standalone pages (outputDir) and no longer to the /site/*.html copies (fullSiteDir). It achieves this by extracting a pure hideTopHeaderInBuiltHtml helper, removing the three erroneous hideTopHeaderInBuiltPage calls that were targeting fullSiteDir, and exporting the new helper so it can be unit-tested directly.

  • Behavioural fix: /site/app.html, /site/generator.html, and /site/combinatorial.html now retain the normal navbar in the test environment, matching the published site; root standalone pages continue to be headerless.
  • Test additions: two new integration tests cover the SEO-rewrite path (must not inject data-testenv-hide-header) and the hideTopHeaderInBuiltHtml path (must inject the hide-header style), with the majority of the diff being formatting-only cleanup.

Confidence Score: 5/5

Safe to merge — targeted removal of three misplaced header-hiding calls with a straightforward pure-function extraction and matching test coverage.

Both changed files are build/test tooling only, with no effect on production runtime behaviour. The bug fix is simple and correct: the three hideTopHeaderInBuiltPage calls incorrectly targeting fullSiteDir are gone, while the equivalent calls targeting outputDir remain. New tests exercise both the SEO-rewrite path and the header-hiding path.

No files require special attention.

Important Files Changed

Filename Overview
scripts/create-testenv.mjs Extracts hideTopHeaderInBuiltHtml as a pure exported function; removes the erroneous hideTopHeaderInBuiltPage calls for fullSiteDir pages so that /site/*.html pages retain their navbar. Includes a formatting cleanup (trailing comma removal). The logic change is intentional and well-scoped.
tests/integration/create-testenv-seo.test.js Adds two regression tests: one asserting applySeoDirectivesToHtml does not inject data-testenv-hide-header, and one asserting hideTopHeaderInBuiltHtml correctly injects the hide-header style. Both new tests are correct and cover the changed behaviour paths.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[main] --> B[copyWebBuildIntoDirectory tempWebDir → outputDir]
    B --> C[hideTopHeaderInBuiltPage outputDir/app.html\noutputDir/generator.html\noutputDir/combinatorial.html]
    C --> D[docusaurus build → fullSiteDir]
    D --> E[copyWebBuildIntoDirectory tempWebDir → fullSiteDir]
    E --> F[rm tempWebDir]

    subgraph hideTopHeaderInBuiltHtml
        G{html includes data-testenv-hide-header?}
        G -- yes --> H[return html unchanged]
        G -- no --> I[inject TESTENV_HIDE_HEADER_STYLE before end of head]
    end

    C --> G
Loading

Reviews (2): Last reviewed commit: "Potential fix for pull request finding" | Re-trigger Greptile

Comment thread scripts/create-testenv.mjs
eviltester and others added 2 commits June 12, 2026 10:45
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@eviltester eviltester merged commit 88489fb into master Jun 12, 2026
14 checks passed
@eviltester eviltester deleted the codex/185-improve-test-env-rendering branch June 12, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants