fix(js-cypress): stop tests depending on the apify.com marketing site#808
Open
l2ysho wants to merge 1 commit into
Open
fix(js-cypress): stop tests depending on the apify.com marketing site#808l2ysho wants to merge 1 commit into
l2ysho wants to merge 1 commit into
Conversation
The js-cypress template's example specs hit the live apify.com marketing site: first-spec visited `/` and second-spec visited `/store`, clicked `.ActorStoreItem-title` and asserted a redirect. This made the template's CI hostage to the marketing site — React hydration errors (e.g. minified #418), CSS class renames, and slow Windows-runner renders all broke the Node template matrix even though the template itself was unchanged (see run 27280506506). Repoint the demo at https://example.com (IANA/RFC-2606 reserved for documentation — stable markup, no app JS), and harden the specs: - first-spec: assert the stable `Example Domain` heading. - second-spec: select the outbound link by `href*="iana.org"` instead of by visible text (robust to copy changes) and assert visibility, avoiding a cross-origin click. - support/e2e.js: swallow page-level uncaught exceptions so a broken JS handler on the visited page can't auto-fail the demo (documented, with a link to the React error docs). - Update baseUrl default/prefill in cypress.config.js, src/main.js and input_schema.json, and document the new target + how to override it via the `baseUrl` input in the README. The template still demonstrates Cypress + Apify SDK wiring end to end. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
js-cypresstemplate's example specs hit the live apify.com marketing site, so the template's CI broke whenever that site changed — even though the template itself was untouched:first-spec.cy.js→cy.visit('/'), assertedcy.contains('div', 'Apify')second-spec.cy.js→cy.visit('/store'), clicked.ActorStoreItem-titlecontainingWeb Scraper, asserted a redirect tohttps://apify.com/apify/web-scraperThe harness runs these for real:
js-cypressis not inSKIP_TESTS, andcheckTemplateRun()(test/templates.test.js:156) executesapify run, which runssrc/main.js→cypress.run()against the configured site.Observed failure on PR #806 / run 27280506506 (windows-latest, node 24):
.ActorStoreItem-titleselector timed out after 30s.It's demo code — it shouldn't depend on production marketing markup the template repo doesn't control.
Fix
Repoint the demo at
https://example.com(IANA / RFC-2606 reserved for documentation — stable markup, no app JS) and harden the specs:Example Domainheading.a[href*="iana.org"]instead of by visible text, and asserts visibility — no cross-origin click. (While testing I found example.com now serves aLearn morelink variant rather than the oldMore information...; the attribute selector is robust to that copy churn.)cypress/support/e2e.js→Cypress.on('uncaught:exception', () => false), documented with a link to the React error docs, so a broken JS handler on the visited page can't auto-fail the demo.baseUrldefault/prefill incypress.config.js,src/main.js, and.actor/input_schema.json, and documented the new target + how to override it via thebaseUrlinput in the README.Scope is limited to
templates/js-cypress/**; the Apify SDK + Cypress wiring (input schema, dataset/KVS result storage, video recording) is unchanged, so the template still teaches the same thing.Verification
Done locally on the final files (in an isolated copy, mirroring
prepareActor'sfs.cpSyncto a tmp dir):npm install,npm run lint,npm run format:check— all pass.node --checkon every touched JS file; JSON files parse.<h1>Example Domain</h1>and a link withhref*="iana.org") exist in the liveexample.comHTML across its served variants.The actual headless browser run can't execute in my sandbox (no Xvfb / no root). Relying on this PR's CI matrix (ubuntu-24.04 + windows-latest, Node 22/24) for the cross-OS browser run — please confirm two consecutive green runs, with attention to the Windows job that was flaky on timing.
🤖 Generated with Claude Code