This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new 03a5bb8424 feat(workflow-form): bring the selected step's result to
the top, and give each result a name and an eye (#9334)
03a5bb8424 is described below
commit 03a5bb842447527910a782c342ef67d2f992ab7b
Author: yangzhang75 <[email protected]>
AuthorDate: Wed Nov 11 06:34:37 2026 +0000
feat(workflow-form): bring the selected step's result to the top, and give
each result a name and an eye (#9334)
### What changes were proposed in this PR?
Closes #9257. The behaviour here is the one settled in the design
discussion #9033.
After a run the Form View can show several result cards, and nothing
tied a card to the step that
produced it. To find one step's result a reader read the card titles,
and two steps with the same
name gave two cards with the same title. The picker that decides which
results show sat below the
cards, away from both the preview and the results it is about.
**Selecting a step leads the Results.** The selected step's card moves
to the front, outlined in the
colour the canvas draws round a selected step (`workflow-editor`'s
`highlightOptions` stroke), so the
move reads as "this is that step's result" rather than a reshuffle. The
selection is the canvas's
own: clicking a step on the embedded preview leads its card, and
deselecting -- the panel's close
button, empty canvas, a multi-select -- puts the cards back in their
saved order. The card at the
front is read from the selection rather than kept beside it; keeping a
second copy let the two drift
apart (hiding the selected step's result cleared the lead but not the
selection, and its name then
read as "already leading").
**Each result becomes a chip with two targets.** The picker moves up to
sit between the preview and
the results. The step's name makes that same selection -- through
`WorkflowActionService`, so a
co-editor sees the ring exactly as they do for a canvas click -- and
clicking the name of the step
already selected lets it go. The eye beside it shows or hides that
result: the author's default for
everyone while editing (written to the config, as before), this page
only otherwise, so a reader
without write access can still hide a result they do not care about and
bring it back. A hidden
result has no card to bring up, so its name is marked unavailable and
says why, while its eye stays
live; that is how the result comes back.
Nothing about the order is saved, and the preview is left as the reader
had it: opening it from a
name click moved the picker and the results about a third of the page
down, out from under the name
just clicked. The ring has a programmatic twin: the leading result's
name carries `aria-current`, so
a reader who cannot see the outline is still told which result is the
one being looked at.
**Known limitation, pre-existing:** a selection made while the preview
is closed is not ringed on the
canvas if the preview is opened afterwards. The editor draws only the
highlights that arrive after it
mounts, which is also why switching between the canvas and the Form View
loses the ring on main. The
step's property panel does open on it, so the selection itself is not
lost.
Not included, and raised in #9033: letting the author drag the results
into an order in Edit mode.
Two dead lines in files this PR already touches go with it: the rendered
spec registered the `lock`
and `unlock` ng-zorro icons, which no template reachable from that spec
renders, and
`workflow-form.component.spec.ts` imported `workspaceFormUrl` without
using it.
#### Video
https://github.com/user-attachments/assets/45a28cdc-9281-469c-89bf-9895d8287c25
### Any related issues, documentation, discussions?
- Closes #9257.
- Design discussion: #9033, where this behaviour was settled (the lock
that an earlier revision used,
and the double click that let a step go, were both dropped there).
### How was this PR tested?
Fifteen new unit tests in `workflow-form.component.spec.ts` and two in
`workflow-form.rendered.spec.ts` (the rendered page asserts the picker's
position between the preview
and the results, and that the ring lands on the lead card and that
step's chip and nowhere else). The
harness gained a `highlightOperators` that models the real chain, so a
name click goes through the
action service, the wrapper replaces the selection, the highlight stream
emits and the page's own
handler runs, as for a canvas click.
Full frontend suite on this branch, rebased on current main: 251 files,
7157 tests, 1 skipped, all
green. ESLint and Prettier clean on the changed files. Production AOT
build passes. Every statement
and every branch the commit adds is covered, checked line by line
against the lcov report: 42/42
statements and 16/16 branches, with no partially-taken branch on a
changed line. Eleven mutations of
the new behaviour -- the lead not moving, the ring on the wrong card, a
hidden name acting, the eye
writing a reader's choice to the config, the name and the eye wired to
each other's handler, the
`aria-current` twin going missing -- were all killed by the new tests.
Checked by hand on a local stack against a ten-operator demo workflow
with four results (a table and
three charts): clicking a step on the preview, clicking a result's name,
clicking it again, hiding
the selected step's result and showing it again, and two browser tabs
open on the same workflow to
confirm the order and the eye are local to a page while the selection
ring propagates as a canvas
click's does.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Meng Wang <[email protected]>
---
.../workflow-form/workflow-form.component.html | 101 ++++---
.../workflow-form/workflow-form.component.scss | 96 ++++++-
.../workflow-form/workflow-form.component.spec.ts | 316 ++++++++++++++++++++-
.../workflow-form/workflow-form.component.ts | 96 +++++--
.../workflow-form/workflow-form.rendered.spec.ts | 105 ++++++-
.../workflow-form/workflow-form.spec-harness.ts | 21 ++
6 files changed, 652 insertions(+), 83 deletions(-)
diff --git
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.html
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.html
index e80ade70ba..8eb83f29b5 100644
---
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.html
+++
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.html
@@ -487,6 +487,68 @@
</div>
</section>
+ <!-- The results this page can show, listed right under the preview since
both are about the same
+ steps: one chip each, carrying the step's name and an eye. A reader
with nothing to choose
+ from sees no section; an author always does, with the hint on how to
add steps. The chips are
+ tracked by step, not by object: a change rebuilds the choices as new
objects, and re-created
+ buttons would drop the keyboard focus from the chip just pressed. -->
+ <section
+ class="card respick"
+ *ngIf="authoring || resultChoices.length > 0">
+ <h3>Results shown here</h3>
+ <p>
+ {{ authoring ? "Click a name to look at that step; the eye sets
whether its result shows for everyone. Until you
+ choose, every final step is on, and an earlier step needs its result
view on the canvas first." : "Click a name
+ to bring its result to the top, and again to let the step go. The eye
hides a result from your page only." }}
+ </p>
+ <div class="opts">
+ <!-- Two buttons in one chip: the name reaches the result (and the
step it came from), the
+ eye decides whether it shows. Separate targets, so neither click
has a second meaning
+ depending on a mode (#9033). -->
+ <div
+ class="pill"
+ *ngFor="let choice of resultChoices; trackBy: trackByChoice"
+ [class.on]="choice.shown"
+ [class.lead-result]="leadsResults(choice.operatorID)">
+ <!-- A hidden result has no card to bring to the top, so its name
does nothing and does
+ not react to the pointer. Marked unavailable rather than
disabled, so it keeps its
+ place in the tab order and says why instead of going silent --
the eye beside it is
+ live, and that is how the result comes back.
+ `aria-current` carries what the ring shows: which result is the
one being looked at,
+ for a reader who does not see the ring. -->
+ <button
+ type="button"
+ class="pill-name"
+ [attr.aria-disabled]="!choice.shown"
+ [attr.aria-current]="leadsResults(choice.operatorID)"
+ [attr.title]="choice.shown ? null : 'Hidden. Turn its eye on to
show this result.'"
+ (click)="onChoiceClick(choice)">
+ {{ choice.label }}
+ </button>
+ <!-- A toggle button: the name stays constant and aria-pressed
carries the state, as on the
+ label wrapper's eye. A name that changed with the state would
announce the opposite of
+ what the state says ("Hide Limit, pressed" for a result that is
shown). -->
+ <button
+ type="button"
+ class="pill-eye"
+ [attr.aria-pressed]="choice.shown"
+ [attr.aria-label]="'Show ' + choice.label"
+ [attr.title]="choice.shown ? 'Shown here' : 'Hidden here'"
+ (click)="onToggleResult(choice)">
+ <i
+ nz-icon
+ [nzType]="choice.shown ? 'eye' : 'eye-invisible'"
+ aria-hidden="true"></i>
+ </button>
+ </div>
+ <p
+ class="hint"
+ *ngIf="resultChoices.length === 0">
+ No steps to choose from yet. Turn on a step's result view on the
canvas to feature it here.
+ </p>
+ </div>
+ </section>
+
<!-- Results, under the workflow that produced them. The section keeps its
place before a run so
the answer has a visible destination. -->
<section class="results">
@@ -501,7 +563,12 @@
yields one cannot be told from the graph, so a step earns its card
at runtime rather than
sitting on a permanent "No result yet." (a download/publish step
never would). -->
<ng-container *ngFor="let id of resultIdsToShow">
- <div class="card result">
+ <!-- The lead card (the step pointed at, moved to the front) wears the
canvas's selection
+ ring, so the move reads as "this is that step's result" rather
than a reshuffle. -->
+ <div
+ class="card result"
+ [style.order]="resultOrder(id)"
+ [class.lead-result]="leadsResults(id)">
<div class="result-head">
<span>{{ resultLabel(id) }}</span>
<!-- Zooming only means something once there is a picture to zoom.
-->
@@ -556,37 +623,5 @@
</div>
</ng-container>
</section>
-
- <!-- Which results show after a run. Everyone gets the picker: in edit
mode a pill sets the default
- for all readers (written to the config); otherwise it changes only
this viewer's page. A reader
- with nothing to choose from sees no section; an author always does,
with the hint on how to
- add steps. The pills are tracked by step, not by object: a toggle
rebuilds the choices as new
- objects, and re-created buttons would drop the keyboard focus from
the pill just pressed. -->
- <section
- class="card respick"
- *ngIf="authoring || resultChoices.length > 0">
- <h3>Results shown here</h3>
- <p>
- {{ authoring ? "What everyone sees after a run. Until you choose,
every final step is on; an earlier step needs
- its result view on the canvas first." : "Choose which results to show
after a run. This changes only your view."
- }}
- </p>
- <div class="opts">
- <button
- type="button"
- class="pill"
- *ngFor="let choice of resultChoices; trackBy: trackByChoice"
- [class.on]="choice.shown"
- [attr.aria-pressed]="choice.shown"
- (click)="onToggleResult(choice)">
- {{ choice.label }}
- </button>
- <p
- class="hint"
- *ngIf="resultChoices.length === 0">
- No steps to choose from yet. Turn on a step's result view on the
canvas to feature it here.
- </p>
- </div>
- </section>
</div>
</div>
diff --git
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.scss
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.scss
index 3889c57e24..747012fdf4 100644
---
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.scss
+++
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.scss
@@ -19,6 +19,8 @@
/* Colours are Texera's own: ng-zorro blue and the #d9d9d9 / #f0f0f0 neutrals.
*/
$blue: #1890ff;
+/* The blue a small icon is drawn in: #1890ff on the chip's tinted ground is
2.9:1, under 3:1. */
+$blue-dark: #096dd9;
$text: rgba(0, 0, 0, 0.85);
$text-2: rgba(0, 0, 0, 0.45);
$divider: #f0f0f0;
@@ -697,8 +699,13 @@ $shell: #fafafa;
/* ---------- results ---------- */
+/* A column, so a card can be put first with `order` instead of being moved in
the list the template
+ repeats: moving it moves its DOM, and a chart's srcdoc iframe reloads when
it is moved, losing the
+ zoom and legend the reader had set (see resultOrder). */
.results {
margin-top: 28px;
+ display: flex;
+ flex-direction: column;
}
/* Quiet on purpose: it marks where the answer will land, and should not
compete with the inputs
@@ -710,10 +717,19 @@ $shell: #fafafa;
font-size: 13.5px;
}
+/* The ring the editor draws round a selected step (workflow-editor's
highlightOptions stroke),
+ reused on the lead result card and on that step's pill so the three read as
one thing. */
+$lead-ring: #4a95ff;
+
.result {
margin-bottom: 14px;
overflow: hidden;
+ &.lead-result {
+ outline: 2px solid $lead-ring;
+ outline-offset: 2px;
+ }
+
.result-head {
display: flex;
align-items: center;
@@ -1056,7 +1072,7 @@ $shell: #fafafa;
}
.respick {
- margin-top: 26px;
+ margin-top: 14px;
padding: 15px 18px;
h3 {
@@ -1077,30 +1093,90 @@ $shell: #fafafa;
gap: 8px;
}
+ /* One result, two things to do with it: the name reaches it, the eye
decides whether it shows.
+ Two buttons rather than one with a mode, so a click always means the same
thing (#9033). They
+ share a border so the pair still reads as one chip. */
.pill {
- padding: 5px 12px;
+ display: inline-flex;
+ align-items: stretch;
border-radius: 15px;
font-size: 13px;
border: 1px solid $border;
background: #fff;
color: $text-2;
- cursor: pointer;
+ overflow: hidden;
- &:hover {
- border-color: $blue;
- color: $blue;
+ button {
+ appearance: none;
+ border: 0;
+ background: none;
+ color: inherit;
+ font: inherit;
+ cursor: pointer;
+
+ &:focus-visible {
+ outline: 2px solid $blue;
+ outline-offset: -2px;
+ }
}
- &:focus-visible {
- outline: 2px solid $blue;
- outline-offset: 2px;
+ .pill-name {
+ padding: 5px 11px;
+
+ &:hover:not([aria-disabled="true"]) {
+ color: $blue;
+ }
+
+ /* Hidden: there is no card to bring to the top, so the name neither
reacts nor invites. */
+ &[aria-disabled="true"] {
+ cursor: default;
+ opacity: 0.55;
+ }
+ }
+
+ /* Its own segment, with a rule between: a target to aim at rather than an
icon tucked into the
+ corner of the name's button. */
+ /* The only control that brings a hidden result back, so it is drawn to be
found: a dimmed icon
+ measured 2.06:1 against the card, under the 3:1 a control's shape
needs. Ink rather than
+ opacity, and the darker blue below, put both states past it (5.7:1 and
4.5:1). */
+ .pill-eye {
+ padding: 5px 10px;
+ font-size: 13px;
+ border-left: 1px solid $border;
+ color: rgba(0, 0, 0, 0.6);
+
+ &:hover {
+ color: $blue-dark;
+ background: rgba(24, 144, 255, 0.08);
+ }
+ }
+
+ /* Only a chip with something to press lights up as a whole; a hidden one
answers at its eye,
+ which has a hover of its own. */
+ &.on:hover {
+ border-color: $blue;
}
+ /* Shown: the result has a card after a run. Hidden, the name stays -- it
is how the result is
+ brought back -- but the chip reads as off. */
&.on {
background: rgba(24, 144, 255, 0.1);
border-color: $blue;
color: $blue;
- font-weight: 500;
+
+ .pill-name {
+ font-weight: 500;
+ }
+
+ .pill-eye {
+ border-left-color: rgba(24, 144, 255, 0.35);
+ color: $blue-dark;
+ }
+ }
+
+ &.lead-result {
+ outline: 2px solid $lead-ring;
+ outline-offset: 2px;
}
}
}
diff --git
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts
index 8b2975dace..0cd2ac4b20 100644
---
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts
+++
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts
@@ -24,7 +24,7 @@ import { Workflow } from "../../../common/type/workflow";
import { WorkflowFormComponent } from "./workflow-form.component";
import { setupHarness, formViewWorkflow, resolved } from
"./workflow-form.spec-harness";
-import { USER_WORKFLOW, workspaceCanvasUrl, workspaceFormUrl } from
"../../../app-routing.constant";
+import { USER_WORKFLOW, workspaceCanvasUrl } from
"../../../app-routing.constant";
import { DefaultView } from
"../../../dashboard/type/workflow-metadata.interface";
import { FORM_DEBOUNCE_TIME_MS } from
"../../service/execute-workflow/execute-workflow.service";
import { ExecutionState } from "../../types/execute-workflow.interface";
@@ -2275,7 +2275,7 @@ describe("WorkflowFormComponent", () => {
expect(component.shownResultIds).toEqual([]);
});
- it("lets a viewer pick their own results for this page, without writing
anything", () => {
+ it("lets a viewer hide a result on their own page, and bring it back,
without writing anything", () => {
build(formViewWorkflow).ngOnInit();
saved();
h.graphOperators.push({ operatorID: "mid", operatorType: "Filter" });
@@ -2287,15 +2287,17 @@ describe("WorkflowFormComponent", () => {
const mid = component.resultChoices.find(c => c.operatorID === "mid")!;
const last = component.resultChoices.find(c => c.operatorID === "last")!;
- // Not in edit mode: the toggle is the viewer's own, so nothing goes to
the shared config.
+ // Not in edit mode: the eye is the viewer's own, so nothing goes to the
shared config.
component.onToggleResult(mid);
expect(component.shownResultIds).toEqual(["last", "mid"]);
component.onToggleResult(last);
expect(component.shownResultIds).toEqual(["mid"]);
expect(h.formBindingService.toggleShownResult).not.toHaveBeenCalled();
- // The picker's pills follow the viewer's choice.
- expect(component.resultChoices.find(c => c.operatorID ===
"last")?.shown).toBe(false);
- expect(component.resultChoices.find(c => c.operatorID ===
"mid")?.shown).toBe(true);
+ // The chips follow the viewer's choice, and a hidden one keeps its name
so it can come back.
+ expect(component.resultChoices.map(c => [c.operatorID,
c.shown])).toEqual([
+ ["mid", true],
+ ["last", false],
+ ]);
// Entering edit mode edits the default for everyone, so the viewer's
own pick gives way to it.
component.toggleAuthoring();
@@ -2349,6 +2351,7 @@ describe("WorkflowFormComponent", () => {
const last = { operatorID: "last", operatorType: "Limit", isDisabled:
false };
h.graphOperators.push(last);
h.terminalIds.add("last");
+ h.anyResultIds.add("last"); // reading, the picker names the results
there are
(component as any).readConfig();
expect(component.shownResultIds).toEqual(["last"]);
expect(component.resultChoices.map(c => c.operatorID)).toEqual(["last"]);
@@ -2368,6 +2371,7 @@ describe("WorkflowFormComponent", () => {
const op = { operatorID: "last", operatorType: "Limit",
customDisplayName: "Old name" };
h.graphOperators.push(op);
h.terminalIds.add("last");
+ h.anyResultIds.add("last");
(component as any).readConfig();
expect(component.resultChoices.map(c => c.label)).toEqual(["Old name"]);
@@ -2753,6 +2757,300 @@ describe("WorkflowFormComponent", () => {
});
});
+ describe("the pointed-at step's result goes first", () => {
+ // Three shown steps, all with a result, cards in the saved order a, b, c.
+ const threeCards = () => {
+ for (const id of ["a", "b", "c"]) {
+ h.hasOperatorIds.add(id);
+ h.graphOperators.push({ operatorID: id, operatorType: "Filter" });
+ h.viewResultIds.add(id);
+ h.anyResultIds.add(id);
+ }
+ formBindingService.getConfig.mockReturnValue({
+ instruction: undefined,
+ fields: [],
+ shownResultIds: ["a", "b", "c"],
+ });
+ (component as any).readConfig();
+ expect(component.resultIdsToShow).toEqual(["a", "b", "c"]);
+ };
+
+ const highlight = (full: string[], delta: string[] = full) => {
+ h.highlightedIds.length = 0;
+ h.highlightedIds.push(...full);
+ h.highlightStream.next(delta);
+ };
+
+ /**
+ * The order the reader sees. The cards keep their saved order in the
document and are laid out
+ * by `order` (see resultOrder), so that a chart's iframe is never moved
and reloaded; sorting by
+ * it here reads back what the column shows. `sort` is stable, so equal
cards keep their order.
+ */
+ const asShown = () =>
+ [...component.resultIdsToShow].sort((x, y) => component.resultOrder(x) -
component.resultOrder(y));
+
+ it("moves the selected step's card to the front, ringed; the others keep
the saved order", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ expect(["a", "b", "c"].map(id =>
component.leadsResults(id))).toEqual([false, false, false]);
+
+ highlight(["b"]);
+ expect(asShown()).toEqual(["b", "a", "c"]);
+ expect(["a", "b", "c"].map(id =>
component.leadsResults(id))).toEqual([false, true, false]);
+
+ highlight(["c"]);
+ expect(asShown()).toEqual(["c", "a", "b"]);
+ expect(["a", "b", "c"].map(id =>
component.leadsResults(id))).toEqual([false, false, true]);
+ });
+
+ it("leaves the cards where they are when the clicked step has no card", ()
=> {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ h.hasOperatorIds.add("mid");
+ h.graphOperators.push({ operatorID: "mid", operatorType: "Filter" }); //
not shown
+ highlight(["c"]);
+ expect(asShown()).toEqual(["c", "a", "b"]);
+
+ // The pointed-at step is now one without a card: nothing leads, so the
usual order is back,
+ // and no ring anywhere (not on the usual first card either).
+ highlight(["mid"]);
+
+ expect(asShown()).toEqual(["a", "b", "c"]);
+ expect(component.shownResultIds).toEqual(["a", "b", "c"]); // the shown
set itself is untouched
+ expect(["a", "mid"].map(id =>
component.leadsResults(id))).toEqual([false, false]);
+ });
+
+ it("puts the cards back once the step is deselected: panel closed, empty
canvas, or a multi-select", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ highlight(["b"]);
+ expect(asShown()).toEqual(["b", "a", "c"]);
+
+ component.closeOperatorPanel();
+ expect(component.selectedOperatorId).toBeUndefined();
+ expect(asShown()).toEqual(["a", "b", "c"]);
+ expect(component.leadsResults("b")).toBe(false);
+
+ // Clicking empty canvas: the un-highlight stream, nothing left selected.
+ highlight(["b"]);
+ h.highlightedIds.length = 0;
+ h.unhighlightStream.next(["b"]);
+ expect(asShown()).toEqual(["a", "b", "c"]);
+
+ // Two selected: no single step is pointed at.
+ highlight(["b"]);
+ highlight(["a", "b"], ["a"]);
+ expect(component.selectedOperatorId).toBeUndefined();
+ expect(asShown()).toEqual(["a", "b", "c"]);
+ });
+
+ it("takes effect once the clicked step produces a result", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ h.anyResultIds.delete("c"); // c has not produced anything yet
+ highlight(["c"]);
+ expect(asShown()).toEqual(["a", "b"]);
+
+ h.anyResultIds.add("c");
+
+ expect(asShown()).toEqual(["c", "a", "b"]);
+ });
+
+ it("names every result a reader could have, hidden ones included, so they
can come back", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ h.graphOperators.push({ operatorID: "off", operatorType: "Filter" });
+ h.viewResultIds.add("off");
+ (component as any).readConfig();
+ expect(component.resultChoices.map(c => c.operatorID)).toEqual(["a",
"b", "c", "off"]);
+ expect(component.resultChoices.map(c => c.shown)).toEqual([true, true,
true, false]);
+
+ // Hidden on this page: the name stays, marked off, and its card goes.
+ component.onToggleResult(component.resultChoices.find(c => c.operatorID
=== "b")!);
+
+ expect(asShown()).toEqual(["a", "c"]);
+ expect(component.resultChoices.find(c => c.operatorID ===
"b")?.shown).toBe(false);
+ });
+
+ it("a click on a result name selects that step on the preview, whose card
then leads", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ (component as any).workflowEverOpened = true; // the strip's canvas has
been built before
+ const choice = (id: string) => component.resultChoices.find(c =>
c.operatorID === id)!;
+
+ component.onChoiceClick(choice("b"));
+
+ // Acted on at once, and it is the same selection a click on the step
makes -- through the
+ // action service, so co-editors see it too. The preview is left as it
was.
+ expect(h.serviceHighlightOperators).toHaveBeenCalledWith(false, "b");
+ expect(h.updateSharedModelAwareness).toHaveBeenCalledWith("highlighted",
["b"]);
+ expect(component.selectedOperatorId).toBe("b");
+ expect(asShown()).toEqual(["b", "a", "c"]);
+ expect(component.leadsResults("b")).toBe(true);
+
+ component.onChoiceClick(choice("c"));
+ expect(component.selectedOperatorId).toBe("c");
+ expect(asShown()).toEqual(["c", "a", "b"]);
+
+ // A deselection on the preview (empty canvas) ends the lead too, being
the same selection.
+ h.highlightedIds.length = 0;
+ h.unhighlightStream.next(["c"]);
+ expect(asShown()).toEqual(["a", "b", "c"]);
+ expect(formBindingService.toggleShownResult).not.toHaveBeenCalled();
+ });
+
+ it("ignores the name of a hidden result: there is no card to bring up", ()
=> {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ (component as any).workflowEverOpened = true;
+ h.graphOperators.push({ operatorID: "off", operatorType: "Filter" });
+ h.viewResultIds.add("off");
+ (component as any).readConfig();
+ const off = component.resultChoices.find(c => c.operatorID === "off")!;
+ expect(off.shown).toBe(false);
+
+ component.onChoiceClick(off);
+
+ expect(h.serviceHighlightOperators).not.toHaveBeenCalled();
+ expect(component.selectedOperatorId).toBeUndefined();
+ expect(component.resultIdsToShow).toEqual(["a", "b", "c"]);
+ });
+
+ it("hiding the selected step's result and showing it again puts its card
back on top", () => {
+ // The card at the front is the selected step's, so the two cannot drift
apart: an earlier
+ // revision kept the lead beside the selection, and after hide/show the
name read as "already
+ // leading" and let the step go instead of bringing the card back.
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ (component as any).workflowEverOpened = true;
+ const choice = (id: string) => component.resultChoices.find(c =>
c.operatorID === id)!;
+ component.onChoiceClick(choice("b"));
+ expect(asShown()).toEqual(["b", "a", "c"]);
+
+ component.onToggleResult(choice("b")); // hide it: its card goes, the
step stays selected
+ expect(asShown()).toEqual(["a", "c"]);
+ expect(component.selectedOperatorId).toBe("b");
+
+ component.onToggleResult(choice("b")); // show it again
+
+ expect(asShown()).toEqual(["b", "a", "c"]);
+ expect(component.leadsResults("b")).toBe(true);
+ });
+
+ // Shift-selecting two steps on the preview leaves neither of them THE
selection, so a name click
+ // has to make one. The wrapper drops an id it already holds before it
would clear the others,
+ // so without letting go first the click did nothing at all (Copilot on
#9334).
+ it("picks one step out of a multi-select, rather than doing nothing", ()
=> {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ highlight(["a", "b"]);
+ expect(component.selectedOperatorId).toBeUndefined();
+ expect(asShown()).toEqual(["a", "b", "c"]);
+
+ component.onChoiceClick({ operatorID: "b", label: "b", shown: true });
+
+ expect(h.serviceUnhighlightOperators).toHaveBeenCalledWith("a", "b");
+ expect(h.serviceHighlightOperators).toHaveBeenCalledWith(false, "b");
+ expect(component.selectedOperatorId).toBe("b");
+ expect(asShown()).toEqual(["b", "a", "c"]);
+ });
+
+ it("clicking the name of the step already selected lets it go", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ (component as any).workflowEverOpened = true;
+ const choice = (id: string) => component.resultChoices.find(c =>
c.operatorID === id)!;
+ component.onChoiceClick(choice("b"));
+ expect(component.selectedOperatorId).toBe("b");
+ h.serviceHighlightOperators.mockClear();
+
+ component.onChoiceClick(choice("b"));
+
+ expect(h.serviceUnhighlightOperators).toHaveBeenCalledWith("b");
+ expect(h.serviceHighlightOperators).not.toHaveBeenCalled();
+ expect(component.selectedOperatorId).toBeUndefined();
+ expect(asShown()).toEqual(["a", "b", "c"]);
+ expect(component.leadsResults("b")).toBe(false);
+ });
+
+ it("leaves the preview as the reader had it, so the page does not move
under the click", () => {
+ vi.useFakeTimers();
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ expect(component.workflowOpen).toBe(false);
+
+ component.onChoiceClick(component.resultChoices.find(c => c.operatorID
=== "b")!);
+
+ // The step is selected and its card leads, but the strip stays closed:
opening it would push
+ // the picker and the results a third of the page down, away from the
name just clicked.
+ expect(h.serviceHighlightOperators).toHaveBeenCalledWith(false, "b");
+ expect(component.selectedOperatorId).toBe("b");
+ expect(asShown()).toEqual(["b", "a", "c"]);
+ expect(component.workflowOpen).toBe(false);
+ expect((component as any).workflowEverOpened).toBe(false);
+ vi.useRealTimers();
+ });
+
+ it("a selected step without a card leads as soon as the author's list
gives it one", () => {
+ build(formViewWorkflow).ngOnInit();
+ threeCards();
+ h.hasOperatorIds.add("mid");
+ h.graphOperators.push({ operatorID: "mid", operatorType: "Filter" });
+ h.viewResultIds.add("mid");
+ h.anyResultIds.add("mid");
+ highlight(["mid"]);
+ expect(asShown()).toEqual(["a", "b", "c"]);
+
+ component.authoring = true;
+ formBindingService.toggleShownResult.mockImplementation(() =>
+ formBindingService.getConfig.mockReturnValue({
+ instruction: undefined,
+ fields: [],
+ shownResultIds: ["mid", "a", "b", "c"],
+ })
+ );
+ (component as any).rebuildResultChoices();
+ component.onToggleResult(component.resultChoices.find(c => c.operatorID
=== "mid")!);
+
+ expect(component.resultIdsToShow).toEqual(["mid", "a", "b", "c"]);
+ expect(component.leadsResults("mid")).toBe(true);
+ });
+
+ it("editing, the eye sets the default everyone sees, and leads nothing by
itself", () => {
+ build(formViewWorkflow).ngOnInit();
+ (component as any).workflowEverOpened = true;
+ h.graphOperators.push({ operatorID: "mid", operatorType: "Filter" });
+ h.graphOperators.push({ operatorID: "last", operatorType: "Limit" });
+ h.hasOperatorIds.add("mid");
+ h.hasOperatorIds.add("last");
+ h.viewResultIds.add("mid");
+ h.terminalIds.add("last");
+ h.anyResultIds.add("mid");
+ h.anyResultIds.add("last");
+ formBindingService.getConfig.mockReturnValue({ instruction: undefined,
fields: [], shownResultIds: ["last"] });
+ component.toggleAuthoring();
+ // The service appends to the saved list; the re-read picks that up.
+ formBindingService.toggleShownResult.mockImplementation(() =>
+ formBindingService.getConfig.mockReturnValue({
+ instruction: undefined,
+ fields: [],
+ shownResultIds: ["last", "mid"],
+ })
+ );
+
+ component.onToggleResult(component.resultChoices.find(c => c.operatorID
=== "mid")!);
+
+ expect(formBindingService.toggleShownResult).toHaveBeenCalledWith("mid",
["last"]);
+ expect(component.resultIdsToShow).toEqual(["last", "mid"]); // the saved
order, nothing leading
+ expect(component.leadsResults("mid")).toBe(false);
+ expect(h.serviceHighlightOperators).not.toHaveBeenCalled(); // the eye
does not select
+
+ // The name selects, in edit mode as well: an author can look at the
step a result came from.
+ component.onChoiceClick(component.resultChoices.find(c => c.operatorID
=== "mid")!);
+ expect(h.serviceHighlightOperators).toHaveBeenCalledWith(false, "mid");
+ });
+ });
+
describe("author mode", () => {
it("enters edit mode: opens the workflow, enables modification, re-reads
the config", () => {
build(formViewWorkflow).ngOnInit();
@@ -2905,7 +3203,7 @@ describe("WorkflowFormComponent", () => {
expect(component.resultChoices.map(c => c.operatorID)).toContain("mid");
});
- it("builds the picker for a reader too, so they can choose what to see",
() => {
+ it("builds the picker for a reader too, so they can reach and hide
results", () => {
build({ ...formViewWorkflow, readonly: true }).ngOnInit();
h.graphOperators.push({ operatorID: "last", operatorType: "Limit" });
h.terminalIds.add("last");
@@ -2916,9 +3214,9 @@ describe("WorkflowFormComponent", () => {
expect(component.resultChoices[0].shown).toBe(true);
});
- it("does not offer a reader a saved pick whose eye is off, since it could
never turn on", () => {
+ it("does not offer a reader a saved pick whose eye is off, since it could
never show", () => {
// The author's stale pick stays listed in edit mode so it can be
un-picked (see above); for a
- // reader nothing is materialised for it, so a pill they can click but
never turn on is left out.
+ // reader nothing is materialised for it, so a chip they could turn on
to no effect is left out.
build({ ...formViewWorkflow, readonly: true }).ngOnInit();
h.graphOperators.push({ operatorID: "stale-pick", operatorType: "Filter"
});
h.graphOperators.push({ operatorID: "chosen-mid", operatorType: "Filter"
});
diff --git
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts
index 610488e05a..06af03b12e 100644
---
a/frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts
+++
b/frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts
@@ -185,13 +185,13 @@ export class WorkflowFormComponent implements OnInit,
OnDestroy {
/** While authoring, the instruction is edited as raw markdown ("write") or
shown rendered
* ("preview"); a reader always sees it rendered. */
public instructionMode: "write" | "preview" = "write";
- /** The "which results to show" picker: every candidate step with its shown
flag. Everyone sees it:
- * in edit mode a toggle sets the default for all readers (saved in the
config); otherwise it is
- * the viewer's own choice for this page (viewerResultIds), never written
anywhere. */
+ /** The results listed under the preview: every candidate step with its
shown flag. The name
+ * reaches the result, the eye beside it decides whether it shows -- the
author's default for
+ * everyone while editing (saved in the config), the viewer's own page
otherwise. */
public resultChoices: ResultChoice[] = [];
- /** A viewer's own pick of results for this page, once they have toggled
anything; undefined means
- * "the author's default". Kept for the page's lifetime only, and cleared
on entering edit mode so
- * the author edits the real default rather than their own view of it. */
+ /** A viewer's own pick of results for this page, once they have hidden or
brought one back;
+ * undefined means "the author's default". Kept for the page's lifetime
only, and cleared on
+ * entering edit mode so the author edits the real default rather than
their own view of it. */
private viewerResultIds?: Set<string>;
/** The exposed inputs, resolved against the live graph, and the formly
field built for each. */
@@ -815,10 +815,10 @@ export class WorkflowFormComponent implements OnInit,
OnDestroy {
* operator (no enabled downstream) as well as every view-result operator,
so a terminal's result is
* always available. The author's default is the saved list (shownResultIds:
exactly those steps, an
* empty list meaning none) or, until the author has chosen, every terminal
step. A viewer who has
- * toggled the picker on this page sees their own set instead
(viewerResultIds), which is never
- * written anywhere. Either way this is a pure display filter that reads the
graph and never writes
- * it, so a normal canvas user's result-viewing is unaffected. A step that
is neither viewed nor
- * terminal (or was deleted) drops out rather than rendering a stale card.
+ * hidden one on this page sees their own set instead (viewerResultIds),
which is never written
+ * anywhere. Either way this is a pure display filter that reads the graph
and never writes it, so a
+ * normal canvas user's result-viewing is unaffected. A step that is neither
viewed nor terminal (or
+ * was deleted) drops out rather than rendering a stale card.
*/
private refreshShownResults(): void {
const graph = this.workflowActionService.getTexeraGraph();
@@ -1334,6 +1334,63 @@ export class WorkflowFormComponent implements OnInit,
OnDestroy {
return this.shownResultIds.filter(id =>
this.workflowResultService.hasNonEmptyResult(id));
}
+ /**
+ * Whether this step's card leads the Results: it is the selected step, and
it has a card to lead
+ * with. What the ring marks, on the card and on the step's chip, and what
puts the card first
+ * (see resultOrder). Read from the selection rather than kept beside it: a
copy drifted from it
+ * (hiding the selected step's result cleared the lead but not the
selection, and its name then
+ * read as "already leading" and let the step go instead of bringing the
card back).
+ */
+ public leadsResults(operatorID: string): boolean {
+ return this.selectedOperatorId === operatorID &&
this.resultIdsToShow.includes(operatorID);
+ }
+
+ /**
+ * Where a card sits among the Results: the selected step's first, the rest
in the saved order.
+ *
+ * The cards are laid out in a column and ordered by this, rather than by
their order in the list
+ * the template repeats. Moving them in the list moves their DOM, and a
chart's srcdoc iframe
+ * reloads when it is moved -- the picture comes back, but the zoom, the pan
and the legend the
+ * reader had set do not, so selecting a step reset a chart they were
reading (Copilot on #9334).
+ * The cards keep their order in the document, which is also the order they
are read in; the one
+ * being looked at is named there by its chip's aria-current rather than by
its position.
+ */
+ public resultOrder(operatorID: string): number {
+ return this.leadsResults(operatorID) ? -1 : 0;
+ }
+
+ /**
+ * A result's name, in either mode: a click selects that step, the same
selection clicking the step
+ * on the preview makes -- through the action service, so co-editors see the
ring as they do for a
+ * canvas click -- and its card comes to the front, ringed. Two steps with
the same name are told
+ * apart by which one lights up. Clicking the name of the step already
selected lets it go, putting
+ * the cards back. Nothing is written either way.
+ *
+ * A hidden result has no card to bring to the top, so its name does nothing
at all: the template
+ * marks it unavailable, and this ignores it in case it is reached another
way.
+ *
+ * The preview is left as the reader had it: opening it from here moved the
results a third of the
+ * page down, out from under the name just clicked (#9033).
+ */
+ public onChoiceClick(choice: ResultChoice): void {
+ if (!choice.shown) {
+ return;
+ }
+ if (this.selectedOperatorId === choice.operatorID) {
+ this.closeOperatorPanel();
+ return;
+ }
+ // A step that is already highlighted as part of a multi-select has to be
let go first. The
+ // wrapper drops an id it is already holding before it gets as far as
clearing the others, so
+ // shift-selecting two steps on the preview and then clicking one of their
names left both of
+ // them selected and no card leading -- the click did nothing (Copilot on
#9334).
+ const highlighted =
this.workflowActionService.getJointGraphWrapper().getCurrentHighlightedOperatorIDs();
+ if (highlighted.includes(choice.operatorID)) {
+ this.workflowActionService.unhighlightOperators(...highlighted);
+ }
+ this.workflowActionService.highlightOperators(false, choice.operatorID);
+ }
+
public isTabularResult(operatorID: string): boolean {
return this.workflowResultService.hasPaginatedResult(operatorID);
}
@@ -1491,8 +1548,8 @@ export class WorkflowFormComponent implements OnInit,
OnDestroy {
if (this.authoring) {
// An author picks fields off the workflow, so show it.
this.showWorkflow();
- // In edit mode the picker sets the default for everyone, so the
author's own view of the
- // results (if they toggled any as a viewer) gives way to that default.
+ // In edit mode the eye sets the default for everyone, so the author's
own view of the
+ // results (if they hid any as a viewer) gives way to that default.
this.viewerResultIds = undefined;
} else {
this.workflowOpen = false;
@@ -1593,12 +1650,16 @@ export class WorkflowFormComponent implements OnInit,
OnDestroy {
}
/**
- * A pill in the picker. In edit mode this sets the default everyone sees:
the step joins or leaves
- * the saved list (which the first choice starts from the final steps, the
default until then), and
- * the config is re-read. Anyone else, a writer merely viewing included,
only changes their own view
- * of this page: nothing is written, so a reader without write access can
choose too.
+ * The eye beside a result's name: whether that result shows after a run.
Editing, it sets the
+ * default everyone gets -- the step joins or leaves the saved list (the
first choice starts the
+ * list from the final steps, the default until then) and the config is
re-read. Otherwise it
+ * changes only this viewer's page: nothing is written, so a reader without
write access can hide
+ * a result they do not care about and bring it back.
*/
public onToggleResult(choice: ResultChoice): void {
+ // Nothing to do about the order here: the card at the front is the
selected step's, so hiding
+ // that result takes its card away and showing it again brings it back to
the front, with the
+ // step still selected throughout.
if (this.authoring && this.canEdit) {
// Re-read once, here: the write's own announcement would rebuild the
form a second time.
this.reflectLocally(() =>
@@ -1876,6 +1937,9 @@ export class WorkflowFormComponent implements OnInit,
OnDestroy {
const graph = this.workflowActionService.getTexeraGraph();
this.selectedOperatorId =
highlighted.length === 1 && graph.hasOperator(highlighted[0]) ?
highlighted[0] : undefined;
+ // The selected step's result leads the Results section while it is
selected (resultIdsToShow),
+ // so the reader can see what a step produced without scrolling past the
others; deselecting
+ // (empty canvas, a multi-select, the panel's close button) puts the cards
back in their order.
this.cdr.detectChanges();
}
diff --git
a/frontend/src/app/workspace/component/workflow-form/workflow-form.rendered.spec.ts
b/frontend/src/app/workspace/component/workflow-form/workflow-form.rendered.spec.ts
index 07b0048102..7437037ce8 100644
---
a/frontend/src/app/workspace/component/workflow-form/workflow-form.rendered.spec.ts
+++
b/frontend/src/app/workspace/component/workflow-form/workflow-form.rendered.spec.ts
@@ -34,7 +34,8 @@ import {
StopOutline,
WarningOutline,
LoadingOutline,
- LockOutline,
+ EyeOutline,
+ EyeInvisibleOutline,
MinusOutline,
PlusOutline,
UpOutline,
@@ -281,7 +282,8 @@ describe("WorkflowFormComponent (rendered template)", () =>
{
StopOutline,
WarningOutline,
LoadingOutline,
- LockOutline,
+ EyeOutline,
+ EyeInvisibleOutline,
MinusOutline,
PlusOutline,
UpOutline,
@@ -556,19 +558,28 @@ describe("WorkflowFormComponent (rendered template)", ()
=> {
// A reader with nothing to choose from gets no section.
expect(el(".respick")).toBeNull();
- // A reader with candidates gets the picker, worded as their own view.
+ // A reader with candidates gets the picker: a name to reach a result, an
eye to hide it.
c.resultChoices = [{ operatorID: "last", label: "Limit", shown: true }];
fixture.detectChanges();
expect(el(".respick")).not.toBeNull();
- expect(el(".respick p")?.textContent).toContain("only your view");
- expect(el(".respick .pill")?.textContent?.trim()).toBe("Limit");
+ expect(el(".respick h3")?.textContent?.trim()).toBe("Results shown here");
+ expect(el(".respick p")?.textContent).toContain("hides a result from your
page");
+ expect(el(".respick .pill-name")?.textContent?.trim()).toBe("Limit");
+ // One constant name, the state on aria-pressed: a name that changed with
it would announce the
+ // opposite of what the state says.
+ expect(el(".respick .pill-eye")?.getAttribute("aria-label")).toBe("Show
Limit");
+ expect(el(".respick
.pill-eye")?.getAttribute("aria-pressed")).toBe("true");
+ c.resultChoices = [{ operatorID: "last", label: "Limit", shown: false }];
+ fixture.detectChanges();
+ expect(el(".respick .pill-eye")?.getAttribute("aria-label")).toBe("Show
Limit");
+ expect(el(".respick
.pill-eye")?.getAttribute("aria-pressed")).toBe("false");
// An author always gets it, with the hint on how to add steps, worded as
the default for all.
c.authoring = true;
c.resultChoices = [];
fixture.detectChanges();
expect(el(".respick")).not.toBeNull();
- expect(el(".respick p")?.textContent).toContain("What everyone sees");
+ expect(el(".respick p")?.textContent).toContain("sets whether its result
shows for everyone");
expect(el(".respick .hint")?.textContent).toContain("No steps to choose
from yet");
c.resultChoices = [
@@ -576,27 +587,40 @@ describe("WorkflowFormComponent (rendered template)", ()
=> {
{ operatorID: "viz", label: "Chart", shown: true },
];
fixture.detectChanges();
+ const click = vi.spyOn(c, "onChoiceClick").mockImplementation(() => {});
const toggle = vi.spyOn(c, "onToggleResult").mockImplementation(() => {});
- const pills = Array.from(fixture.nativeElement.querySelectorAll(".respick
.pill")) as HTMLButtonElement[];
- expect(pills.map(p => p.textContent?.trim())).toEqual(["Filter", "Chart"]);
- // The pressed state is exposed to assistive tech as well as styled.
- expect(pills.map(p => p.getAttribute("aria-pressed"))).toEqual(["false",
"true"]);
+ const pills = Array.from(fixture.nativeElement.querySelectorAll(".respick
.pill")) as HTMLElement[];
+ const names = Array.from(fixture.nativeElement.querySelectorAll(".respick
.pill-name")) as HTMLButtonElement[];
+ const eyes = Array.from(fixture.nativeElement.querySelectorAll(".respick
.pill-eye")) as HTMLButtonElement[];
+ expect(names.map(p => p.textContent?.trim())).toEqual(["Filter", "Chart"]);
+ // A hidden result's name is not pressable: no card to bring up, and it
says so. Marked rather
+ // than disabled, so it keeps its place in the tab order when the eye
beside it is pressed.
+ expect(names.map(p => p.getAttribute("aria-disabled"))).toEqual(["true",
"false"]);
+ expect(names.map(p => p.getAttribute("title"))).toEqual(["Hidden. Turn its
eye on to show this result.", null]);
+ expect(names.every(p => !p.disabled)).toBe(true);
+ // The eye is the toggle, and its pressed state is exposed to assistive
tech as well as styled.
+ expect(eyes.map(p => p.getAttribute("aria-pressed"))).toEqual(["false",
"true"]);
expect(pills[1].classList.contains("on")).toBe(true);
expect(el(".respick .hint")).toBeNull();
- pills[0].click();
+
+ // Two targets, two meanings: the name reaches the result, the eye decides
whether it shows.
+ names[1].click();
+ expect(click).toHaveBeenCalledWith(c.resultChoices[1]);
+ expect(toggle).not.toHaveBeenCalled();
+ eyes[0].click();
expect(toggle).toHaveBeenCalledWith(c.resultChoices[0]);
// A toggle re-reads the config and rebuilds the choices as new objects.
The pill just pressed
// must be the same element afterwards (tracked by step), or the keyboard
focus on it is lost.
- pills[0].focus();
+ eyes[0].focus();
c.resultChoices = [
{ operatorID: "mid", label: "Filter", shown: true },
{ operatorID: "viz", label: "Chart", shown: true },
];
fixture.detectChanges();
- const after = Array.from(fixture.nativeElement.querySelectorAll(".respick
.pill")) as HTMLButtonElement[];
- expect(after[0]).toBe(pills[0]);
- expect(document.activeElement).toBe(pills[0]);
+ const after = Array.from(fixture.nativeElement.querySelectorAll(".respick
.pill-eye")) as HTMLButtonElement[];
+ expect(after[0]).toBe(eyes[0]);
+ expect(document.activeElement).toBe(eyes[0]);
expect(after[0].getAttribute("aria-pressed")).toBe("true");
});
@@ -815,6 +839,57 @@ describe("WorkflowFormComponent (rendered template)", ()
=> {
expect(el(".result .result-body")).not.toBeNull();
});
+ it("keeps the picker between the preview and the results", () => {
+ fixture.detectChanges();
+ finishLoad();
+ const c = fixture.componentInstance;
+ c.resultChoices = [{ operatorID: "last", label: "Limit", shown: true }];
+ fixture.detectChanges();
+
+ const preview = el(".wf")!;
+ const picker = el(".respick")!;
+ const results = el(".results")!;
+ expect(preview.compareDocumentPosition(picker) &
Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(picker.compareDocumentPosition(results) &
Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ });
+
+ it("rings the lead result card and that step's pill, and only those", () => {
+ fixture.detectChanges();
+ finishLoad();
+ const c = fixture.componentInstance;
+ const wrs: any = TestBed.inject(WorkflowResultService);
+ wrs.hasNonEmptyResult = () => true;
+ c.shownResultIds = ["op-1", "op-2"];
+ c.resultChoices = [
+ { operatorID: "op-1", label: "Filter", shown: true },
+ { operatorID: "op-2", label: "Chart", shown: true },
+ ];
+ fixture.detectChanges();
+ const cards = () =>
Array.from(fixture.nativeElement.querySelectorAll(".result")) as HTMLElement[];
+ const pills = () =>
Array.from(fixture.nativeElement.querySelectorAll(".respick .pill")) as
HTMLElement[];
+ const names = () =>
Array.from(fixture.nativeElement.querySelectorAll(".respick .pill-name")) as
HTMLElement[];
+ expect(cards().map(e =>
e.classList.contains("lead-result"))).toEqual([false, false]);
+ expect(names().map(e => e.getAttribute("aria-current"))).toEqual(["false",
"false"]);
+
+ // The cards sit in the saved order in the document, and are laid out by
`order`: moving them
+ // would move a chart's iframe and reload it (see resultOrder).
+ const titles = () => cards().map(e => e.querySelector(".result-head
span")?.textContent?.trim());
+ const laidOut = () => cards().map(e => e.style.order);
+ expect(titles()).toEqual(["op-1", "op-2"]);
+ expect(laidOut()).toEqual(["0", "0"]);
+
+ // op-2 pointed at: it is laid out first and ringed, so is its pill;
nothing else is.
+ c.selectedOperatorId = "op-2";
+ fixture.detectChanges();
+
+ expect(titles()).toEqual(["op-1", "op-2"]);
+ expect(laidOut()).toEqual(["0", "-1"]);
+ expect(cards().map(e =>
e.classList.contains("lead-result"))).toEqual([false, true]);
+ expect(pills().map(e =>
e.classList.contains("lead-result"))).toEqual([false, true]);
+ // The ring has a programmatic twin, for a reader who cannot see it.
+ expect(names().map(e => e.getAttribute("aria-current"))).toEqual(["false",
"true"]);
+ });
+
it("mounts the step panel from the start, hidden until a step is selected",
() => {
fixture.detectChanges();
finishLoad();
diff --git
a/frontend/src/app/workspace/component/workflow-form/workflow-form.spec-harness.ts
b/frontend/src/app/workspace/component/workflow-form/workflow-form.spec-harness.ts
index 0bce6e34ff..95c3eecd07 100644
---
a/frontend/src/app/workspace/component/workflow-form/workflow-form.spec-harness.ts
+++
b/frontend/src/app/workspace/component/workflow-form/workflow-form.spec-harness.ts
@@ -119,6 +119,25 @@ export function setupHarness() {
unhighlightOperators(...ops);
updateSharedModelAwareness("highlighted", [...highlightedIds]);
});
+ // The action service's highlight, modelled as the real chain. The page only
ever asks for a single
+ // selection (`highlightOperators(false, id)`), so the wrapper replaces the
selection rather than
+ // adding to it, emits on the highlight stream -- which is what runs the
form's own handler, as a
+ // canvas click does -- and the service publishes the selection to
co-editors. The multi-select
+ // flag is taken and ignored, as the one caller never sets it.
+ //
+ // With one exception modelled from the real wrapper (joint-graph-wrapper's
highlightElement): an
+ // id it is ALREADY holding is dropped before it gets as far as clearing the
others, so asking for
+ // a step that is part of a multi-select changes nothing and emits nothing.
+ const serviceHighlightOperators = vi.fn((_multiSelect: boolean, ...ops:
string[]) => {
+ const fresh = ops.filter(op => !highlightedIds.includes(op));
+ if (fresh.length === 0) {
+ return;
+ }
+ highlightedIds.length = 0;
+ highlightedIds.push(...fresh);
+ highlightStream.next([...fresh]);
+ updateSharedModelAwareness("highlighted", [...highlightedIds]);
+ });
// Operators that produced a non-empty result -- drives hasNonEmptyResult in
the result mock.
const anyResultIds = new Set<string>();
// Operators the engine treats as terminal (out-degree 0 on the ENABLED
plan): the engine materializes
@@ -162,6 +181,7 @@ export function setupHarness() {
setWorkflowName: vi.fn(),
setWorkflowMetadata: vi.fn(),
setHighlightingEnabled: vi.fn(),
+ highlightOperators: serviceHighlightOperators,
unhighlightOperators: serviceUnhighlightOperators,
getTexeraGraph: () => ({
triggerCenterEvent,
@@ -417,6 +437,7 @@ export function setupHarness() {
highlightedIds,
unhighlightOperators,
serviceUnhighlightOperators,
+ serviceHighlightOperators,
updateSharedModelAwareness,
};
}