Skip to content

test(frontend): render the hub search result with its real children - #7661

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/hub-search-result-render
Aug 15, 2026
Merged

test(frontend): render the hub search result with its real children#7661
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/hub-search-result-render

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

hub-search-result.component.html reported 0 of 23 lines, 0 of 8 branches and 0 of 3 functions covered, behind a 17-test spec. That is the attribution loss from #7458, not an untested template: the spec swaps its four children for same-selector stubs via TestBed.overrideComponent, and any override re-JITs the component from its decorator metadata, leaving the recompiled template with no source map back to the .html.

Adds a describe block that renders the component with its real children:

Before After
lines 0/23 23/23
branches 0/8 8/8
functions 0/3 3/3

The block keeps its own TestBed, so the 17 existing tests keep their stubs and assertions untouched. Same remedy as merged PRs #7535, #7627 and #7629 — this is the last of the six templates #7458 identified, bar workspace and the user-project one that the project-feature removal deletes.

Covered: the real children resolving rather than the stub selectors, the dataset-only view toggle and its absence for workflows, which toggle button is highlighted, the sort options shown and hidden per search type, the sort handler's two halves, the card template and its viewMode guard, and the three inputs handed to the results list.

Verification

23 mutations applied and reverted, production diff empty each time.

Two then turned out to survive, and the cause is worth recording. The view-toggle helper read each button as classList.contains("ant-btn-primary"), which pins a ternary's true leg only — so changing the false leg from 'default' to 'dashed' or 'link' shipped green. The build's own mutations replaced the whole ternary with a constant, which flips the primary leg and dies, which is exactly why the gap was missed.

The helper now reads the type by name, matched against the nzType names rather than any ant-btn-* class, since the buttons also carry ant-btn-icon-only — my first attempt at the fix picked that modifier up and failed loudly, which is how I found it.

All three are now red, each on the intended test rather than merely somewhere in the suite:

Mutation Result Failing test
list button's false leg → dashed red "highlights whichever view-toggle button matches…"
card button's false leg → link red same
list button collapsed to a constant (control) red same

Deliberately not included

A static nzTheme="outline" attribute carries no lcov line and is not asserted.

No production file is touched.

Any related issues, documentation, discussions?

Closes #7660

How was this PR tested?

npx ng test --watch=false --include="**/hub-search-result.component.spec.ts"
 Test Files  1 passed (1)
      Tests  27 passed (27)

10 new on top of the existing 17. Coverage re-measured by reverting the spec, running with --coverage, and restoring. yarn format:ci passes.

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

Generated-by: Claude Code (Opus 5)

hub-search-result.component.html reported 0 of 23 lines, 0 of 8 branches
and 0 of 3 functions covered, behind a 17-test spec. That is the
attribution loss recorded in apache#7458: the spec swaps its four children for
same-selector stubs via TestBed.overrideComponent, and any override
re-JITs the component from its decorator metadata, so the recompiled
template has no source map back to the .html.

Adds a describe block that renders the component with its real children,
taking the template to 23/23 lines, 8/8 branches and 3/3 functions. It
keeps its own TestBed, so the existing suite and its stubs are untouched.

The view-toggle helper reads each button's nzType by name rather than
testing for ant-btn-primary. A boolean read pins only the true leg, so
changing the false leg from 'default' to 'dashed' or 'link' shipped green
until this was corrected.

No production file is touched.
Copilot AI lite review requested due to automatic review settings August 14, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.19%. Comparing base (324278e) to head (29dc150).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7661      +/-   ##
============================================
+ Coverage     90.14%   90.19%   +0.05%     
  Complexity     4417     4417              
============================================
  Files          1174     1174              
  Lines         46964    46964              
  Branches       5262     5262              
============================================
+ Hits          42334    42360      +26     
+ Misses         2876     2850      -26     
  Partials       1754     1754              
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 324278e
agent-service 98.62% <ø> (ø) Carriedforward from 324278e
amber 86.74% <ø> (ø) Carriedforward from 324278e
computing-unit-managing-service 72.46% <ø> (ø) Carriedforward from 324278e
config-service 77.31% <ø> (ø) Carriedforward from 324278e
file-service 68.90% <ø> (ø) Carriedforward from 324278e
frontend 91.57% <ø> (+0.12%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from 324278e
pyamber 97.57% <ø> (ø) Carriedforward from 324278e
workflow-compiling-service 57.89% <ø> (ø) Carriedforward from 324278e

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

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

frontend/src/app/hub/component/hub-search-result/hub-search-result.component.spec.ts:515

  • The new suite’s afterEach removes the .cdk-overlay-container element from the document. Most frontend specs instead clear its contents (e.g., dashboard/component/user/search-results/search-results.component.spec.ts:98, dashboard/component/user/user-project/user-project.component.spec.ts:116), which avoids breaking later tests that expect the container element to exist. Consider clearing innerHTML instead of removing the node, and similarly avoid clearing all of localStorage here (remove only VIEW_MODE_STORAGE_KEY).
  afterEach(() => {
    fixture?.destroy();
    localStorage.clear();
    document.querySelectorAll(".cdk-overlay-container").forEach(el => el.remove());
  });

frontend/src/app/hub/component/hub-search-result/hub-search-result.component.spec.ts:468

  • render() clears all of localStorage, which can interfere with unrelated specs running in the same Karma session. In other frontend specs, the common pattern is to clean up only the key under test (e.g., user-dataset.component.spec.ts:337 uses localStorage.removeItem(VIEW_MODE_KEY)). Consider removing just VIEW_MODE_STORAGE_KEY here instead of clear().

This issue also appears on line 511 of the same file.

    TestBed.resetTestingModule();
    localStorage.clear();
    if (storedViewMode !== undefined) {
      localStorage.setItem(VIEW_MODE_STORAGE_KEY, storedViewMode);
    }

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 15, 2026
Merged via the queue into apache:main with commit 3b19f76 Aug 15, 2026
25 checks passed
@aglinxinyuan
aglinxinyuan deleted the cov/hub-search-result-render branch August 15, 2026 01:50
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.

Recover the hub search result template's coverage by rendering its real children

4 participants