Skip to content

test(frontend): cover the websocket handshake, port editor binding and quota charts - #7696

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/frontend-quota-port-websocket
Aug 16, 2026
Merged

aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/frontend-quota-port-websocket

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Three frontend files that sat below their neighbours, all with untested behaviour rather than tooling problems (these are .ts files, so #7458's template attribution does not apply).

File Before After
user-quota.component.ts 90.1% 140/140 lines, 34/34 branches, 36/36 functions
port-property-edit-frame.component.ts 86.5% 72/74 (97.3%)
workflow-websocket.service.ts 76.0% 45/48 (93.8%), 15/15 branches

Tests 47 -> 70.

Covered: the handshake URL's query construction and the heartbeat interval; the Yjs/Quill shared binding, its awareness and cursors module, and the three DOM triggers that drive it; and the quota component's per-day aggregation, its chart wiring, and the accumulator reset that makes a reload idempotent.

Verification

The build applied 26 mutations. Review then proposed 23 more, and every one of the 23 was real -- none was refutable. 33 distinct mutations were run in total (~54 runs), one at a time, anchor uniqueness asserted, reverted between each, with git diff on the production files confirmed empty after every revert.

The recurring failure was degenerate fixtures, where two different inputs produce identical output so a swap cannot be seen:

Surviving mutation Why nothing noticed
chart the workflow series into datasetLineChart both divs received identical-looking data
exchange the two chart div ids same
sizePieChart -> datasetLineChart, and dataset.size -> dataset.did the pie series was unpinned entirely
getSharedModelAwareness() -> undefined, and cursors: true -> false nothing read the binding's arguments back
the descriptor read for a different port id only one port existed in the fixture
(click) loses connectQuillToText(); (focusout) and (keyup.enter) dropped handlers were called directly, never through the DOM

One error I caught in my own repair, and only because mutations were run individually. The first idempotence test asserted workflows.length, which is unchanged when this.workflows = [] is dropped -- executions simply get re-filed under the existing panels. Running the two resets as separate mutations exposed it; the test now pins the per-workflow execution ids.

Deliberately not included

Two defects are reported rather than pinned, so neither is cemented as a contract:

  • The handshake drops cuid on a live path. WorkflowWebsocketResource.myOnOpen does session.getRequestParameterMap.get("cuid").get(0).toInt with no Option guard, while admin-execution.component.ts:327, :340, :353 all call socket.openWebsocket(wid) with no computing-unit id -- so admin kill/pause/resume dial a URL the server cannot accept. The test that observes today's URL is named descriptively rather than approvingly and carries a note pointing at the gap.
  • sortBySize is inverted relative to the NzTableSortFn contract. user-quota.component.ts:344-345 returns b - a, but ng-zorro applies sortOrder === 'ascend' ? compareResult : -compareResult and nzSortDirections defaults to ['ascend','descend',null], which the <th> does not override -- so the first click lights the up-caret while rendering largest-first. admin-user.component.ts:268 uses the contract-correct form, so this is not a house convention. The test clicks twice and asserts row order and which caret is active in both directions, with a comment stating the mismatch.

No production file is touched.

Any related issues, documentation, discussions?

Closes #7695

How was this PR tested?

npx ng test --watch=false --include="**/user-quota.component.spec.ts" --include="**/port-property-edit-frame.component.spec.ts" --include="**/workflow-websocket.service.spec.ts"
 Test Files  3 passed (3)
      Tests  70 passed (70)

Coverage measured with --coverage on the same run. yarn format:ci passes.

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 15, 2026 12:08

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 15, 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:

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

@codecov-commenter

codecov-commenter commented Aug 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.71%. Comparing base (1022c7d) to head (fd35386).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7696      +/-   ##
============================================
+ Coverage     90.64%   90.71%   +0.06%     
  Complexity     4439     4439              
============================================
  Files          1175     1175              
  Lines         47140    47140              
  Branches       5284     5284              
============================================
+ Hits          42729    42761      +32     
+ Misses         2697     2673      -24     
+ Partials       1714     1706       -8     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 1022c7d
agent-service 98.62% <ø> (ø) Carriedforward from 1022c7d
amber 87.26% <ø> (ø) Carriedforward from 1022c7d
computing-unit-managing-service 72.46% <ø> (ø) Carriedforward from 1022c7d
config-service 77.55% <ø> (ø) Carriedforward from 1022c7d
file-service 68.90% <ø> (ø) Carriedforward from 1022c7d
frontend 92.30% <ø> (+0.15%) ⬆️
notebook-migration-service 79.31% <ø> (ø) Carriedforward from 1022c7d
pyamber 97.52% <ø> (ø) Carriedforward from 1022c7d
workflow-compiling-service 57.89% <ø> (ø) Carriedforward from 1022c7d

*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

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

Suppressed comments (3)

frontend/src/app/dashboard/component/user/user-quota/user-quota.component.spec.ts:567

  • The assertions below do “bless” the caret/order mismatch: any future correction that makes the active ascending caret render smallest-first will fail this test. That contradicts the stated decision not to cement this defect as a contract. Remove this scenario from the test-only change, or fix sortBySize in production and assert that each caret agrees with the corresponding row order.
      // NOTE: the direction indicator and the row order disagree, and that is recorded here rather
      // than blessed. nzSortDirections defaults to ['ascend', 'descend', null], so the first click
      // selects 'ascend' and lights the up caret — but the rows come out LARGEST first, because
      // sortBySize returns `b - a` while NzTableSortFn expects `a - b` (nz-table negates the result
      // itself for 'descend'). Correcting the comparator is meant to flip both halves below.

frontend/src/app/workspace/service/workflow-websocket/workflow-websocket.service.spec.ts:237

  • This explicitly locks in the malformed no-cuid handshake that the PR description says is “reported rather than pinned.” Because the server unconditionally reads cuid, this assertion makes the known-bad URL part of the test contract and will fail when the live path is corrected. Keep only the valid three-ID handshake case (or add a regression test together with the production fix).
      service.openWebsocket(3, 9);
      expect(openedSockets[1].url).toContain("/wsapi/workflow-websocket?wid=3&uid=9");
      expect(openedSockets[1].url).not.toContain("cuid");

frontend/src/app/dashboard/component/user/user-quota/user-quota.component.spec.ts:375

  • This test makes the known inverted comparator an explicit contract by requiring largest-first order, despite the PR description saying this defect is not pinned. NzTableSortFn expects the comparator’s ascending order, so correcting sortBySize would now break this test. Either omit this assertion from the test-only PR or fix the production comparator and assert ascending order.

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

    it("orders executions by total cache size, largest first", () => {
      const scrambled = [SIZE_SORT_MIDDLE, SIZE_SORT_SMALL, SIZE_SORT_BIG];

      expect([...scrambled].sort(component.sortBySize).map(e => e.eid)).toEqual([30, 10, 20]);

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 16, 2026
Merged via the queue into apache:main with commit bf1a4e7 Aug 16, 2026
25 checks passed
@aglinxinyuan
aglinxinyuan deleted the cov/frontend-quota-port-websocket branch August 16, 2026 01:29
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.

Cover the websocket handshake, the port editor's shared binding and the quota charts

4 participants