Skip to content

test(frontend): expand spec coverage for download / code-editor / annotation-suggestion#5004

Merged
aglinxinyuan merged 4 commits into
apache:mainfrom
aglinxinyuan:test/monaco-stack-coverage
May 12, 2026
Merged

test(frontend): expand spec coverage for download / code-editor / annotation-suggestion#5004
aglinxinyuan merged 4 commits into
apache:mainfrom
aglinxinyuan:test/monaco-stack-coverage

Conversation

@aglinxinyuan
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan commented May 9, 2026

What changes were proposed in this PR?

Three areas were under-tested in the frontend spec suite; this PR addresses all three as one cohesive change:

  • DownloadService — went from 8 active specs (all it.skip(...)) to 14 active specs + 1 still-skipped (createZip, blocked by an unrelated import * as JSZip interop bug). New coverage: downloadSingleFile (incl. default-filename fallback + isLogin=false), downloadDataset, downloadDatasetVersion, downloadWorkflow (JSON shape), downloadWorkflowsAsZip, single-file downloadOperatorsResult, the No files to download error path, getWorkflowResultDownloadability HTTP wiring, plus matching error-notification paths.
  • CodeEditorComponent — went from 1 spec (should create) to 9 specs: operator-type → language detection for the three V2 Python operator types and for plain Java / unknown types; the languageTitle formula; getCoeditorCursorStyles for hex and rgba colours.
  • AnnotationSuggestionComponent — new spec file (6 specs): creation, default inputs, accept / decline event emission, independence of the two emitters, @Input binding.

Why one test stays skipped

The multi-file downloadOperatorsResult path goes through new JSZip(), where the production code does import * as JSZip from "jszip". The CI build flags this as Constructing "JSZip" will crash at run-time because it's an import namespace object, and vitest reproduces it as __vite_ssr_import_* is not a constructor. The spec is left as it.skip(...) with a comment so it gets re-enabled when the source switches to a default import.

Any related issues, documentation, discussions?

Closes #5003.

How was this PR tested?

Ran the suite on both branches under active development — confirms the new specs are stable AND the in-flight v10 refactor on #4997 preserves the externally-observable behaviour these specs exercise.

