Skip to content

test(frontend): drive the dataset detail template through the DOM - #7681

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/dataset-detail-render
Aug 15, 2026
Merged

aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:cov/dataset-detail-render

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

dataset-detail.component.html was at 92.0% of lines, 72.9% of branches and 42.9% of functions behind a 129-test spec. This is not an instance of #7458 — the spec uses no TestBed.overrideComponent, so no attribution is lost. The gaps were real: handlers on child outputs, controls inside CDK overlays, the version-creator block, and the false legs of the header and settings ternaries.

Before After
lines 312/339 (92.0%) 339/339 (100%)
branches 35/48 (72.9%) 48/48 (100%)
functions 15/35 (42.9%) 35/35 (100%)

Tests 129 -> 161, all 32 new ones in one appended describe with its own TestBed, no override, real children and real overlays. No existing test or stub is touched.

Verification — and a correction

The first pass reported 25 mutations, all killed, zero survivors. That did not hold. Four reviewers were asked to refute the suite; between them they predicted 21 distinct surviving mutations, and every one of the 21 did survive the 154-test suite. 23 of the 24 findings are now fixed, and each repaired kill was re-proved with only the new block selected (--filter "DatasetDetailComponent rendered template", 129 pre-existing tests skipped), so no new test leans on a neighbour.

Two failure modes are worth recording, because neither is visible in a coverage report:

Branches counted as covered and still unpinned. The upload row's tooltip ternary read 2/2 covered, yet swapping its two results passed. Both legs rendered somewhere; nothing asserted which. The same shape hid an exchange of the two nz-switch models and an exchange of the view/like counters.

Degenerate fixtures. A row with totalTime and estimatedTimeRemaining both undefined renders ["1s", "1s left"], because formatTime maps undefined, 0 and any n <= 0 to "1s" — so swapping elapsed and remaining, a real user-visible bug, was undetectable. formatSpeed(1024) and formatSpeed(40) likewise both render "0.0 MB/s". Those tests now use distinguishable values (12s / 1m30s left, 5.0 MB/s) and keep the degenerate case as a separate, honestly-named floor test.

Also fixed: toContain("2") against a size of 2048 (passes on the raw number — now toBe("2.00 KB")), two expect.any(Number) arguments that left chunk-size and concurrency swappable, and an isLogin flag hidden behind expect.anything().

One mutation is deliberately left alive

html:401 [(ngModel)]="selectedVersion" -> [ngModel] survives, and that is correct rather than a gap: the same element carries (ngModelChange)="onVersionSelected($event)", and onVersionSelected assigns this.selectedVersion itself (ts:527). Removing the two-way sugar leaves an observationally identical component. It is an equivalent mutant, settled by running it rather than by reading.

A misdiagnosis worth flagging

An earlier pass concluded that [disabled]="isCreatingVersion" on the version-name input was inert — that NzInputDirective swallowed the binding because [(ngModel)] supplies an NgControl. That was wrong, and the test settled it: NgModel routes disabled through control.disable(), which it defers to a microtask, so the DOM simply lags one turn behind detectChanges(). With the microtask hop the field really does lock. Both the flip and outright deletion of that binding now fail.

Deliberately not included

html:585's userHasWriteAccess() && is redundant — the enclosing nz-collapse at html:452 is already gated on userDatasetAccessLevel === "WRITE", which is exactly what that method returns. Reported, not tested.

The read-only leg of the description editor's [editable] is unreachable from the template: the Settings tab itself sits behind *ngIf="userHasWriteAccess()", so a reader never gets there.

No production file is touched.

Any related issues, documentation, discussions?

Closes #7680

How was this PR tested?

npx ng test --watch=false --include="**/dataset-detail.component.spec.ts"
 Test Files  1 passed (1)
      Tests  161 passed (161)

32 new on top of the existing 129. 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 03:34

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:

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

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.28%. Comparing base (f5017f7) to head (6829f03).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7681      +/-   ##
============================================
+ Coverage     90.14%   90.28%   +0.14%     
  Complexity     4415     4415              
============================================
  Files          1176     1176              
  Lines         47133    47133              
  Branches       5285     5285              
============================================
+ Hits          42487    42555      +68     
+ Misses         2879     2822      -57     
+ Partials       1767     1756      -11     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from f5017f7
agent-service 98.62% <ø> (ø) Carriedforward from f5017f7
amber 86.67% <ø> (ø) Carriedforward from f5017f7
computing-unit-managing-service 72.46% <ø> (ø) Carriedforward from f5017f7
config-service 77.55% <ø> (ø) Carriedforward from f5017f7
file-service 68.90% <ø> (ø) Carriedforward from f5017f7
frontend 91.83% <ø> (+0.32%) ⬆️
notebook-migration-service 79.31% <ø> (ø) Carriedforward from f5017f7
pyamber 97.57% <ø> (ø) Carriedforward from f5017f7
workflow-compiling-service 57.89% <ø> (ø) Carriedforward from f5017f7

