Repository navigation
test: add Jest test suite, PR test workflow and testing guide - #26
Merged
Merged
Conversation
- 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
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.
Closes #25
What
Automated tests: Jest + jsdom, 47 tests, 98% line coverage
taskpane.htmland runtaskpane.tsagainst:test/helpers/office.ts), with asynchronous callbacks like the real API, and<ezp-printing>(test/helpers/ezpPrinting.ts), which records every property write so ordering can be asserted.<ezp-printing>defined late or never (15 s timeout)filedatawatcher resetjavascript:)whenDefinedwait,filenamebeforefiledata, thefiledatareset, and the dialog status check.CI:
.github/workflows/test.ymlnpm run lint,npm run typecheck,npm run test:coverageandnpm run buildon every pull request, on Node 18 like the release build.node.js.ymlis unchanged.Documentation:
TESTING.md(linked from the README)defaultscommands, cache clearing), and a 12-case matrix over Word/Excel × Windows/Mac/web.Small source change
authRedirect.tsnow exportsisAllowedAuthUri,resultMessageandhandleAuthRedirect(with injectable navigation) so it can be tested.Tooling
test,test:coverageandtypecheck.test/tsconfig.json, an ESLint override for test files, and a roottsconfig.jsonthat excludestest/andjest.config.js. Before that,tsc -p .picked up Jest's typings throughallowJs.coverage/is gitignored.jest@29,jest-environment-jsdom@29,babel-jest@29,@babel/preset-env@7,@types/jest@29.@babel/preset-envrequires Babel core 7.29 (from 7.21), plus minor transitive bumps.npm auditagainstmain: no new advisories; 4 fewer, including the critical@babel/traverseone.Verification
npm ci, then lint, type check (app and tests), 47/47 tests and production build: all pass locally.Note on #16
This content was first pushed to
feature/office-api-review-fixesafter #16 had already been merged. That commit (f0242b4) is not onmain, and that branch can be deleted. This PR carries the same content, rebuilt on currentmain.🤖 Generated with Claude Code
https://claude.ai/code/session_01CKAReNgzxtfL9PsLuthKK1
Generated by Claude Code