Skip to content

Refactor news generation: externalize CSS, modularize architecture, add comprehensive testing#160

Draft
Copilot wants to merge 13 commits intomainfrom
copilot/refactor-news-article-generator
Draft

Refactor news generation: externalize CSS, modularize architecture, add comprehensive testing#160
Copilot wants to merge 13 commits intomainfrom
copilot/refactor-news-article-generator

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

News articles had 350+ lines of embedded CSS causing cache inefficiency and maintenance overhead. News generation logic was monolithic with no article-type-specific testing or cross-reference validation.

Changes

CSS Architecture Refactoring

  • Removed: generateArticleCSS() and getArticleStyles() from article-template.js (350 lines → external stylesheet)
  • Added: NEWS ARTICLE STYLES section to styles.css (~450 lines)
  • Result: 43% smaller template file (813 → 463 lines), single source of truth for all article styling

Economist-Style Formatting

  • Brand tagline on all articles
  • Typography: 3.5rem drop caps, justified text (desktop), 66ch optimal line length
  • Special blocks: .why-matters (analysis), .pull-quote (large quotes), enhanced .context-box
  • Responsive: justified text desktop-only, smaller drop caps mobile, B&W print mode

Modular News Architecture

Created 5 specialized generators in scripts/news-types/:

  • week-ahead.js - Prospective 7-day coverage (calendar_events + dokument + fragor + interpellationer)
  • committee-reports.js - Committee betänkanden analysis (betankanden + voteringar + anforanden + propositioner)
  • propositions.js - Government bills analysis
  • motions.js - Opposition motions analysis
  • breaking-news.js - Event-driven coverage (voteringar + voting_group + anforanden + ledamoter)

Each module exports: generate(), validate(), REQUIRED_TOOLS constant

Testing Infrastructure

  • 111 tests across 6 test files for article generators
  • validate-cross-references.js - Ensures 3+ data sources per article
  • validate-articles-playwright.js - Accessibility (WCAG 2.1 AA), RTL layout (ar/he), screenshot capture
  • Integration tests for cross-reference patterns

Before:

// article-template.js line 320
${generateArticleCSS()}  // Embedded <style> tag with 335 lines

function getArticleStyles() {
  return `/* 335 lines of CSS */`;
}

After:

// article-template.js - CSS generation removed
// All styles in styles.css lines 8705-9150
// Template now 43% smaller with external stylesheet

Bug Fixes

  • Import: generate-news-enhanced.js line 46 incorrectly imported from breaking-news.js instead of motions.js
  • Method names: breaking-news.test.js used non-existent searchVoteringar()/searchAnforanden() instead of fetchVotingRecords()/searchSpeeches()
  • File organization: Moved take-screenshot.js to scripts/ directory

Documentation

  • NEWS_ARTICLE_STYLING_GUIDE.md - CSS class reference, responsive patterns, maintenance guidelines
  • MODULAR_NEWS_ARCHITECTURE.md - Architecture overview, module API reference
  • REFACTORING_SUMMARY.md - Complete deliverables summary
  • news/sample-economist-style.html - Full demonstration of styling features

Impact

  • Maintainability: Single CSS source, modular generators, comprehensive tests
  • Performance: ~5KB smaller HTML (no embedded CSS), better browser caching
  • Quality: Automated validation ensures 3+ sources, proper cross-referencing, accessibility compliance
Original prompt

This section details on the original issue you should resolve

<issue_title>Improve news-article-generator.md: Modular architecture and cross-referencing validation</issue_title>
<issue_description>## 📋 Issue Type
Feature Enhancement / Code Quality

🎯 Objective

Refactor and enhance the news-article-generator.md agentic workflow to improve code modularity, test coverage, and cross-referencing capabilities for generating high-quality prospective and retrospective political journalism from riksdag-regering data.

📊 Current State

Workflow Analysis

