Skip to content

Unify generated-page chrome (news index / sitemap / political-intelligence) via render-lib/buildChrome#2012

Merged
pethers merged 8 commits intomainfrom
copilot/fix-mermaid-loading-issues
Apr 26, 2026
Merged

Unify generated-page chrome (news index / sitemap / political-intelligence) via render-lib/buildChrome#2012
pethers merged 8 commits intomainfrom
copilot/fix-mermaid-loading-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 26, 2026

Plan — unify generated-page chrome via render-lib/chrome.ts

  • Phase 1 — extend chrome API.
  • Phase 2 — sitemap port.
  • Phase 3 — political-intelligence port.
  • Phase 4 — news-index port.
  • Phase 5 — i18n via LANGUAGE_META[lang].translations.
  • Phase 6 — vitest 2157/2157, build, htmlhint.

Cypress regressions fixed

Run 24957929765 (news-page.cy.js · 3 failures) — fixed in dced8d4

  1. Missing <h1> in news/index — restored as <header class="news-page-heading"><h1>${t.title}</h1></header> to mirror sitemap and PI.
  2. Closed <details> lang-switcher dropdown was clickable — gated display: flex behind .rm-lang-switcher[open]. Cypress click selector tightened to :visible.

Run 24958216054 (sitemap.cy.js · 1 failure) — fixed in this commit

Norwegian Sitemap (no) → should have proper lang attribute for Norwegian expected lang="no" but got lang="nb". The site correctly emits BCP-47 nb for Norwegian Bokmål (per LANGUAGE_META[no].hreflang = 'nb' and the repo-wide instruction "Norwegian uses BCP-47 nb (preferred)"); only the file slug stays sitemap_no.html for backward-compat URLs. The Cypress test was hard-coding code (the slug) as the expected lang value. Updated the Norwegian fixture to { code: 'no', lang: 'nb' } and the assertion to cy.get('html').should('have.attr', 'lang', lang ?? code). All other 12 locales unchanged.

Vitest still 2157/2157 ✓.

Copilot AI and others added 6 commits April 26, 2026 12:44
@pethers pethers marked this pull request as ready for review April 26, 2026 13:35
Copilot AI review requested due to automatic review settings April 26, 2026 13:35
@github-actions github-actions Bot added documentation Documentation updates html-css HTML/CSS changes translation Translation updates testing Test coverage refactor Code refactoring news News articles and content generation size-xl Extra large change (> 1000 lines) labels Apr 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: documentation,html-css,translation,testing,refactor,size-xl,news

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR centralizes the HTML “chrome” (head/header/footer, SEO JSON-LD, theme toggle, language switcher, skip-link target) for generated pages (news indexes, sitemap, political-intelligence) by reusing scripts/render-lib/chrome.ts (buildChrome / renderChromeHead) and updating tests/docs accordingly.

Changes:

  • Extend buildChrome/renderChromeHead with breadcrumb, ogType, and defaultAlternateBase, plus theme anti-flash bootstrap and runtime script injection.
  • Update generator-facing test suites to assert the unified chrome contract (IDs/classes, JSON-LD serialization format, og:type behavior).
  • Add styling for the unified header theme toggle button and update generated HTML/doc artifacts accordingly.

Reviewed changes

