Skip to content

test(frontend): cover the compiling service and the search-results template - #7727

Merged
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:cov/compiling-service-and-search-results
Aug 17, 2026
Merged

aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:cov/compiling-service-and-search-results

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Two frontend files, bundled because one needed a proven remedy and the other was a plain gap.

File Before After
search-results.component.html 0/33 lines, 0/6 branches, 0/6 functions 33/33, 6/6, 6/6
workflow-compiling.service.ts 140/157 lines, 90/105 branches, 32/36 functions 157/157, 103/105, 36/36

Tests 50 -> 73. search-results.component.ts also rises to 42/42 lines as a side effect.

Both files reach 100% of their lines, which necessarily covers all 19 of the lines Codecov reports missed (11 + 8).

The template was not undertested — it was unattributed

This is #7458, and this instance is worth recording because it presents as the opposite. The existing describe uses TestBed.overrideComponent and does render and assert on the DOM: it checks texera-list-item counts, .card-entry nodes, and load-more visibility. The template still measured 0 of 33 lines. Rendering happened; nothing was attributed. Second fingerprint: under the override the whole template function was attributed to the .ts as one uncovered span (55,35)-(79).

The appended describe keeps its own TestBed with no override and the real ListItemComponent, so the existing tests and the StubListItemComponent are untouched.

Verification

23 mutations, 23 killed, no survivors — each applied one at a time with the production file byte-compared after every revert, and the failing test read by name.

Two mutations had to be reformulated, which is the part worth flagging:

  • Exchanging the compile response's success/failure legs is a TypeScript narrowing error, not a behaviour change. A mutation that only fails to compile proves nothing, so it was discarded and replaced with three semantic mutants: the success leg additionally requiring zero operator errors, the state stream being notified only from the failed leg, and the failed leg reusing the previous errors.
  • Dropping the && cardTemplate guard breaks strictTemplates narrowing, so that mutant carries a companion [ngTemplateOutlet]="cardTemplate!" purely to keep it compiling. The behaviour change — card view rendering with no template — is the mutation, and it died on a DOM assertion.

One survivor was found and closed during the build rather than reported: [currentUid]="this.currentUid" replaced by entry.ownerId passed, because every fixture entry shared an owner. The new test gives two entries distinguishable owners (7 and 99), asserts on the rendered .owner-badge, then re-points currentUid to 99 and asserts the badge moves — so a constant replacement dies too.

Deliberately not included

Two branches in workflow-compiling.service.ts are structurally unreachable, so it cannot exceed 103/105:

  • if (!dynamicSchema) return undefined (line 241) is dead: DynamicSchemaService.getDynamicSchema() returns a non-nullable OperatorSchema and throws on a miss. This is also the file's only uncovered statement.
  • if (schemas.length > 0) (line 285) sits inside if (linksToThisPort.length > 0), where schemas is precisely that array mapped, so the false leg cannot occur.

A production bug is reported rather than pinned: getAttrNames (line 362) tests required-ness against the root schema via operatorSchema.jsonSchema.required?.includes(attrName), while DynamicSchemaService.mutateProperty recurses into nested properties/definitions/items. So a nested property that is required in its own sub-schema still gets "" appended to its enum, and a nested optional property whose name collides with a root-level required one loses that escape hatch. The new tests exercise only root-level properties, so neither behaviour is cemented.

Also noted, not cemented: getOperatorInputSchemaMap is a getter that mutates currentCompilationStateInfo, flipping the whole compilation to Failed when two links disagree on a port schema.

No production file is touched.

Any related issues, documentation, discussions?

Closes #7726

How was this PR tested?

npx ng test --watch=false --include="**/workflow-compiling.service.spec.ts" --include="**/search-results.component.spec.ts"
 Test Files  2 passed (2)
      Tests  73 passed (73)

Coverage measured with --coverage on the same run. yarn format:ci passes, and was checked non-vacuously with a positive control: a deliberately misformatted throwaway file made it exit 1 and name the file, then was removed.

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 17, 2026 06:45

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:

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

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Aug 17, 2026
@aglinxinyuan
aglinxinyuan requested a review from mengw15 August 17, 2026 06:52
@codecov-commenter

codecov-commenter commented Aug 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.76%. Comparing base (16ba619) to head (d91968a).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7727      +/-   ##
============================================
- Coverage     90.93%   90.76%   -0.17%     
+ Complexity     4450     4403      -47     
============================================
  Files          1174     1173       -1     
  Lines         47139    46961     -178     
  Branches       5284     5258      -26     
============================================
- Hits          42866    42626     -240     
- Misses         2580     2662      +82     
+ Partials       1693     1673      -20     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (-11.00%) ⬇️ Carriedforward from 2f77d5a
agent-service 98.62% <ø> (ø) Carriedforward from 2f77d5a
amber 87.04% <ø> (-0.35%) ⬇️ Carriedforward from 2f77d5a
computing-unit-managing-service 72.81% <ø> (-0.86%) ⬇️ Carriedforward from 2f77d5a
config-service 77.08% <ø> (-9.66%) ⬇️ Carriedforward from 2f77d5a
file-service 68.90% <ø> (ø) Carriedforward from 2f77d5a
frontend 92.58% <ø> (+0.14%) ⬆️
notebook-migration-service 78.35% <ø> (-5.40%) ⬇️ Carriedforward from 2f77d5a
pyamber 97.57% <ø> (-0.01%) ⬇️ Carriedforward from 2f77d5a
workflow-compiling-service 57.89% <ø> (-19.30%) ⬇️ Carriedforward from 2f77d5a

*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 requested a lite review from Copilot August 17, 2026 07:05

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

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 17, 2026
Merged via the queue into apache:main with commit 8bcc8eb Aug 17, 2026
22 checks passed
@aglinxinyuan
aglinxinyuan deleted the cov/compiling-service-and-search-results branch August 17, 2026 08:18
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)
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 compiling service and recover the search-results template's coverage

4 participants