Skip to content

test(frontend): call fixture.detectChanges() in three dashboard component specs#5181

Merged
Yicong-Huang merged 1 commit into
apache:mainfrom
Yicong-Huang:test/detect-changes-fix
May 24, 2026
Merged

test(frontend): call fixture.detectChanges() in three dashboard component specs#5181
Yicong-Huang merged 1 commit into
apache:mainfrom
Yicong-Huang:test/detect-changes-fix

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang commented May 24, 2026

What changes were proposed in this PR?

list-item, share-access, and user-dataset-file-renderer each constructed a ComponentFixture via TestBed.createComponent but never triggered change detection. The template's creation pass therefore never ran, the source-map-attributed v8 coverage stayed at 0 % for the corresponding .component.html, and the specs still passed green.

Adds fixture.detectChanges() to each:

  • list-item.component.spec.ts — seeds component.entry with a fully-formed workflow entry in beforeEach before calling detectChanges(). The component's entry getter throws when _entry is undefined and initializeEntry() (called from ngOnChanges) reads entry.workflow.isOwner, accessibleUserIds, and counters, so a minimal stub is not enough. Each it block continues to overwrite component.entry and assert on confirm-method behavior; no existing assertions change.
  • share-access.component.spec.tsdetectChanges() lives in the setupComponent helper so every test case picks it up.
  • user-dataset-file-renderer.component.spec.tsdetectChanges() in beforeEach after createComponent. ngOnInit -> reloadFileContent hits the unsupported-MIME bail with the default empty filePath, so no service calls fire.

Any related issues, documentation, discussions?

Closes #5180.

How was this PR tested?

yarn ng test --watch=false --include=… against the three affected specs locally: 3 files, 10 tests, all pass. yarn format:ci clean.

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

Generated-by: Claude Opus 4.7

…nent specs

`list-item`, `share-access`, and `user-dataset-file-renderer` each
constructed a `ComponentFixture` but never triggered change detection,
so the template's creation pass never ran and the corresponding
`.component.html` files reported 0 % coverage despite the specs
passing green. This violates the golden rule documented in
`frontend/AGENTS.md` and `frontend/TESTING.md`.

Add `fixture.detectChanges()` to each:

- `list-item`: in `beforeEach`, after seeding `component.entry` with a
  fully-formed workflow entry. The component's `entry` getter throws
  when `_entry` is undefined, and `initializeEntry()` (called from
  `ngOnChanges`) reads `entry.workflow.isOwner`, `accessibleUserIds`,
  and counters, so a minimal stub is insufficient. Each test below
  still overwrites `component.entry` and asserts on confirm-method
  behavior — no behavior change to existing assertions.
- `share-access`: inside the `setupComponent` helper, so every test
  case picks it up.
- `user-dataset-file-renderer`: in `beforeEach` after `createComponent`.
  `ngOnInit -> reloadFileContent` hits the unsupported-MIME bail with
  the default empty `filePath`, so no service calls fire.

Closes apache#5180
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label May 24, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.91%. Comparing base (b228d51) to head (97d5179).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5181      +/-   ##
============================================
+ Coverage     43.71%   43.91%   +0.19%     
  Complexity     2218     2218              
============================================
  Files          1049     1049              
  Lines         40578    40578              
  Branches       4327     4327              
============================================
+ Hits          17739    17818      +79     
+ Misses        21733    21640      -93     
- Partials       1106     1120      +14     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from b228d51
agent-service 33.76% <ø> (ø) Carriedforward from b228d51
amber 44.17% <ø> (ø) Carriedforward from b228d51
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from b228d51
config-service 0.00% <ø> (ø) Carriedforward from b228d51
file-service 32.18% <ø> (ø) Carriedforward from b228d51
frontend 35.66% <ø> (+0.48%) ⬆️
python 90.50% <ø> (ø) Carriedforward from b228d51
workflow-compiling-service 56.81% <ø> (ø) Carriedforward from b228d51

*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 requested a review from mengw15 May 24, 2026 18:39
Copy link
Copy Markdown
Contributor

@mengw15 mengw15 left a comment

Choose a reason for hiding this comment

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

LGTM

@Yicong-Huang Yicong-Huang added this pull request to the merge queue May 24, 2026
Merged via the queue into apache:main with commit afb29e7 May 24, 2026
21 checks passed
@Yicong-Huang Yicong-Huang deleted the test/detect-changes-fix branch May 24, 2026 20:17
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.

Three dashboard component specs never call fixture.detectChanges()

3 participants