*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 15, 2026
Merged via the queue into apache:main with commit 00fe327 Aug 15, 2026
25 checks passed
@aglinxinyuan
aglinxinyuan deleted the cov/dataset-detail-render branch August 15, 2026 04:37
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Aug 18, 2026
…rds (apache#7733)

### What changes were proposed in this PR?

Two small frontend targets. The headline is the console frame template,
whose line percentage hid the real gap:

| File | Before | After |
|---|---|---|
| `console-frame.component.html` | branches **0/8**, functions **5/9** |
**8/8 branches, 9/9 functions** |
| `console-frame.component.ts` | 96.9% lines, 95% functions | **65/65
lines (100%), 20/20 functions** |
| `preset.service.ts` | 94.8% lines, 90.5% branches | **111/115 lines,
70/74 branches** |

7 tests added. Covered: `ngOnChanges` adopting a new operator id, the
empty-list fallback, typing into the command box through a real `input`
event and submitting, narrowing the send by picking a worker in the
`nz-select` overlay, the settings dropdown's two toggles, and two
`preset.service` validation guards.

**This is 8 lines by line-count.** What earns it is the branch and
function coverage on the template — every interactive control in the
console frame was previously unexercised — and that all 8 mutations die.

### Not an apache#7458 case, and worth saying so

The obvious guess for a dark template here is the
`TestBed.overrideComponent` attribution loss behind merged PRs apache#7535,
apache#7627, apache#7629, apache#7661, apache#7681 and apache#7727. It is not: the existing spec uses
`imports: [ConsoleFrameComponent, ...]` with no override, and the
coverage map shows bindings executing counted (the `*ngFor` statement
has 124 hits). So this extends the existing TestBed rather than
appending a separate one — the opposite call from apache#7727, for a checkable
reason.

### Verification

8 mutations, **8 killed, no survivors**, each applied one at a time with
the anchor asserted unique, reverted and `git diff`-checked between
every run. All failures are assertion failures, never compile errors.

| Mutation | Killed by |
|---|---|
| **exchange** `[(ngModel)]="showTimestamp"` and `"showSource"` |
toggles the timestamp and source tags independently |
| `[(ngModel)]="targetWorker"` -> one-way | narrows the command to the
worker picked |
| `[(ngModel)]="command"` -> one-way | sends the text typed into the
command box |
| **exchange** `currentValue` and `previousValue` | `ngOnChanges` adopts
the newly bound operator id |
| remove the `\|\| []` fallback | falls back to an empty list for an
unseen operator |
| **exchange** the `"error"` and `"info"` switch bodies | refuses to
save with an 'info' severity |
| `push(replacementPreset)` -> `push(originalPreset)` | stores the
replacement when the dictionary has no entry yet |
| give `"warning"` a default toast instead of throwing | refuses to save
with a 'warning' severity |

The first one is the reason the fixture is not degenerate: the kill
lands on the *independence* assertion (timestamp off, source still on).
Turning both toggles off at once would have survived the exchange.

One mechanical note worth recording: the settings dropdown's menu is
projected into a CDK overlay wired in `ngAfterViewInit` behind an
`auditTime(150)`, so its fixture must be created **inside** `fakeAsync`.
Created in a plain `beforeEach`, the timers escape `tick()`, the overlay
never attaches, and the switch count is 0 — a test written against that
state would pass while asserting nothing.

### Deliberately not included, with evidence

- **`updatePreset` (lines 184-190) is dead *and* buggy**, so no test was
written for it. It has zero call sites repo-wide outside its own spec.
And `indexOf(presets, originalPreset)` is lodash reference-equality
against a freshly `JSON.parse`d array, so it always returns `-1`:
`splice(-1, 1)` deletes the **wrong** preset and `presets[-1] = ...` is
a silent no-op that `JSON.stringify` drops. Its sibling
`updateOrCreatePreset` carries the comment *"presets are freshly
JSON-parsed, so reference-based indexOf would miss"* and uses
`findIndex(isEqual)` — the fix was applied there and not here. Any test
would cement the bug.
- **`console-frame.component.html` lines 54 and 59 are structurally
unreachable**: `#checkedTemplate` and `#unCheckedTemplate` are each
declared **twice** (36/41 and 53/58), and both `nz-switch`es resolve to
the first pair. The coverage map proves it — statements at 37/42 have 46
hits (2 switches x 23 fixtures) while 54/59 have 0.
- Two `.ts` branch arms are guard-guaranteed: `renderConsole()`'s `if
(this.operatorId)` already forces the ternary's true leg, and
`#consoleList` is unconditional in the template so its `@ViewChild` is
always set in a rendered fixture.

A third, weaker observation, reported and not pinned: `ngOnChanges` does
`this.operatorId = changes.operatorId?.currentValue`, so an
`ngOnChanges` fired by a change to `consoleInputEnabled` alone would
wipe `operatorId` to `undefined` and silently disable the debug console.
`ResultPanelComponent` always sets both inputs together, so it is latent
rather than triggered today; the new test pins only the normal path.

No production file is touched.

### Any related issues, documentation, discussions?

Closes apache#7732

### How was this PR tested?

```
npx ng test --watch=false --include="**/preset.service.spec.ts" --include="**/console-frame.component.spec.ts"
```

```
 Test Files  2 passed (2)
```

86 tests green in the two target specs; 174 green including the consumer
specs `result-panel.component.spec.ts` and
`preset-wrapper.component.spec.ts`, checked for CDK-overlay leakage
across specs. `yarn format:ci` passes.

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

Generated-by: Claude Code (Opus 5)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Aug 22, 2026
…mponents (apache#7833)

### What changes were proposed in this PR?

Test-only. **No production file changes.**

Both templates here reached 100% in merged PRs apache#7681 and apache#7772, which
lifted these `.ts` files as a side effect — so what remained was branch
arms and uncalled handlers rather than whole untested regions. Measured
with istanbul JSON from `--coverage --coverage-reporters=json`, one spec
at a time, identical `--include` filter for the before and after runs:

**`dataset-detail.component.ts`**

| | before | after |
|---|---|---|
| statements | 425/430 (98.84%) | **428/430 (99.53%)** |
| branch arms | 177/203 (87.19%) | **193/203 (95.07%)** |
| functions | 115/120 (95.83%) | **120/120 (100%)** |

In the Codecov framing used in the issue: 5 missed lines + 24 partial →
**2 missed + 9 partial**. 15 of the 24 partial lines are now fully
covered. Closed 3 of 5 missed statement lines, **16 of 26 missed branch
arms**, and **5 of 5 missed functions**. Its template is re-confirmed at
455/455 statements and 46/46 branch arms, so nothing was added there.

**`user-dataset-version-creator.component.ts`**

| | before | after |
|---|---|---|
| statements | 58/63 (92.06%) | **62/63 (98.41%)** |
| branch arms | 22/24 (91.67%) | **24/24 (100%)** |
| functions | 14/16 (87.50%) | 15/16 (93.75%) |

Codecov framing: 5 missed + 2 partial → **1 missed + 0 partial**.

Tests **188 → 214**: dataset-detail 173 → 192, version-creator 15 → 18,
plus the repair round below.

### An honest correction to the second target's count

The assessment called it 5 lines + 2 arms. The real closable count is
**4 statements + 2 arms + 1 function**, because **one of its 5 missed
lines is dead code**: `get formControlNames(): string[]`. A repo-wide
grep returns exactly one hit — its own declaration — with no template
and no TypeScript reference. It is left uncovered deliberately rather
than cemented; deleting the getter belongs in a separate production PR.

### Verification

Review raised 14 findings across two lenses; the repair round took the
suite to 214 and every accepted finding was proved by running the
reviewer's proposed mutation first, then re-running after the fix to
confirm it dies on the named test.

Neither file is an instance of apache#7458 — no `TestBed.overrideComponent` in
either spec, which the non-zero starting percentages already implied.

One earlier misdiagnosis was deliberately **not** re-reported:
`dataset-detail.component.html:593`'s `[disabled]` binding does work.
`NgModel` routes it through `control.disable()`, deferred to a
microtask, so the DOM lags one turn behind `detectChanges()` — asserting
immediately reads a stale value and looks like an inert binding.

### Any related issues, documentation, discussions?

Closes apache#7832

### How was this PR tested?

```
npx ng test --watch=false --include="**/dataset-detail.component.spec.ts" --include="**/user-dataset-version-creator.component.spec.ts"
```

```
 Test Files  2 passed (2)
      Tests  214 passed (214)
```

`yarn format:ci` exits 0; no `junit.xml` left behind.

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

Drive the dataset detail template through the DOM

4 participants