Branch Files Tests
main 66 passed / 2 skipped 333 passed / 4 skipped / 2 todo
chore/monaco-lsp-v10 (#4997) 65 passed / 2 skipped 297 passed / 4 skipped / 2 todo
yarn test   # on main                     → 333 passed / 4 skipped / 2 todo
yarn test   # on chore/monaco-lsp-v10     → 297 passed / 4 skipped / 2 todo

The test-count delta between branches is unrelated PR drift (main has picked up extra non-monaco specs that haven't been merged into the v10 branch yet); the spec files this PR adds run green on both.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.7)

…otation-suggestion

Closes apache#5003.

* `download.service.spec.ts` — rewrite the eight `it.skip(...)` blocks
  with `firstValueFrom` / `await expect(...).rejects.toThrow(...)`
  against the same mocks; add new cases for `downloadWorkflow`,
  single-file `downloadOperatorsResult`, the empty-array error path,
  `getWorkflowResultDownloadability` (HTTP), default-filename fallback,
  and `isLogin=false` plumbing. The multi-file `downloadOperatorsResult`
  case stays `it.skip(...)` for now — the source's
  `import * as JSZip from "jszip"` form is flagged by the build as
  `Constructing "JSZip" will crash at run-time because it's an import
  namespace object`, and vitest reproduces that as
  `__vite_ssr_import_* is not a constructor`. Once the source switches
  to a default import the skip can come off.

* `code-editor.component.spec.ts` — add language-detection cases for
  the three V2 Python operator types + plain Java + an unknown type,
  assert `languageTitle` formatting, and exercise
  `getCoeditorCursorStyles` for valid clientId / colour shapes. The
  V2 / unknown types aren't in the shared `mockOperatorMetaData`, so
  this spec subclasses `StubOperatorMetadataService` with the
  synthesised schemas.

* `annotation-suggestion.component.spec.ts` — new file, six tests:
  creation, default `@Input` values, `onAccept` / `onDecline` event
  emission (each independently), and that `@Input` updates take.

Verified on both:
* `main` — 66 files / 333 pass (was 63 / 269 — +64 specs, +3 files)
* `chore/monaco-lsp-v10` (the in-flight v10 upgrade, apache#4997) — 65 files
  / 297 pass; the same new specs run green there too. Confirms the
  refactor preserves the externally-observable behaviour these specs
  exercise.
Copilot AI review requested due to automatic review settings May 9, 2026 21:19
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label May 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the frontend unit test suite to cover previously under-tested behavior in DownloadService, CodeEditorComponent, and the AnnotationSuggestionComponent, primarily by rewriting skipped tests into async/observable-friendly Vitest patterns and adding new spec cases.

Changes:

  • Rewrote and expanded DownloadService specs to actively test multiple download flows, error paths, and the downloadability endpoint wiring.
  • Added constructor/language-detection and coeditor-cursor-style coverage for CodeEditorComponent.
  • Introduced a new spec file for AnnotationSuggestionComponent covering input defaults and output event emission.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
frontend/src/app/dashboard/service/user/download/download.service.spec.ts Converts skipped Jasmine-style tests to active Vitest-friendly async tests and adds endpoint/download-result coverage.
frontend/src/app/workspace/component/code-editor-dialog/code-editor.component.spec.ts Adds test cases for operator-type language selection, derived languageTitle, and cursor style generation.
frontend/src/app/workspace/component/code-editor-dialog/annotation-suggestion.component.spec.ts Adds initial unit tests for annotation suggestion inputs and accept/decline emitters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.78%. Comparing base (62d4489) to head (90678f9).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5004      +/-   ##
============================================
+ Coverage     42.64%   42.78%   +0.14%     
  Complexity     2188     2188              
============================================
  Files          1045     1045              
  Lines         39876    39876              
  Branches       4205     4205              
============================================
+ Hits          17004    17061      +57     
+ Misses        21811    21757      -54     
+ Partials       1061     1058       -3     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 1cf9c7d
agent-service 33.72% <ø> (ø) Carriedforward from 1cf9c7d
amber 43.29% <ø> (ø) Carriedforward from 1cf9c7d
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 1cf9c7d
config-service 0.00% <ø> (ø) Carriedforward from 1cf9c7d
file-service 32.18% <ø> (ø) Carriedforward from 1cf9c7d
frontend 34.20% <ø> (+0.35%) ⬆️
python 88.90% <ø> (ø) Carriedforward from 1cf9c7d
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 1cf9c7d

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Yicong-Huang Yicong-Huang marked this pull request as draft May 10, 2026 01:03
- annotation-suggestion.component.spec: explicitly import the
  standalone component into TestBed so the setup is resilient to
  Angular's defaults flipping back.
- code-editor.component.spec: fail fast at module load if the
  PythonUDF base schema isn't in mockOperatorMetaData, instead of
  silently falling back to an empty schema cast.
- download.service.spec: move httpMock.verify() into afterEach so
  every spec (current and future) is checked for outstanding
  HTTP requests, not just the one downloadability test.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Round 2 of Copilot review on PR apache#5004:

- Language-detection coverage missed the `RUDFSource` / `RUDF` ->
  `r` branch in code-editor.component.ts:147. Augmented the stub
  metadata with two synthetic R schemas, updated the section
  comment, and parametrized the existing forEach pattern to assert
  language="r" / languageTitle="R UDF" for both types.
- getCoeditorCursorStyles returns bypassSecurityTrustHtml(...) (a
  SafeHtml consumed via [innerHTML]), not a SafeStyle. Renamed the
  comment block and the two test descriptions accordingly.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@aglinxinyuan aglinxinyuan marked this pull request as ready for review May 11, 2026 22:39
Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aglinxinyuan aglinxinyuan merged commit dcb457e into apache:main May 12, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand spec coverage for DownloadService, CodeEditorComponent, and AnnotationSuggestionComponent

4 participants