aglinxinyuan opened a new pull request, #7733:
URL: https://github.com/apache/texera/pull/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 #7458 case, and worth saying so
   
   The obvious guess for a dark template here is the 
`TestBed.overrideComponent` attribution loss behind merged PRs #7535, #7627, 
#7629, #7661, #7681 and #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 #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 #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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to