Copilot reviewed 89 out of 112 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/render-lib.test.ts Adds unit coverage for new chrome options (theme toggle, anti-flash, breadcrumb override, alternate fallback, ogType).
tests/generate-sitemap-html.test.ts Updates assertions to the unified chrome contract (skip-link target #main, compact JSON-LD, footer/header parity).
tests/generate-political-intelligence.test.ts Aligns PI generation expectations with unified chrome (JSON-LD formatting, skip-link, header/footer structure).
tests/generate-news-indexes.test.ts Retargets news index tests to canonical header/footer, app-version marker, and JSON-LD serialization behavior.
styles.css Introduces .rm-theme-toggle styling consistent with the unified header chrome.
scripts/render-lib/index.ts Re-exports BreadcrumbItem type for consumers.
scripts/render-lib/chrome.ts Implements BreadcrumbItem, breadcrumb, defaultAlternateBase, ogType, anti-flash theme bootstrap, header theme toggle, and runtime script injection.
news/2026-04-21-realtime-1353-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-21-realtime-1353-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-21-motions-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-21-motions-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-21-evening-analysis-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-21-evening-analysis-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-20-motions-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-20-motions-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-20-evening-analysis-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-20-evening-analysis-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-19-realtime-1219-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-19-realtime-1219-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-19-month-ahead-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-19-month-ahead-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-19-deep-inspection-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-19-deep-inspection-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-18-realtime-1705-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-18-realtime-1705-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-17-realtime-1434-sv.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
news/2026-04-17-realtime-1434-en.html Regenerated output reflecting unified chrome (theme bootstrap/toggle, updated timestamps, injected loader).
analysis/daily/2026-04-26/monthly-review/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-26/month-ahead/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-25/monthly-review/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-25/month-ahead/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-24/propositions/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-24/motions/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-24/interpellations/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-24/evening-analysis/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-24/committeeReports/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-23/motions/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-23/monthly-review/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-23/month-ahead/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-23/committeeReports/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-22/realtime-2338/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-22/evening-analysis/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-21/realtime-1353/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-21/motions/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-21/evening-analysis/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-21/committeeReports/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-20/motions/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-20/interpellations/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-20/evening-analysis/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-19/realtime-1219/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-19/monthly-review/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-19/month-ahead/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-19/deep-inspection/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-18/weekly-review/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-18/realtime-1705/article.md Updates generated_at timestamp from regeneration.
analysis/daily/2026-04-17/realtime-1434/article.md Updates generated_at timestamp from regeneration.
Article-Generation.md Documents the new runtime injection approach for Mermaid/back-to-top/theme-toggle and the anti-flash bootstrap.

@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 26, 2026

@copilot analyse root cause of Test News / News & Sitemap Tests (cypress/e2e/news-page.cy.js) (pull_request)
Test News / News & Sitemap Tests (cypress/e2e/news-page.cy.js) (pull_request)Failing after 2m

and adress root cause and improve changed code from all perspective. regenerate html , analyse, iterate and improve

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 26, 2026

@copilot analyse root cause of [Test News / News & Sitemap Tests (cypress/e2e/news-page.cy.js) (pull_request)](https://github.com/Hack23/riksdagsmonitor/actions/runs/24957929765/job/73...

Root-caused and fixed in dced8d4.

Two root causes behind the 3 Cypress failures (should display page heading, should have proper heading hierarchy, should support language switching on news page):

  1. Missing <h1> in news/index — the canonical rm-site-header brand link replaced the legacy .header-section h1 during the news-index port, but unlike sitemap (<h1>${t.siteMap}</h1>) and PI (<h1>🧠 ${t.title}</h1>) the news-index lost its body-level h1. Restored as <header class="news-page-heading"><h1>${t.title}</h1><p class="news-page-subtitle">…</p></header> to mirror the other two generators and keep a11y heading hierarchy + SEO consistent.

  2. Closed <details> lang-switcher dropdown was still clickable.rm-lang-switcher-dropdown { display: flex } beat the UA-default details:not([open]) > *:not(summary) { display: none } by class-selector specificity. Result: the dropdown anchors stayed in layout even when visually collapsed, sitting under the sticky rm-site-header, and cy.click() on the first index_sv.html link hit a header-covered element. Fixed by gating display: flex behind .rm-lang-switcher[open] > .rm-lang-switcher-dropdown — also resolves the same latent bug on articles/sitemap/PI. Cypress selector tightened to :visible so it's robust whether the dropdown is open or the user uses the footer language row.

Vitest still 2157/2157 ✓; news-index regenerated (14/14 files, 2746 articles).

@github-actions github-actions Bot added the javascript JavaScript code changes label Apr 26, 2026
Copilot AI requested a review from pethers April 26, 2026 13:50
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 26, 2026

@copilot continue improve

still

89 passing (33s)
1 failing

  1. Sitemap Pages
    Multi-Language Sitemap Support
    Norwegian Sitemap (no)
    should have proper lang attribute for Norwegian:

    Timed out retrying after 5000ms

    • expected - actual

    -'nb'
    +'no'

    at Context.eval (webpack://riksdagsmonitor/./cypress/e2e/sitemap.cy.js:108:25)

❌ Test failures detected in spec. Use the --bail flag to stop the run on first failing spec.
Error: Cypress tests: 1 failed

failing checks
Test News / News & Sitemap Tests (cypress/e2e/sitemap.cy.js) (pull_request)
Test News / News & Sitemap Tests (cypress/e2e/sitemap.cy.js) (pull_request)Failing after 2m

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 26, 2026

@copilot continue improve

still
...

Fixed in de10b28.

Root cause: the site correctly emits <html lang="nb"> for Norwegian (BCP-47 nb for Bokmål per LANGUAGE_META[no].hreflang = 'nb', and the repo-wide rule "Norwegian uses BCP-47 nb (preferred)"). Only the file slug stays sitemap_no.html for URL backward-compat. The Cypress fixture was conflating slug and lang, hard-coding cy.get('html').should('have.attr', 'lang', code) with code='no'.

Fix: added optional lang field to the language fixture ({ code: 'no', name: 'Norwegian', dir: 'ltr', lang: 'nb' }) and changed the assertion to cy.get('html').should('have.attr', 'lang', lang ?? code). All 12 other locales are unaffected (their slug == lang). The sitemap HTML itself does not need to change.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers pethers merged commit 0f42e53 into main Apr 26, 2026
26 checks passed
@pethers pethers deleted the copilot/fix-mermaid-loading-issues branch April 26, 2026 14:26
Copilot AI added a commit that referenced this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation updates html-css HTML/CSS changes javascript JavaScript code changes news News articles and content generation refactor Code refactoring size-xl Extra large change (> 1000 lines) testing Test coverage translation Translation updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants