Skip to content

test: add Jest test suite, PR test workflow and testing guide - #26

Merged
btrappe merged 1 commit into
mainfrom
feature/automated-tests
Oct 3, 2026
Merged

btrappe merged 1 commit into
mainfrom
feature/automated-tests

Conversation

@btrappe

@btrappe btrappe commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Closes #25

What

Automated tests: Jest + jsdom, 47 tests, 98% line coverage

  • The tests load the real taskpane.html and run taskpane.ts against:
    • a fake Office.js (test/helpers/office.ts), with asynchronous callbacks like the real API, and
    • a fake <ezp-printing> (test/helpers/ezpPrinting.ts), which records every property write so ordering can be asserted.
  • Covered:
    • start-up, signed in and signed out
    • <ezp-printing> defined late or never (15 s timeout)
    • multi-slice PDF export: order, closed once, 9 MB document, bytes > 127
    • every error path shows a message instead of an endless spinner
    • Word on the web, Excel on the web, PowerPoint, legacy Edge
    • Excel empty sheet; file name from a local path, a SharePoint URL or an unsaved document
    • reprint, including the filedata watcher reset
    • sign-in dialog: start URL, sizes, code, error, non-JSON message, user close 12006, open failure; single-use code cleared
    • redirect page and its open-redirect guard (look-alike hosts, userinfo trick, javascript:)
    • logout and German texts
  • The tests catch real regressions.

CI: .github/workflows/test.yml

  • Runs npm run lint, npm run typecheck, npm run test:coverage and npm run build on every pull request, on Node 18 like the release build.
  • Uploads the coverage report as an artifact.
  • Has read-only permissions and never deploys. node.js.yml is unchanged.

Documentation: TESTING.md (linked from the README)

Small source change

  • authRedirect.ts now exports isAllowedAuthUri, resultMessage and handleAuthRedirect (with injectable navigation) so it can be tested.
  • Runtime behaviour is unchanged.

Tooling

  • npm scripts test, test:coverage and typecheck.
  • test/tsconfig.json, an ESLint override for test files, and a root tsconfig.json that excludes test/ and jest.config.js. Before that, tsc -p . picked up Jest's typings through allowJs.
  • coverage/ is gitignored.
  • New dev dependencies: jest@29, jest-environment-jsdom@29, babel-jest@29, @babel/preset-env@7, @types/jest@29.
  • The lockfile stays on v2 and the node-forge override from chore(deps): override node-forge to >=1.4.0 (Dependabot) #15 is kept.
  • @babel/preset-env requires Babel core 7.29 (from 7.21), plus minor transitive bumps.
  • npm audit against main: no new advisories; 4 fewer, including the critical @babel/traverse one.

Verification

  • Clean npm ci, then lint, type check (app and tests), 47/47 tests and production build: all pass locally.
  • The new workflow should run on this PR. It's the first time it runs on GitHub, so please check that it shows up.

Note on #16

This content was first pushed to feature/office-api-review-fixes after #16 had already been merged. That commit (f0242b4) is not on main, and that branch can be deleted. This PR carries the same content, rebuilt on current main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CKAReNgzxtfL9PsLuthKK1


Generated by Claude Code

- Jest + jsdom tests (47) for the task pane and the sign-in redirect page,
  running against the real taskpane.html with a fake Office.js
  (test/helpers/office.ts) and a fake <ezp-printing> element
  (test/helpers/ezpPrinting.ts). Covers start-up, late/missing ezeep-js
  component, multi-slice PDF export, error paths, Word on the web,
  sign-in dialog, open-redirect guard, logout, reprint and localisation.
  98% line coverage. Checked against the pre-#16 code: 29 of 30 task pane
  tests fail there; reverting each key fix individually fails at least
  one test.
- authRedirect.ts: export isAllowedAuthUri/resultMessage/handleAuthRedirect
  with injectable navigation so the page can be tested; behaviour unchanged.
- .github/workflows/test.yml: lint, typecheck, tests with coverage and
  build on pull requests (Node 18). Never deploys; node.js.yml unchanged.
- TESTING.md: how the harness works, coverage map, limits, and a manual
  end-to-end test plan with a Word/Excel x Win/Mac/web matrix. README links it.
- Tooling: npm scripts test, test:coverage, typecheck; test/tsconfig.json;
  ESLint override for test files; tsconfig excludes test and jest.config.js;
  coverage/ ignored. Dev deps jest 29, jest-environment-jsdom, babel-jest,
  @babel/preset-env, @types/jest (lockfile v2 kept, node-forge override
  kept; Babel core 7.21 -> 7.29 as required by preset-env, which also
  clears 4 npm audit advisories incl. critical @babel/traverse).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CKAReNgzxtfL9PsLuthKK1
@btrappe
btrappe merged commit 8fc373d into main Oct 3, 2026
1 check passed
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.

Add automated tests and PR CI for the add-in

1 participant