Skip to content

Commit dced8d4

Browse files
Copilotpethers
andauthored
Fix Cypress news-page failures: add page <h1>, hide closed lang dropdown
Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/5516d7cf-01ed-4225-8adf-b8e1202fca9c Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
1 parent 2e5bab4 commit dced8d4

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

cypress/e2e/news-page.cy.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,13 @@ describe('News Page - Navigation', () => {
244244
it('should support language switching on news page', () => {
245245
cy.visit('/news/');
246246

247-
// Try to switch to Swedish version
247+
// Try to switch to Swedish version. The canonical chrome renders the
248+
// top-of-page lang switcher inside a collapsed <details> dropdown, so
249+
// filter to the visible anchor (footer language row, or open dropdown).
248250
cy.get('body').then(($body) => {
249251
const svLink = $body.find('a[href*="index_sv.html"]');
250252
if (svLink.length > 0) {
251-
cy.get('a[href*="index_sv.html"]').first().click();
253+
cy.get('a[href*="index_sv.html"]:visible').first().click();
252254
cy.url().should('include', 'index_sv.html');
253255
} else {
254256
cy.log('Swedish language link not found - skipping language switch test');

scripts/generate-news-indexes/template.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ export function generateIndexHTML(
183183
const body = ` <div class="container">
184184
${needsLanguageNotice ? generateLanguageNotice(langKey) : ''}
185185
186+
<!-- Page heading (canonical chrome puts brand only in <header>; the
187+
news-index page itself owns the document <h1> for a11y heading
188+
hierarchy and SEO, matching sitemap.html and political-intelligence.html). -->
189+
<header class="news-page-heading">
190+
<h1>${escapeHtml(lang.title)}</h1>
191+
<p class="news-page-subtitle">${escapeHtml(lang.subtitle)}</p>
192+
</header>
193+
186194
<!-- Filter Bar -->
187195
<div class="filter-bar">
188196
<div class="filter-group">

styles.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12235,12 +12235,21 @@ html[data-theme="light"] .footer-disclaimer a {
1223512235
border-radius: 6px;
1223612236
padding: 0.5rem;
1223712237
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
12238-
display: flex;
12238+
/* Hidden by default so the closed <details> doesn't leave dropdown
12239+
anchors as click targets (Cypress would otherwise hit them through
12240+
the sticky rm-site-header). The class selector previously beat the
12241+
UA-default `details:not([open]) > *:not(summary) { display: none }`
12242+
rule and forced the dropdown visible even when collapsed. */
12243+
display: none;
1223912244
flex-direction: column;
1224012245
gap: 0.125rem;
1224112246
z-index: 120;
1224212247
}
1224312248

12249+
.rm-lang-switcher[open] > .rm-lang-switcher-dropdown {
12250+
display: flex;
12251+
}
12252+
1224412253
.rm-lang-switcher-dropdown a {
1224512254
color: var(--light-text, #e0e0e0);
1224612255
text-decoration: none;

0 commit comments

Comments
 (0)