Skip to content

fix(test, frontend): stub Plotly in the execution-history spec - #8288

Open
mengw15 wants to merge 2 commits into
apache:mainfrom
mengw15:fix/8287-stub-plotly-in-execution-history-spec
Open

fix(test, frontend): stub Plotly in the execution-history spec#8288
mengw15 wants to merge 2 commits into
apache:mainfrom
mengw15:fix/8287-stub-plotly-in-execution-history-spec

Conversation

@mengw15

@mengw15 mengw15 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

workflow-execution-history.component.spec.ts let ngAfterViewInit call the real Plotly.newPlot on every setup. 36 of its 61 tests build the component, and each build plots twice, so one run drove roughly 72 real Plotly renders through jsdom — for the benefit of a single test.

That test then read data and layout back off the graph divs Plotly populates. Every value it asserted (type, labels, values, x, y, the widths, the titles) is one the component itself computed and handed over, so the round trip through the real library bought no coverage. It also cannot buy any here: jsdom has no layout or canvas, so whether Plotly drew anything sensible is unobservable — that belongs to the browser-mode suite, if anywhere.

Mock the module for this spec and assert on the arguments passed to newPlot instead. The chart test now checks the component's own decision rather than Plotly's handling of it.

This is what made the spec flaky rather than merely slow: the failing case on macOS was three synchronous assertions behind a setup(), timing out against the 20 s per-test limit under runner contention, while ubuntu and windows passed. Removing the dominant avoidable cost restores the margin; it is not a proof that Plotly was the only contributor.

user-quota and workflow-runtime-statistics render real Plotly too, but at 339 ms / 25 tests and 197 ms / 12 tests they are nowhere near the limit, so they are left alone.

Also corrects TESTING.md, which documented ng test --test-file <path> for single-file runs; the builder rejects that argument and the flag is --include.

Any related issues, documentation, discussions?

Closes #8287.

How was this PR tested?

yarn ng test --include ".../workflow-execution-history.component.spec.ts" — 61 passed, test time 4.12 s → 1.69 s.

Failure paths checked, since the rewritten assertions must still catch what the old ones did: changing the component's pie-chart WIDTH from 450 to 451 turns the chart test red, and removing one of the two Plotly.newPlot calls does too. Restoring each returns the file to 61 passing. eslint is clean on the touched spec.

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

Generated-by: Claude Code (claude-opus-5)

`workflow-execution-history.component.spec.ts` let ngAfterViewInit call
the real `Plotly.newPlot` on every setup. 36 of its 61 tests build the
component, and each build plots twice, so one run drove roughly 72 real
Plotly renders through jsdom — for the benefit of a single test.

That test then read `data` and `layout` back off the graph divs Plotly
populates. Every value it asserted (`type`, `labels`, `values`, `x`, `y`,
the widths, the titles) is one the component itself computed and handed
over, so the round trip through the real library bought no coverage. It
also cannot buy any: jsdom has no layout or canvas, so whether Plotly
drew anything sensible is unobservable here — that belongs to the
browser-mode suite, if anywhere.

Mock the module for this spec and assert on the arguments passed to
`newPlot` instead. The chart test now checks the component's own decision
rather than Plotly's handling of it, and the file's test time drops from
4.12s to 1.78s locally.

This is what made the spec flaky rather than merely slow: the failing
case on macOS was three synchronous assertions behind a `setup()`, timing
out against the 20s per-test limit under runner contention while ubuntu
and windows passed. Removing the dominant avoidable cost restores the
margin; it is not a proof that Plotly was the only contributor.

`user-quota` and `workflow-runtime-statistics` render real Plotly too,
but at 339ms/25 tests and 197ms/12 tests they are not close to the limit,
so they are left alone.

Also corrects `TESTING.md`, which documented `ng test --test-file <path>`
for single-file runs; the builder rejects that argument and the flag is
now `--include`.

Closes apache#8287.
@mengw15
mengw15 requested review from aglinxinyuan and a lite review from Copilot and removed request for Copilot August 31, 2026 11:11
@mengw15 mengw15 self-assigned this Aug 31, 2026
@mengw15
mengw15 requested a lite review from Copilot August 31, 2026 11:11

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR reduces flakiness and runtime in workflow-execution-history.component.spec.ts by stubbing Plotly renders and asserting against Plotly.newPlot call arguments, and fixes the documented Angular single-spec flag in TESTING.md.

Changes:

  • Mock plotly.js-basic-dist-min in the execution-history spec and validate chart inputs via newPlot call args instead of jsdom-rendered graph div state.
  • Clear the Plotly mock between setups to avoid cross-test pollution.
  • Correct TESTING.md to use ng test --include for single-file runs.

Reviewed changes

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

File Description
frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-execution-history.component.spec.ts Stubs Plotly and rewrites chart assertions to check newPlot arguments, improving test speed/stability
frontend/TESTING.md Updates single-file test docs to use the correct --include flag

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@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:

  • Contributors with relevant context: @aglinxinyuan
    You can notify them by mentioning @aglinxinyuan in a comment.

@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI docs Changes related to documentations labels Aug 31, 2026
@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Aug 31, 2026
@github-actions
github-actions Bot requested a review from xuang7 August 31, 2026 11:30
@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.3 Not labeled automatically — none of the files this PR modifies exist on this branch (frontend/TESTING.md, frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-execution-history.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.3 by hand if this fix should be backported here.
release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. Requested review from @xuang7.

Auto-label run.

@mengw15 mengw15 removed fix release/v1.2 back porting to release/v1.2 labels Aug 31, 2026
Addresses review feedback on PR apache#8288: the `plot()` helper used
`.find()`, which would silently pick the first match if the
component ever called `Plotly.newPlot` twice for the same id.
Switch to `.filter()` + `expect(calls).toHaveLength(1)` so a
duplicate render fails the test alongside a missing one.
@mengw15
mengw15 removed the request for review from xuang7 August 31, 2026 11:49
@github-actions github-actions Bot added the fix label Aug 31, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.93%. Comparing base (50321e4) to head (73612c7).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8288   +/-   ##
=========================================
  Coverage     93.93%   93.93%           
  Complexity     4762     4762           
=========================================
  Files          1191     1191           
  Lines         48308    48308           
  Branches       5377     5377           
=========================================
  Hits          45380    45380           
  Misses         1494     1494           
  Partials       1434     1434           
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from 50321e4
agent-service 99.32% <ø> (ø) Carriedforward from 50321e4
amber 90.03% <ø> (ø) Carriedforward from 50321e4
computing-unit-managing-service 73.67% <ø> (ø) Carriedforward from 50321e4
config-service 86.86% <ø> (ø) Carriedforward from 50321e4
file-service 87.91% <ø> (ø) Carriedforward from 50321e4
frontend 96.41% <ø> (ø)
notebook-migration-service 79.31% <ø> (ø) Carriedforward from 50321e4
pyamber 98.87% <ø> (ø) Carriedforward from 50321e4
workflow-compiling-service 77.19% <ø> (ø) Carriedforward from 50321e4

*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

docs Changes related to documentations fix frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky WorkflowExecutionHistoryComponent spec: every setup renders real Plotly, over half the file's runtime

4 participants