Skip to content

Add GitHub Actions CI and make the puppeteer suite run headless with no local server - #771

Merged
joedolson merged 6 commits into
ableplayer:developfrom
blogcastAI:upstream/headless-tests
Aug 25, 2026
Merged

joedolson merged 6 commits into
ableplayer:developfrom
blogcastAI:upstream/headless-tests

Conversation

@blogcastAI

Copy link
Copy Markdown

Follow-up to #770 (includes its lint commit so CI starts green — happy to rebase once that merges).

What

Two changes that make the existing test suite protective:

1. GitHub Actions CI (.github/workflows/ci.yml) — the repo ships ESLint + Jest configs but no CI. Four jobs on every push/PR: ESLint, Jest jsdom (55 tests), Jest puppeteer headless (26 tests), and a Grunt + Rollup build with artifact existence checks (build output never committed, per contributing.md). Node 22, npm cache, GITHUB_TOKEN restricted to contents: read.

2. Headless, serverless puppeteer suitenpm test currently fails 26/81 out of the box: validate.test.cjs expects a manually-started server on localhost:8000, and jest-puppeteer.config.cjs sets headless: false (needs a display).

  • jest-puppeteer.config.cjs: headless by default, HEADFUL=1 to watch while debugging, --no-sandbox under CI.
  • validate.test.cjs: request interception replaces the server — the page navigates to http://ableplayer.test/ fulfilled from memory. A real http(s) origin is still needed because isProtocolSafe() resolves relative URLs against window.location.origin (opaque on about:blank), but no server process.

Verification

Why

contributing.md calls test-suite expansion a high priority — CI plus a suite that runs unattended is the prerequisite that makes new tests protective rather than advisory. We run Able Player v5 in production and plan further contributions (YouTube issue cluster #736/#670/#606 next).

🤖 Generated with Claude Code

- ableplayer-base.js: the descriptionsAudible else-if duplicated the first
  condition (no-dupe-else-if), so the documented singular spelling
  data-description-audible was never honored. Read the singular attribute
  (options.descriptionAudible ?? data.descriptionAudible) in the second
  branch, matching the existing comment's intent.
- dialog.js: import AblePlayer for the AblePlayer.getActiveDOMElement()
  call (no-undef).
- dragdrop.js: remove unused thisObj locals in handleWindowButtonClick and
  handleMenuChoice (no-unused-vars); document the intentionally-empty
  Space/Enter branch (no-empty).
- preference.js: remove the write-only $thisLabel variable and a dead
  $thisField assignment (no-unused-vars, no-useless-assignment).

npm run lint: 0 problems. jsdom test suites: 55/55 pass. Build artifacts
intentionally omitted per contributing.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
blogcastAI and others added 4 commits August 9, 2026 21:57
Per review: the singular `data-description-audible` alternate code
path was added in the feature's original commit as protection against
misspelling the attribute, but was never documented and never the
standard form. Eliminate the alternate condition rather than keep a
lint-clean version of it; `data-descriptions-audible` (plural) is the
one supported spelling.
The repository ships Jest and ESLint configs but has no CI, so
regressions surface only when someone runs the tools locally. This
workflow runs three jobs on every push and pull request:

- ESLint over scripts/ (npm run lint)
- the jsdom Jest project (55 tests; the puppeteer project needs a
  localhost:8000 demo server and a headed browser, so it is excluded
  for now)
- a Grunt + Rollup build with an artifact existence check, without
  committing build output (per contributing.md)

Node 22 with npm cache; read-only GITHUB_TOKEN permissions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
validate.test.cjs previously required a manually started server on
localhost:8000 and a headed browser (headless: false), so npm test
always failed 26 tests out of the box and the suite could not run in CI.

- jest-puppeteer.config.cjs: headless by default; HEADFUL=1 restores a
  visible browser for debugging; pass --no-sandbox in CI containers.
- validate.test.cjs: navigate to an intercepted http://ableplayer.test/
  origin fulfilled from memory instead of localhost:8000. A real http(s)
  origin is still required because isProtocolSafe() resolves relative
  URLs against window.location.origin (opaque on about:blank), but no
  server process is needed.
- ci.yml: new test-browser job runs the puppeteer project (after
  npm run build, which produces build/test/validate.umd.js).

npm test now passes 81/81 locally with zero setup. Build artifacts
intentionally omitted per contributing.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- The jsdom project's webvtt.test.cjs loads build/test/webvtt.umd.js, so
  without a build step the job exercised the committed bundle instead of
  the source under review. Build first, matching the puppeteer job.
- Cancel superseded runs on the same ref so a force-push to an open pull
  request does not leave stale jobs queued.
- Give every job an explicit timeout; the default is six hours, which a
  hung headless page load would otherwise occupy.
- jest-puppeteer: compare HEADFUL explicitly so HEADFUL=0 stays headless
  instead of launching a visible browser (any non-empty string is truthy).
@blogcastAI
blogcastAI force-pushed the upstream/headless-tests branch from 19d4f0b to adb378a Compare August 10, 2026 03:58
…esting docs

- Only the puppeteer job launches a browser, but puppeteer's postinstall
  downloads a browser during npm ci in every job, and setup-node's npm
  cache does not cover that directory. Set PUPPETEER_SKIP_DOWNLOAD on the
  lint, jsdom and build jobs.
- contributing.md described adjusting the test runner's target URL and a
  default of http://localhost:8000. The suite now intercepts its own
  navigation and needs no server, so document that, and mention HEADFUL=1
  for watching the browser while debugging.
blogcastAI added a commit to blogcastAI/ableplayer that referenced this pull request Aug 10, 2026
…#773 review fixes into develop

# Conflicts:
#	.github/workflows/ci.yml
#	e2e/a11y.spec.js
#	e2e/keyboard.spec.js
#	e2e/serve.mjs
#	jest-puppeteer.config.cjs
#	playwright.config.js
@joedolson
joedolson merged commit 44e31c6 into ableplayer:develop Aug 25, 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