apache / apache/texera

cover the remaining branches in ResultExportation, PresetService, WorkflowActionService, and ResultTableFrame

Open
#7,777 0 comments 0 reactions 1 assignee Claimed by @mengw15 View on GitHub
Dominant language
Scala
Stars
314
Forks
187
Avg merge
1d 21h
Merged PRs (30d)
214

Description

### Task Summary

Four frontend files are a few lines and untaken branches from full coverage — 16 partial branches and 10 unhit lines between them. Codecov computes `coverage = hits / lines` and does not count a partially-covered line as a hit, so both kinds cost percentage points.

**Goal: cover the listed lines and take the missing side of each branch so these files reach full coverage.** All four already have a spec; extend it and re-run the coverage report to catch anything left. Vitest/jsdom; see `frontend/TESTING.md`.

Every case below is reached by **passing a different input value or toggling a component flag** — no timer, clock, OS, or concurrency is involved. Assert on rendered text / bound attributes / component state, never on layout or geometry (zeros under jsdom).

### Behavior to add

**ResultExportationComponent template** (`frontend/src/app/workspace/component/result-exportation/result-exportation.component.html`, 89.5%, 3 partials + 4 unhit)
- `[nzDescription]="blockingDatasetSummary || null"` (two sites) — render once with a blocking-dataset summary present and once with it empty, so both sides of the `||` run.
- `{{dataset.dataset.did?.toString()}}` — a dataset whose `did` is set and one where it is undefined (the `?.` short-circuit).
- The unhit `[(ngModel)]` bindings — `exportType`, `inputFileName`, `destination`: set each control's value and dispatch `input`, asserting the bound component field updates.
- `(click)="onClickExportResult('dataset', dataset)"` — click the dataset export button via `By.css` + `triggerEventHandler` and assert the service double received `'dataset'` and that dataset.

**PresetService** (`frontend/src/app/workspace/service/preset/preset.service.ts`, 95.0%, 2 partials + 4 unhit)
- The whole gap is the **replace path in the preset update**: `JSON.parse(presetsString ?? "[]")` (cover a stored value present and absent) and `if (!contains(presets, originalPreset))`.
- Drive the update three ways so the remaining unhit lines run: the original preset is **missing** (the guarded arm), the replacement **already exists** (`else if (contains(presets, replacementPreset))`), and the normal replace — which executes `presets.splice(indexOf(presets, originalPreset), 1)`, `presets[indexOf(presets, originalPreset)] = replacementPreset`, and the following `savePresets(type, target, presets, displayMessage, messageType)` call.

**WorkflowActionService** (`frontend/src/app/workspace/service/workflow-graph/model/workflow-action.service.ts`, 97.7%, 7 partials)
- `if (links)` — call the add/paste path with links supplied and with none.
- `if (this.texeraGraph.sharedModel.elementPositionMap.get(operatorID) !== …)` and the same guard for `commentBoxID` — move an element to a new position and then to its current position, so the "changed" and "unchanged" arms both run.
- `if (position.x < minX)` and the sibling bounds comparisons — feed elements positioned inside and outside the current bounds so each comparison decides both ways.

**ResultTableFrameComponent** (`frontend/src/app/workspace/component/result-panel/result-table-frame/result-table-frame.component.ts`, 97.3%, 4 partials + 1 unhit)
- `previousStr = previous !== undefined ? previous.toFixed(2) : currentStr` and the sibling `previous.toLocaleString()` ternary — render a statistics update where the previous value exists and one where it is undefined (first update), so both arms run.
- `if (resultData.length < 1) { return }` — call with an empty result set (the unhit `return`) and with a populated one.
- `this.cellMediaTypes.get(row)?.[columnIndex] ?? "text"` — a row that has a recorded media type at that column, a row absent from the map (the `?.` short-circuit), and one present but without that column (the `?? "text"` fallback).

### Task Type

- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.