Skip to content

fix(test, frontend): stop the agent-panel tab test depending on nz-tabs click timing - #7756

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:fix/agent-panel-tab-click-flake
Open

fix(test, frontend): stop the agent-panel tab test depending on nz-tabs click timing#7756
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:fix/agent-panel-tab-click-flake

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

agent-panel.component.spec.ts's tab-selection test fails intermittently on CI with:

AssertionError: expected "vi.fn()" to be called with arguments: [ 'b' ]
Number of calls: 0

It has now failed on both ubuntu-latest and windows-latest while passing locally — including a clean local run of the full 201-file suite — so it is a timing dependency, not a real regression. It is currently red on unrelated PRs.

Cause. The test clicked the tab header and then called fixture.detectChanges() once:

(tabHeaders()[2].querySelector(".ant-tabs-tab-btn") as HTMLElement).click();
fixture.detectChanges();
expect(service.activateAgent).toHaveBeenCalledWith("b");

nz-tabs does not emit nzSelectedIndexChange from its click handler — it emits during its own change-detection pass. So a single detectChanges() is not guaranteed to have run onTabSelectChange yet. Locally one pass happened to catch it; on CI it did not, and activateAgent had not been called.

Fix. Drive the output the template binds, which is the same idiom the nzResize test a few cases above already uses:

const tabSet = fixture.debugElement.query(By.directive(NzTabsComponent)).componentInstance;
tabSet.nzSelectedIndexChange.emit(2);
fixture.detectChanges();

The DOM-level check that the tab is selectable is kept, so the case cannot pass for the wrong reason if [nzDisabled] ever inverts:

expect(tabHeaders()[2].classList.contains("ant-tabs-tab-disabled")).toBe(false);

fixture.whenStable() is not usable here: the panel keeps a long-lived subscription open, so awaiting stability hangs the test to its 20s timeout. That was tried first and is recorded in the comment so nobody repeats it.

The fix is not vacuous

Emitting the output still pins the binding. Two mutations of the template, applied one at a time and reverted with the production diff verified empty:

Mutation Result Failing test
delete the (nzSelectedIndexChange)="onTabSelectChange($event)" binding red, 1 failed / 50 passed selecting an agent's tab activates that agent and marks only its chat active
point the binding at onTabSelectChange(0) instead of $event red, 1 failed / 50 passed same test

The test is renamed from "clicking an agent's tab header…" to "selecting an agent's tab…" so the name matches what it now does.

Any related issues, documentation, discussions?

Closes #7755

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)

The full frontend suite is green: 201 files, 4731 passed, 1 skipped. yarn format:ci passes. No production file is touched.

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

Generated-by: Claude Code (Opus 5)

Copilot AI lite review requested due to automatic review settings August 18, 2026 08:19

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

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.

@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI labels Aug 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. release/* labels drive the post-merge backport, so add or remove one to change where this fix lands.

Release branch Analysis
⚠️ release/v1.2 Not labeled automatically — none of the files this PR modifies exist on this branch (frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.spec.ts). The fix may target code that isn't on this release, or the files were moved/renamed after the branch was cut. Please check and add release/v1.2 by hand if this fix should be backported here.

Auto-label run.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.02%. Comparing base (60300e3) to head (9c9d12d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7756   +/-   ##
=========================================
  Coverage     91.02%   91.02%           
  Complexity     4454     4454           
=========================================
  Files          1174     1174           
  Lines         47146    47146           
  Branches       5287     5287           
=========================================
  Hits          42916    42916           
  Misses         2550     2550           
  Partials       1680     1680           
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from 60300e3
agent-service 98.62% <ø> (ø) Carriedforward from 60300e3
amber 87.45% <ø> (ø) Carriedforward from 60300e3
computing-unit-managing-service 73.67% <ø> (ø) Carriedforward from 60300e3
config-service 86.73% <ø> (ø) Carriedforward from 60300e3
file-service 68.90% <ø> (ø) Carriedforward from 60300e3
frontend 92.59% <ø> (ø)
notebook-migration-service 83.74% <ø> (ø) Carriedforward from 60300e3
pyamber 97.57% <ø> (ø) Carriedforward from 60300e3
workflow-compiling-service 77.19% <ø> (ø) Carriedforward from 60300e3

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent panel tab-selection test fails intermittently in CI

3 participants