Skip to content

Fix Cypress failures: stub replag script, format ZIM date in UTC#1214

Merged
audiodude merged 1 commit into
mainfrom
cypress-fix
Jul 17, 2026
Merged

Fix Cypress failures: stub replag script, format ZIM date in UTC#1214
audiodude merged 1 commit into
mainfrom
cypress-fix

Conversation

@audiodude

Copy link
Copy Markdown
Member

Problem

CI's frontend-cypress job started failing on every spec (13 of 13, 62 failures) with:

TypeError: Failed to execute 'setHTML' on 'Element': Failed to read the 'sanitizer' property from 'ElementSetHTMLOptions': Failed to convert value to 'Sanitizer' — at https://tools-static.wmflabs.org/replag-embed/replag-embed.js:41

The replag banner script is fetched live from wmflabs on every page load (index.html). An upstream change to it (it now passes a new-spec Sanitizer config to Element.setHTML()) throws in Cypress's bundled Electron browser, and Cypress fails any test whose app throws an uncaught exception. Nothing in this repo changed — main was green two days before the same code went red.

Fixes

  • Stub replag-embed.js in cypress/support/e2e.js: a global cy.intercept serves an empty body for the script, so tests no longer execute third-party code fetched over the network (also removes a flakiness/external-dependency liability). No test asserts on the banner. Real browsers are unaffected.
  • Format the ZIM next-generation date in UTC (ZimFile.vue): found while re-running the suite locally. The backend sends a date-only YYYY-MM-DD string, which new Date() parses as UTC midnight, but it was formatted in the viewer's local timezone — so the zimFile spec's "shows the next generation date" test fails in any timezone behind UTC, and real users west of UTC see the previous day. Adding timeZone: 'UTC' to toLocaleDateString fixes both. (This never failed in CI, which runs in UTC.)

Testing

Full Cypress suite run locally against the dev stack, twice: 193/193 passing across all 13 specs.

🤖 Generated with Claude Code

The replag banner script is fetched live from wmflabs on every page
load; an upstream change made it throw in Cypress's Electron browser,
failing all 13 specs. Stub it out in the support file, since no test
asserts on the banner.

Also fix a timezone bug exposed while re-running the suite: the ZIM
next-generation date (a date-only YYYY-MM-DD string) was parsed as UTC
midnight but formatted in local time, showing the previous day to
viewers in timezones behind UTC. Format it in UTC.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@audiodude
audiodude enabled auto-merge July 17, 2026 12:54
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.64%. Comparing base (cb7b6f4) to head (4d38e8e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1214   +/-   ##
=======================================
  Coverage   92.64%   92.64%           
=======================================
  Files          78       78           
  Lines        4987     4987           
=======================================
  Hits         4620     4620           
  Misses        367      367           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@audiodude
audiodude added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit 605d218 Jul 17, 2026
7 checks passed
@audiodude
audiodude deleted the cypress-fix branch July 17, 2026 13:04
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.

1 participant