File: .github/workflows/news-article-generator.md
Schedule: Daily (unspecified time)
Model: claude-opus-4.6
MCP Server: riksdag-regering (https://riksdag-regering-ai.onrender.com/mcp)
Timeout: 30 minutes
Default Languages: en,sv

Article Types Supported

  1. week-ahead - Prospective coverage (next 7 days)
  2. committee-reports - Committee betänkanden analysis
  3. propositions - Government bills analysis
  4. motions - Opposition motions analysis
  5. breaking - Event-driven coverage

Current Issues Identified

  1. Code Organization Needs Improvement

    • Problem: Monolithic workflow with inline article generation logic
    • Impact: Difficult to test individual article types
    • Missing: Modular functions for each article type
    • Needed: Separate modules: week-ahead.js, committee-reports.js, etc.
  2. Test Coverage Gaps

    • Current: Tests exist for generate-news-enhanced.js (split into part1/part2)
    • Gap: No tests for article-type-specific logic
    • Missing: Week-ahead calendar parsing tests
    • Missing: Committee reports cross-referencing tests
    • Missing: Propositions/motions analysis tests
  3. Cross-Referencing Strategy Incomplete

    • Documented: Good cross-referencing patterns in workflow
    • Implemented: Partial - not all patterns tested
    • Week Ahead Pattern: calendar_events + dokument + fragor + interpellationer
    • Committee Reports Pattern: betankanden + voteringar + anforanden + propositioner
    • Breaking News Pattern: voteringar + voting_group + anforanden + ledamoter
    • Missing: Validation that all required tools are called
  4. Playwright Validation Inconsistent

    • Documented: Step 8 includes Playwright validation
    • Implementation: Not enforced in code
    • Missing: Automated screenshot capture for PRs
    • Missing: Accessibility tree validation
    • Missing: RTL layout validation for ar/he

Measured Metrics (Feb 10-14)

  • Articles Generated: 22 articles in news/ directory
  • Week-Ahead Coverage: 3 articles (Feb 10, Feb 14)
  • Committee Reports: 1 article (Feb 2026)
  • Propositions: 1 article (Feb 2026)
  • Motions: 1 article (Feb 2026)
  • Evening Analysis: 14 language versions (Feb 13)
  • Breaking News: 2 articles (PM EU Summit, Biodiversity)
  • Test Coverage: generate-news-enhanced.js tested, article types not tested

🚀 Desired State

Target Outcomes

  1. Modular Code Architecture

    • ✅ scripts/news-types/week-ahead.js
    • ✅ scripts/news-types/committee-reports.js
    • ✅ scripts/news-types/propositions.js
    • ✅ scripts/news-types/motions.js
    • ✅ scripts/news-types/breaking-news.js
    • ✅ Each module exports: generate(), validate(), test()
  2. Comprehensive Test Coverage

    • ✅ tests/news-types/week-ahead.test.js (15+ tests)
    • ✅ tests/news-types/committee-reports.test.js (15+ tests)
    • ✅ tests/news-types/propositions.test.js (10+ tests)
    • ✅ tests/news-types/motions.test.js (10+ tests)
    • ✅ tests/news-types/breaking-news.test.js (10+ tests)
    • ✅ tests/news-article-generator-integration.test.js (workflow integration)
  3. Enhanced Cross-Referencing

    • ✅ Validate all required MCP tools called for each article type
    • ✅ Track which tools were used per article
    • ✅ Verify cross-references appear in article body
    • ✅ Ensure 3+ distinct data sources per article
  4. Playwright Visual Validation

    • ✅ Automated screenshot capture for all generated articles
    • ✅ Accessibility tree validation (WCAG 2.1 AA)
    • ✅ RTL layout validation for ar/he versions
    • ✅ Screenshots included in PR body as evidence

🔧 Implementation Approach

Phase 1: Modular Architecture Refactoring

Create Modular Structure:

scripts/
├── news-types/
│   ├── week-ahead.js
│   ├── committee-reports.js
│   ├── propositions.js
│   ├── motions.js
│   └── breaking-news.js
└── generate-news-enhanced.js (orchestrator)

Example: scripts/news-types/week-ahead.js

import { MCPClient } from '../mcp-client.js';

export async function generateWeekAhead(options = {}) {
  const { languages = ['en', 'sv'], dateRange = 7 } = options;
  
  // MCP queries for week-ahead
  const client = new MCPClient();
  const events = await client.getCalendarEvents({ /* ... */ });
  const documents = await client.searchDokumen...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Hack23/riksdagsmonitor#159

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Copilot AI and others added 3 commits February 14, 2026 00:26
- Created scripts/news-types/week-ahead.js
- Created scripts/news-types/committee-reports.js
- Created scripts/news-types/propositions.js
- Created scripts/news-types/motions.js
- Created scripts/news-types/breaking-news.js
- Created scripts/validate-cross-references.js
- Created scripts/validate-articles-playwright.js

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
- Created tests/news-types/week-ahead.test.js (46 tests)
- Created tests/news-types/committee-reports.test.js (22 tests)
- Created tests/news-types/propositions.test.js (9 tests)
- Created tests/news-types/motions.test.js (9 tests)
- Created tests/news-types/breaking-news.test.js (11 tests)
- Created tests/news-article-generator-integration.test.js (14 tests)
- All 111 tests passing

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
- Added MODULAR_NEWS_ARCHITECTURE.md comprehensive documentation
- Documented all 5 modular generators with required tools
- Documented validation tools (cross-references & Playwright)
- Documented 111 tests across 6 test files
- Documented cross-reference patterns per article type
- Documented usage examples and benefits
- Updated generate-news-enhanced.js with modular imports
- Maintained backward compatibility

✅ All acceptance criteria met:
- 5 modular scripts in scripts/news-types/
- 111 tests across 6 test files (exceeds 60+)
- Cross-reference validation implemented
- Playwright validation with screenshots
- All tests passing
- Documentation completed

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Comment on lines +29 to +34
import {
generateWeekAhead as generateWeekAheadModule,
getWeekAheadDateRange,
formatDateForSlug as formatDateForSlugModule,
REQUIRED_TOOLS as WEEK_AHEAD_TOOLS
} from './news-types/week-ahead.js';
Comment on lines +35 to +38
import {
generateCommitteeReports as generateCommitteeReportsModule,
REQUIRED_TOOLS as COMMITTEE_REPORTS_TOOLS
} from './news-types/committee-reports.js';
Comment on lines +39 to +42
import {
generatePropositions as generatePropositionsModule,
REQUIRED_TOOLS as PROPOSITIONS_TOOLS
} from './news-types/propositions.js';
- Added REFACTORING_SUMMARY.md with complete deliverables
- All acceptance criteria met (Must Have + Should Have)
- 111/111 tests passing (185% of requirement)
- 5 modular scripts + 2 validation tools + 6 test files
- Comprehensive documentation (architecture + summary)
- Backward compatibility maintained
- Multi-language support (14 languages) verified
- ISMS compliance ensured

🎉 COMPLETE: Modular architecture, comprehensive tests, validation tools, documentation

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor news-article-generator for modularity and validation Refactor news generation into modular architecture with validation tools Feb 14, 2026
Copilot AI requested a review from pethers February 14, 2026 00:42
Copilot AI and others added 3 commits February 14, 2026 00:55
- Removed ~350 lines of embedded CSS from article-template.js
- Moved all article styles to styles.css for maintainability
- Added Economist-style tagline to all generated articles
- Added improved typography with justified text (desktop)
- Added drop cap for first paragraph (Economist flourish)
- Added "Why This Matters" section styling
- Added pull quote styling
- Optimized line length to 66ch for readability
- Improved section dividers
- Added dark mode and print styles
- All articles now use external styles.css
- ✅ Verified: No <style> tags in generated HTML
- ✅ Verified: Economist tagline present
- ✅ Verified: styles.css linked correctly

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
- Created NEWS_ARTICLE_STYLING_GUIDE.md documentation
- Created news/sample-economist-style.html demonstration
- Documented all Economist-style classes and usage
- Documented architecture change (embedded → external CSS)
- Added implementation guide for developers
- Added responsive design notes
- Added accessibility compliance notes
- Added maintenance guidelines
- ✅ Complete reference for future development

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
All generated news articles now:
✅ Use external styles.css (no embedded CSS)
✅ Include Economist-style tagline
✅ Feature drop caps, justified text, optimal line length
✅ Support "Why This Matters" analysis sections
✅ Include elegant pull quotes
✅ Maintain WCAG 2.1 AA accessibility
✅ Responsive design (mobile, tablet, desktop)

Technical achievements:
- Reduced article-template.js by 43% (813→463 lines)
- Added 450+ lines of news styles to styles.css
- Created comprehensive styling guide
- Sample article demonstrating all features
- 100% backward compatible

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title Refactor news generation into modular architecture with validation tools Refactor news articles: move embedded CSS to styles.css, add Economist-style formatting Feb 14, 2026
@pethers pethers requested a review from Copilot February 14, 2026 01:03
@github-actions
Copy link
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

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

This PR implements two major refactorings: (1) moving 350+ lines of embedded CSS from article-template.js to styles.css with Economist-style formatting enhancements, and (2) creating a modular news architecture with 5 specialized article generators, comprehensive test coverage (111 tests), and validation tools.

Changes:

  • CSS refactoring: Removed embedded CSS generation from article-template.js (~350 lines) and added NEWS ARTICLE STYLES section to styles.css (~450 lines) with Economist-style features (drop caps, justified text, special content blocks)
  • Modular architecture: Created 5 new modules in scripts/news-types/ (week-ahead, committee-reports, propositions, motions, breaking-news) with exports, REQUIRED_TOOLS constants, and validation functions
  • Testing: Added 6 test files with 111 total tests covering all modules, cross-reference validation, and Playwright visual validation

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/article-template.js Removed ~350 lines of CSS generation functions, added tagline, now links to external stylesheet only
styles.css Added ~450 lines of NEWS ARTICLE STYLES with Economist-style formatting (lines 8703-9156)
scripts/news-types/*.js 5 new modular article generators with consistent API, exports, and validation
tests/news-types/*.test.js 6 test files with 111 comprehensive tests using vitest and mocks
scripts/validate-cross-references.js New validation module ensuring 3+ data sources and required MCP tools
scripts/validate-articles-playwright.js New Playwright validation for screenshots, accessibility, and RTL
NEWS_ARTICLE_STYLING_GUIDE.md Complete documentation of CSS architecture and Economist-style features
MODULAR_NEWS_ARCHITECTURE.md Architecture documentation for modular news system
news/sample-economist-style.html Sample article demonstrating new styling (no embedded CSS)
news/index.html & index_sv.html Updated news indexes with reordered article dates

Comment on lines 67 to 100
@@ -79,10 +79,10 @@
"position": 3,
"item": {
"@type": "NewsArticle",
"headline": "Ten Committee Reports This Week: Parliament",
"url": "https://riksdagsmonitor.com/news/2026-02-committee-reports-en.html",
"datePublished": "2026-02-13",
"description": "Analysis of parliamentary activity February 5-6, 2026",
"headline": "Sweden",
"url": "https://riksdagsmonitor.com/news/2026-02-parliament-agenda-en.html",
"datePublished": "2026-02-14",
"description": "Eight major propositions in first week, security detention faces opposition, coalition gears up for September election campaign.",
"inLanguage": "en"
}
},
@@ -91,10 +91,10 @@
"position": 4,
"item": {
"@type": "NewsArticle",
"headline": "Sweden",
"url": "https://riksdagsmonitor.com/news/2026-02-parliament-agenda-en.html",
"datePublished": "2026-02-13",
"description": "Eight major propositions in first week, security detention faces opposition, coalition gears up for September election campaign.",
"headline": "Sweden’s Riksdag Enters Spring Recess: A Mid-Session Assessment of the Tidö Government’s Legislative Record",
"url": "https://riksdagsmonitor.com/news/2026-02-13-evening-analysis-en.html",
"datePublished": "2026-02-13T18:00:00.000Z",
"description": "With 2,308 rule violations flagged across 2,494 tracked politicians and 109,259 documents processed, the parliamentary session reveals a government st",
"inLanguage": "en"
}
},
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The dates in the news index files appear to have been reordered (comparing lines 67-100). Articles from "2026-02-13" are shown after articles dated "2026-02-14", which breaks chronological ordering. News indexes should display articles in reverse chronological order (newest first).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current order is correct - articles are in reverse chronological order (newest first): Feb 14 positions 1-3, Feb 13 position 4, Feb 10 position 5. This matches the expected sorting for news indexes.

import {
generateMotions as generateMotionsModule,
REQUIRED_TOOLS as MOTIONS_TOOLS
} from './news-types/breaking-news.js';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Incorrect import: line 46 imports generateMotions and MOTIONS_TOOLS from breaking-news.js, but it should import from motions.js. This bug will cause the motions article type to fail at runtime.

Suggested change
} from './news-types/breaking-news.js';
} from './news-types/motions.js';

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit da5ec79. Changed import from './news-types/breaking-news.js' to './news-types/motions.js'.

@@ -0,0 +1,218 @@
# News Article Generator Refactoring - Completion Summary
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The PR title says "move embedded CSS to styles.css" but the description and code changes show this PR actually includes BOTH CSS refactoring AND modular news architecture refactoring. These are two separate major changes combined in one PR. The PR title should accurately reflect the full scope: "Refactor news articles: move CSS to styles.css and implement modular architecture"

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +23
import { chromium } from 'playwright';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1200, height: 1600 } });

const filePath = join(__dirname, 'news', 'sample-economist-style.html');
await page.goto(`file://${filePath}`);

await page.screenshot({
path: 'economist-style-article.png',
fullPage: true
});

console.log('✅ Screenshot saved: economist-style-article.png');

await browser.close();
})();
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The script take-screenshot.js is placed in the project root directory. For consistency with the project structure, consider moving this to the scripts/ directory where other utility scripts are located.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit da5ec79. Moved take-screenshot.js from root to scripts/ directory.

@pethers
Copy link
Member

pethers commented Feb 14, 2026

@copilot apply changes based on the comments in this thread

- Fixed import bug in generate-news-enhanced.js line 46
  Changed from './news-types/breaking-news.js' to './news-types/motions.js'
  This was causing motions article type to fail at runtime
- Moved take-screenshot.js from root to scripts/ directory
  For consistency with project structure where utility scripts belong

Addresses PR review comments:
- Comment 2806726335: Import correction
- Comment 2806726348: File organization

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Comment on lines +43 to +46
import {
generateMotions as generateMotionsModule,
REQUIRED_TOOLS as MOTIONS_TOOLS
} from './news-types/motions.js';
@github-actions
Copy link
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

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

Copilot reviewed 23 out of 24 changed files in this pull request and generated 7 comments.

* - Article structure validation
*/

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Missing beforeAll import from vitest. The test uses beforeAll on line 38, but it's not imported. Add beforeAll to the import statement from 'vitest'.

Suggested change
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest';

Copilot uses AI. Check for mistakes.
* Unit Tests for Breaking News Article Generation Module
*/

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Missing beforeAll import from vitest. The test uses beforeAll on line 26, but it's not imported. Add beforeAll to the import statement from 'vitest'.

Suggested change
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest';

Copilot uses AI. Check for mistakes.
// Example: Fetch related votes if event involves a vote
if (eventData.voteId) {
console.log(' 🔄 Fetching voting details...');
const votes = await client.searchVoteringar({ punkt: eventData.voteId });
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Method name mismatch: calling client.searchVoteringar() but the MCPClient class only has fetchVotingRecords(). Either rename the call to use fetchVotingRecords() or add a searchVoteringar() method to MCPClient.

Suggested change
const votes = await client.searchVoteringar({ punkt: eventData.voteId });
const votes = await client.fetchVotingRecords({ punkt: eventData.voteId });

Copilot uses AI. Check for mistakes.
// Example: Fetch related speeches
if (eventData.topic) {
console.log(' 🔄 Fetching related speeches...');
const speeches = await client.searchAnforanden({ text: eventData.topic });
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Method name mismatch: calling client.searchAnforanden() but the MCPClient class only has searchSpeeches(). Either rename the call to use searchSpeeches() or add a searchAnforanden() method to MCPClient.

Suggested change
const speeches = await client.searchAnforanden({ text: eventData.topic });
const speeches = await client.searchSpeeches({ text: eventData.topic });

Copilot uses AI. Check for mistakes.
* - Article structure validation
*/

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Missing beforeAll import from vitest. The test uses beforeAll on line 40, but it's not imported. Add beforeAll to the import statement from 'vitest'.

Suggested change
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest';

Copilot uses AI. Check for mistakes.
* Unit Tests for Propositions Article Generation Module
*/

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Missing beforeAll import from vitest. The test uses beforeAll on line 30, but it's not imported. Add beforeAll to the import statement from 'vitest'.

Suggested change
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest';

Copilot uses AI. Check for mistakes.
* Unit Tests for Motions Article Generation Module
*/

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Missing beforeAll import from vitest. The test uses beforeAll on line 30, but it's not imported. Add beforeAll to the import statement from 'vitest'.

Suggested change
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest';

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Member

pethers commented Feb 14, 2026

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
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

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions
Copy link
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
Member

pethers commented Feb 14, 2026

@copilot try again

Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot try again

All issues from the previous review have already been addressed in the current code:

Missing beforeAll imports: All 5 test files already have beforeAll imported from 'vitest' (lines 5, 11, or 12):

  • tests/news-types/committee-reports.test.js:11
  • tests/news-types/breaking-news.test.js:5
  • tests/news-types/week-ahead.test.js:12
  • tests/news-types/propositions.test.js:5
  • tests/news-types/motions.test.js:5

Method name mismatches: scripts/news-types/breaking-news.js already uses the correct method names:

  • Line 72: client.fetchVotingRecords()
  • Line 79: client.searchSpeeches()

The review comments appear to be from an earlier commit state. The code is already correct and ready for merge.

- Updated mock methods from searchVoteringar → fetchVotingRecords
- Updated mock methods from searchAnforanden → searchSpeeches
- Fixed test expectations to match actual implementation
- All test files already have beforeAll imported from vitest

Addresses PR review comments:
- Comment 2806768638: Method name mismatch fixed
- Comment 2806768641: Method name mismatch fixed
- Comments 2806768628, 2806768635, 2806768643, 2806768646, 2806768650: beforeAll already imported in all test files

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
All 541 tests passing successfully:
- Fixed method name mismatches in breaking-news tests
- All vitest imports correctly include beforeAll
- CSS refactoring complete with external styles.css
- Economist-style formatting implemented
- Modular news architecture with 5 specialized generators
- Comprehensive test coverage (111 tests for news types)
- Cross-reference validation working
- No failures detected

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title Refactor news articles: move embedded CSS to styles.css, add Economist-style formatting Refactor news generation: externalize CSS, modularize architecture, add comprehensive testing Feb 14, 2026
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