Skip to content

Frontend: improvements to code coverage of Typescript code#1330

Open
gusthoff wants to merge 16 commits intoAdaCore:mainfrom
gusthoff:topic/infrastructure/yarn/refactoring/20260322/code_coverage
Open

Frontend: improvements to code coverage of Typescript code#1330
gusthoff wants to merge 16 commits intoAdaCore:mainfrom
gusthoff:topic/infrastructure/yarn/refactoring/20260322/code_coverage

Conversation

@gusthoff
Copy link
Collaborator

Line coverage is now 100%.

gusthoff and others added 16 commits March 22, 2026 23:04
The rejectedWith assertions were missing await and chaiAsPromised was
not registered. Without await the assertions passed regardless of
whether the promise was actually rejected, giving false confidence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The new error-throwing behavior of getUnparsedSwitches was not covered
by any tests. Add a describe block with three cases: valid JSON,
missing keys returning empty arrays, and invalid JSON throwing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nyc uses Istanbul require-hook instrumentation which is bypassed when
mocha runs with --loader=ts-node/esm, causing 0% coverage reports.
c8 uses V8's built-in coverage which works natively with ES modules.

- Replace nyc + @istanbuljs/nyc-config-typescript + istanbul-lib-instrument
  with c8
- Update 'cover' script: nyc -> c8
- Translate coverage config from 'nyc' to 'c8' key (same thresholds)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- resource.ts, server-types.ts: pure TypeScript type/interface
  declarations that compile to no executable code
- sandbox-redirect.ts: browser-only sandbox gate relying on prompt(),
  alert(), and window.location

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reflects removal of nyc and its 52 transitive dependencies, addition
of c8 and its 26 transitive dependencies, and minor version drift in
unrelated packages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover lines 225-262 of download.ts: non-SPARK and SPARK zip generation
(including filename, source file, .gpr, .adc, _spark.gpr, _spark.adc).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Invalid switches JSON on run button click (lines 491-494)
- stdout from a file not present in viewMap (lines 562-565)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…get.spec.ts

- Tab-setting change: revert on cancel, apply+reload on confirm (lines 160-176)
- Theme-setting change: revert on cancel, apply dark+reload on confirm (lines
  191-207, 417-418)
- Compiler switches: mutual exclusion, help-info click, help button (lines
  362-406)
- Download button: successful download and invalid-JSON error path (lines
  221-235)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…c.ts

- LabWidget.resetEditors resets both output area and lab container (lines
  700-702)
- Malformed widget: widgetFactory error handling for a widget with no files
  (lines 79-81, 732-745)
- Multi widget: dep-handling when two widgets share the same project name
  (lines 64-69); new multi.rst fixture added to tests/rst/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removing the `window.location.reload` mock assignment, which throws a
TypeError in strict-mode ESM before the event is dispatched, leaving
lines 161-171, 192-202, and 417-418 of widget.ts uncovered. Replace
with a try-catch around triggerEvent() instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cover editor.ts lines 110-111 (C_CPP mode branch in addSession) and
lines 89-92 (non-tabbed editors loop in refresh(false)) which were
previously uncovered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a no_button RST widget (Test.CodeBlockInfo) with pre-baked run.log
test data so make site-testing generates a page with code-block-info
elements. Pass SRC_TEST_DIR to sphinx-build in the site-testing target
so code_block_info.py picks up the test data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…4-249

Load code_block_info.html (generated by make site-testing with SRC_TEST_DIR)
and assert that the code-block-info output element is populated from the
widget's hidden code-block-info div.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The private serverAddress() method was never called anywhere in the
codebase, making it dead code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- editor.spec.ts: restore session to resource.basename after the C_CPP
  mode test so that the subsequent #reset() tests operate on the right
  session
- download.spec.ts: convert Blob to ArrayBuffer via .arrayBuffer() before
  passing to JSZip.loadAsync(), working around the Blob type mismatch in
  the Node.js test environment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ESLint 9 dropped support for eslintConfig in package.json; add
eslint.config.js with the equivalent flat config. Also fix a line that
was too long in widget.ts (line 394) and remove a now-redundant
eslint-disable directive in editor.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gusthoff gusthoff force-pushed the topic/infrastructure/yarn/refactoring/20260322/code_coverage branch from b55745b to cb8ea8b Compare March 22, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant