Skip to content

test(frontend): render the agent panel with its real children - #7629

Merged
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:cov/agent-panel-render
Aug 14, 2026
Merged

test(frontend): render the agent panel with its real children#7629
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:cov/agent-panel-render

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

agent-panel.component.html reported 0 of 49 lines while its own .ts sat at 133/133 with nothing missed. That pairing can only be attribution loss — this template is one of the better-tested in the frontend. The cause is #7458: the spec stubs its children out with TestBed.overrideComponent, and any override re-JITs the component from its decorator metadata, leaving the re-compiled template with no source map back to the .html.

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

Before After
agent-panel.component.html 0/49 49/49
agent-panel.component.ts 133/133 133/133

The block keeps its own TestBed, so the 42 existing tests keep their stubs and assertions untouched. Same remedy as merged PR #7535. Rendering the real children also incidentally lifts the child templates' own coverage.

Verification

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

Two of my new tests then turned out to claim more than they could observe, and both are fixed:

Test Why it could not fail Fix
"force-renders every tab body: the registration form and one chat per agent" the registration tab is the selected tab, so its body renders whether or not [nzForceRender] is set — flipping it to false left the suite green select an agent tab first, so the registration body is present only if force-rendered; the tautological selectedTabIndex assertion was dropped
"the close button ... deletes that agent without selecting its tab" selectedTabIndex was already 0 and activateAgent already un-called, so both assertions held with event.stopPropagation() deleted start on the first agent's tab and assert the click does not activate the neighbour

Both exposing mutations — the registration tab losing nzForceRender, and the close handler losing stopPropagation — are now red.

That second one is worth spelling out: the mutation did turn the suite red before the fix, but the failure came from a pre-existing test elsewhere in the file, while the new test stayed green. A red suite is not evidence that the test under discussion pins anything.

Deliberately not included

Nothing in this PR pins the child components' internals; the assertions stay on this template's own structure and branches.

No production file is touched.

Any related issues, documentation, discussions?

Closes #7628

How was this PR tested?

npx ng test --watch=false --include="**/agent-panel.component.spec.ts"
 Test Files  1 passed (1)
      Tests  51 passed (51)

9 new on top of the existing 42. 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)

agent-panel.component.html reported 0 of 49 lines covered while its own
.ts sat at 133/133 with nothing missed. That pairing can only come from
attribution loss, not from undertesting - this template is one of the
better-tested in the frontend. The cause is apache#7458: the spec stubs its
children out through TestBed.overrideComponent, and any override re-JITs
the component from its decorator metadata, leaving the re-compiled
template with no source map back to the .html.

Adds a describe block that renders the component with its real children,
taking the template from 0/49 to 49/49 lines. The block keeps its own
TestBed so the 42 existing tests keep their stubs untouched.

Two of the new tests claimed more than they could observe and were
rewritten: the force-render test asserted the registration form while its
tab was selected, where it renders either way, and the close-button test
asserted a tab index and a call count that were already at their expected
values before the click. Both now start from a state the behaviour has to
move, and the mutations that exposed them are red.

No production file is touched.
Copilot AI lite review requested due to automatic review settings August 13, 2026 05:56

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 13, 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.

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/workspace/component/agent/agent-panel/agent-panel.component.spec.ts:883

  • Avoid mutating the Vitest mock internals via .mock.calls.length = 0; this is brittle and inconsistent with the rest of the file (which uses .mockClear()). Clear the mock using the supported API instead.
      (service.activateAgent as unknown as { mock: { calls: unknown[] } }).mock.calls.length = 0;

frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts:839

  • This test reaches into child-component DOM internals (.agent-chat-container, .model-card) and can become brittle if those templates change. It also starts on the registration tab, so depending on tab-pane retention behavior, the registration assertion may still be non-discriminating for [nzForceRender]. Prefer asserting on the presence of the child components themselves and make the registration tab inactive from the first render.
    it("force-renders every tab body: the registration form and one chat per agent", () => {
      service.agentList = [makeAgent("a"), makeAgent("b")];
      createComponent();

      // The agent tabs are unselected here, so their bodies exist only because they are

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.11%. Comparing base (12169c2) to head (66f007b).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7629      +/-   ##
============================================
- Coverage     89.65%   89.11%   -0.54%     
+ Complexity     4397     4343      -54     
============================================
  Files          1177     1178       +1     
  Lines         46996    46872     -124     
  Branches       5268     5245      -23     
============================================
- Hits          42136    41772     -364     
- Misses         3094     3352     +258     
+ Partials       1766     1748      -18     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from f6a8526
agent-service 98.62% <ø> (-0.01%) ⬇️ Carriedforward from f6a8526
amber 84.89% <ø> (-1.46%) ⬇️ Carriedforward from f6a8526
computing-unit-managing-service 60.38% <ø> (-12.08%) ⬇️ Carriedforward from f6a8526
config-service 77.31% <ø> (ø) Carriedforward from f6a8526
file-service 68.90% <ø> (ø) Carriedforward from f6a8526
frontend 90.90% <ø> (+0.23%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from f6a8526
pyamber 97.51% <ø> (-0.06%) ⬇️ Carriedforward from f6a8526
workflow-compiling-service 57.89% <ø> (ø) Carriedforward from f6a8526

*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.

@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 14, 2026
Merged via the queue into apache:main with commit 379208e Aug 14, 2026
22 checks passed
@aglinxinyuan
aglinxinyuan deleted the cov/agent-panel-render branch August 14, 2026 06:28
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Aug 15, 2026
…pache#7661)

### 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 apache#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 apache#7535, apache#7627
and apache#7629 — this is the last of the six templates apache#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 apache#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)
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 agent panel template's coverage by rendering its real children

4 participants