feat(app): add native content-sized graph stage node
One content-sized stage node as an ordinary native control. Material uses stock Card.outlined/Card.filled inside an InkWell; Cupertino uses CupertinoButton.tinted/filled. onSelected reports the definition key verbatim, one merged button semantics node carries the exact label and selected state, recorded status is shown only when the caller supplies it, and invisible U+200B break opportunities reproduce the web's anywhere wrapping. Painted-boundary and painted-surface tests cover the UI-review 2x outline and Cupertino container defects.
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/graph_definition.dart';
|
||||
|
||||
/// One content-sized stage node as an ordinary native control.
|
||||
///
|
||||
/// [node] is the definition identity. [recordedStatus] is executed evidence the
|
||||
/// caller read from the run; it is shown verbatim and never derived here, so an
|
||||
/// unvisited or terminal definition node cannot be presented as executed.
|
||||
class GraphStageNode extends StatelessWidget {
|
||||
const GraphStageNode({
|
||||
super.key,
|
||||
required this.node,
|
||||
this.recordedStatus,
|
||||
this.selected = false,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
final GraphNode node;
|
||||
|
||||
/// The run's recorded status word for this node, or null when none exists.
|
||||
final String? recordedStatus;
|
||||
|
||||
/// Whether this definition node is the current graph selection.
|
||||
final bool selected;
|
||||
|
||||
/// Reports [node.key] exactly as the definition recorded it.
|
||||
final ValueChanged<String> onSelected;
|
||||
|
||||
/// Content inset shared by both hosts. It is spacing, not a size: the control
|
||||
/// still takes its size from its label, and the inset keeps wrapped glyphs
|
||||
/// clear of a rounded surface's corners.
|
||||
static const EdgeInsets _contentPadding = EdgeInsets.all(16);
|
||||
|
||||
String? get _status {
|
||||
final status = recordedStatus;
|
||||
return status != null && status.trim().isNotEmpty ? status : null;
|
||||
}
|
||||
|
||||
String get _label {
|
||||
final status = _status;
|
||||
return status == null ? node.label : '${node.label}\n$status';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final content = ExcludeSemantics(child: _content());
|
||||
void onPressed() => onSelected(node.key);
|
||||
return MergeSemantics(
|
||||
child: Semantics(
|
||||
button: true,
|
||||
selected: selected,
|
||||
label: _label,
|
||||
child: usesCupertinoHost(context)
|
||||
? _cupertinoButton(onPressed, content)
|
||||
: _materialCard(onPressed, content),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// A stock card, not a stock button: Material's button shape is a stadium,
|
||||
/// which assumes one line and cuts into a wrapped label's first and last
|
||||
/// line. A card keeps the rounded-rectangle surface the web node uses, and
|
||||
/// [selected] only chooses between two stock emphasis levels.
|
||||
Widget _materialCard(VoidCallback onPressed, Widget content) {
|
||||
final body = InkWell(
|
||||
onTap: onPressed,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: kMinInteractiveDimension),
|
||||
child: Padding(
|
||||
padding: _contentPadding,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return selected
|
||||
? Card.filled(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: body,
|
||||
)
|
||||
: Card.outlined(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
|
||||
/// Tinted is Cupertino's stock low-emphasis surface, so an unselected node is
|
||||
/// still a visible node body; filled raises the selected one.
|
||||
Widget _cupertinoButton(VoidCallback onPressed, Widget content) => selected
|
||||
? CupertinoButton.filled(onPressed: onPressed, child: content)
|
||||
: CupertinoButton.tinted(onPressed: onPressed, child: content);
|
||||
|
||||
Widget _content() {
|
||||
final status = _status;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(_breakable(node.label), softWrap: true),
|
||||
if (status != null) Text(_breakable(status), softWrap: true),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The web node uses `overflow-wrap: anywhere`; Flutter text does not break a
|
||||
/// long unbroken key, so the same invisible break opportunities are added.
|
||||
/// The visible text and the semantics label stay unchanged.
|
||||
String _breakable(String value) {
|
||||
final buffer = StringBuffer();
|
||||
for (final rune in value.runes) {
|
||||
buffer
|
||||
..writeCharCode(rune)
|
||||
..write('\u200B');
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
# P2-node — native content-sized stage-node control
|
||||
|
||||
## This visit: both UI-review must-fixes
|
||||
|
||||
| Finding | Change |
|
||||
| --- | --- |
|
||||
| Material stadium outline cut into a wrapped 2x label | Material no longer uses a stock **button**. It is a stock **card** body: `Card.outlined` when unselected, `Card.filled` when selected, wrapped in an `InkWell` with a 16 px content inset and the framework's `kMinInteractiveDimension` tap target. A card's painted shape is a rounded rectangle, so a long wrapped label stays inside the visible boundary at 1x and 2x. |
|
||||
| Cupertino unselected stages and terminals were bare tinted text | Unselected Cupertino nodes are `CupertinoButton.tinted`, so every node has a visible native surface; selected stays `CupertinoButton.filled`. |
|
||||
|
||||
Both fixes use stock widgets and stock variants only: no shape override, no
|
||||
font, size, padding on a button, palette value or CSS token was added.
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | ---: | --- |
|
||||
| `lib/features/graph/widgets/graph_stage_node.dart` | 126 | one content-sized node as a native Material card or Cupertino button |
|
||||
| `test/features/graph/widgets/graph_stage_node_test.dart` | 235 | key identity, semantics, keyboard, focus retention, wrap and terminal honesty |
|
||||
| `test/features/graph/widgets/graph_stage_node_render_test.dart` | 210 | painted-boundary and painted-surface checks on real render objects/pixels |
|
||||
| `tool/graph_node_probe.dart` | 83 | isolated browser fixture, 1x and 2x narrow cases |
|
||||
| `tool/graph_node_probe.mjs` | 151 | headless-Chrome runner: labels, click identity, `aria-current`, captures |
|
||||
| `notes/P2-node.md` | this page | facts for review/landing |
|
||||
|
||||
No existing app source, domain, layout, routing, shell, `main.dart`, pubspec,
|
||||
server, web client or platform file was modified.
|
||||
|
||||
## Public API
|
||||
|
||||
```dart
|
||||
GraphStageNode({
|
||||
required GraphNode node,
|
||||
String? recordedStatus,
|
||||
bool selected = false,
|
||||
required ValueChanged<String> onSelected,
|
||||
})
|
||||
```
|
||||
|
||||
Unchanged from the reviewed candidate. `onSelected` reports `node.key` verbatim,
|
||||
including `#success` / `#failure`; the display label is never used as identity.
|
||||
|
||||
## Native mapping
|
||||
|
||||
| State | Material | Cupertino |
|
||||
| --- | --- | --- |
|
||||
| unselected | `Card.outlined` + `InkWell` | `CupertinoButton.tinted` |
|
||||
| selected | `Card.filled` + `InkWell` | `CupertinoButton.filled` |
|
||||
|
||||
- The host is chosen with the existing `usesCupertinoHost` helper.
|
||||
- Material content sits in a `Padding` of 16 logical px inside the card, so
|
||||
wrapped glyphs stay clear of the rounded corners; the control is still
|
||||
content-sized (no fixed width or height) and grows with its label.
|
||||
- `MergeSemantics` + `Semantics(button: true, selected: …, label: …)` keep one
|
||||
accessibility node per stage: button role, tap action, exact label/status and
|
||||
selected state. The painted content stays `ExcludeSemantics`.
|
||||
- Selection keeps the same widget type on both hosts (`Card` / `CupertinoButton`),
|
||||
so keyboard focus survives activation; the previous Material
|
||||
`OutlinedButton` → `FilledButton` swap replaced the focus node (review note 1).
|
||||
- **Break-anywhere parity.** The web node uses `overflow-wrap: anywhere`; the
|
||||
painted lines get invisible U+200B break opportunities. The accessible label
|
||||
stays exact, with no invisible characters.
|
||||
- **Recorded status only.** `recordedStatus` is shown verbatim on a second line
|
||||
when non-blank; blank or whitespace-only status adds no line. Nothing is
|
||||
derived from `terminal`, `stageIndex` or the label, so a terminal reads only
|
||||
`Success` / `Failure` unless the caller supplies real run evidence.
|
||||
|
||||
## Rendered checks (new)
|
||||
|
||||
`graph_stage_node_render_test.dart` closes the gap the previous 2x test had
|
||||
(line metrics versus paragraph width, not glyphs versus the painted boundary):
|
||||
|
||||
- **Painted-boundary containment.** Reads the actual `Material.shape` and render
|
||||
rect of the Material control, builds its outer `Path`, converts every laid-out
|
||||
line box of the label to card-local coordinates with
|
||||
`RenderParagraph.localToGlobal`, and requires all four corners of every line
|
||||
box to be inside the painted path — at 1x and 2x in a 150 logical px box.
|
||||
A rounded rectangle is convex, so corner containment means the whole line box
|
||||
is inside; no padding/shape override can hide a crossing.
|
||||
- **The check has teeth.** Running the same test against the identical widget
|
||||
while a `StadiumBorder` is temporarily set on the card fails with
|
||||
`at 1.0x a glyph box corner at Offset(16.1, 19.0) escapes the painted control
|
||||
boundary`. The shape assertion (`material node paints a rounded surface, not a
|
||||
stadium`) fails too. The override was reverted before this page was written.
|
||||
- **Cupertino container.** Renders the unselected node over an opaque page,
|
||||
reads pixels back from a real `RepaintBoundary.toImage`, and requires the point
|
||||
just inside the control's left edge to differ from the page background by more
|
||||
than 24/255. Reverting to plain `CupertinoButton` fails this test.
|
||||
- **Visible selection.** The same pixel path requires the painted surface to
|
||||
change between unselected and selected in both hosts.
|
||||
- **Focus retention.** Tab + Enter on the Material node, then the primary focus
|
||||
must still be a descendant of the node's `Card`.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
dart format --output=none --set-exit-if-changed lib/features/graph/widgets \
|
||||
test/features/graph/widgets tool/graph_node_probe.dart # 0 changed, exit 0
|
||||
flutter test test/features/graph/widgets # 13 passed
|
||||
flutter test # 460 passed
|
||||
flutter analyze # No issues found!
|
||||
flutter build web -t tool/graph_node_probe.dart --release # ✓ Built build/web
|
||||
PROBE_VARIANT=material PROBE_SCHEME=dark node tool/graph_node_probe.mjs # passed, 6 captures
|
||||
PROBE_VARIANT=material PROBE_SCHEME=light node tool/graph_node_probe.mjs # passed, 6 captures
|
||||
PROBE_VARIANT=cupertino PROBE_SCHEME=dark node tool/graph_node_probe.mjs # passed, 6 captures
|
||||
PROBE_VARIANT=cupertino PROBE_SCHEME=light node tool/graph_node_probe.mjs # passed, 6 captures
|
||||
```
|
||||
|
||||
The runner asserts the initial labels (`Selected: build`, `plan`, `build`,
|
||||
`running`, `Success`, `Failure`), that exactly the `build` node carries
|
||||
`aria-current="true"` (Flutter web maps `Semantics(selected:)` to `aria-current`,
|
||||
not `aria-selected` — review note 5), that clicking `plan` and `Success` yields
|
||||
exactly `Selected: plan` and `Selected: #success`, and that the selected
|
||||
`aria-current` moves to `plan`.
|
||||
|
||||
## Browser evidence (current)
|
||||
|
||||
Real headless Chrome, loopback fixture only, 390×844 phone and 1280×800 desktop;
|
||||
dark is Chrome's default scheme, light uses `prefers-color-scheme: light`.
|
||||
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/64/public/p2-node-fix-material-dark-phone.png`
|
||||
- `.../p2-node-fix-material-light-phone.png`
|
||||
- `.../p2-node-fix-material-dark-desktop.png`
|
||||
- `.../p2-node-fix-material-long-2x-crop.png` (2x enlargement of the wrapped 2x node)
|
||||
- `.../p2-node-fix-material-long-1x-crop.png`
|
||||
- `.../p2-node-fix-material-selected-plan.png`
|
||||
- `.../p2-node-fix-cupertino-dark-phone.png`
|
||||
- `.../p2-node-fix-cupertino-light-phone.png`
|
||||
- `.../p2-node-fix-cupertino-dark-desktop.png`
|
||||
- `.../p2-node-fix-cupertino-long-2x-crop.png`
|
||||
- `.../p2-node-fix-cupertino-selected-terminal.png`
|
||||
- Runner: `.../public/graph_node_probe.mjs` (same file as `tool/graph_node_probe.mjs`)
|
||||
|
||||
The visit-1 captures (`material-nodes-*.png`, `cupertino-nodes-*.png`) and the UI
|
||||
review crops are superseded by this set; they are kept only as history.
|
||||
|
||||
Pixel measurements of the current 2x crops (crops are 2x, 8 logical px margin):
|
||||
|
||||
| Node | Container (px) | Glyph ink (px) | Corner band |
|
||||
| --- | --- | --- | --- |
|
||||
| Material | x 16–316, y 16–560 | x 50–269, y 66–507 | 24 px (radius 12) |
|
||||
| Cupertino | x 16–316, y 16–640 | x 60–268, y 63–590 | 16 px (radius 8) |
|
||||
|
||||
At 1x the same nodes measure Material ink x 50–268, y 61–147 inside a
|
||||
x 16–316, y 16–200 container, and Cupertino ink x 59–264, y 59–164.
|
||||
No glyph ink enters a corner band or crosses the visible boundary in either
|
||||
scaling; the previous outline crossing is gone.
|
||||
|
||||
Inspected captures: Material shows outlined node bodies, a visibly filled
|
||||
selected node, `running` only on `build`, and no status on either terminal;
|
||||
Cupertino shows a tinted body for every unselected node and a filled selected
|
||||
node in both light and dark.
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **Material selection is tonal.** `Card.filled` (surfaceContainerHighest) versus
|
||||
`Card.outlined` (surface + border) is the strongest stock card pairing, but it
|
||||
is lighter than the previous primary-filled button. It is visible in the
|
||||
captures and asserted by pixels; if UI review wants a stronger accent, that
|
||||
needs an explicit theme-colour decision rather than a bespoke palette.
|
||||
- **Stage vs terminal is label-driven.** Both hosts give every node the same
|
||||
stock container; the web's terminal pill and outcome tints are styling the
|
||||
rules exclude. Terminals read `Success` / `Failure` (and no invented status).
|
||||
Composition can add a stock type affordance if it is still wanted.
|
||||
- **Material content inset is a spacing choice.** 16 logical px inside the card
|
||||
keeps wrapped glyphs clear of the 12 px corner radius; the framework's
|
||||
`kMinInteractiveDimension` keeps the tap target at the native minimum.
|
||||
- **No measurement API yet.** The control shrink-wraps; the caller imposes width
|
||||
(the fixture uses 150). The renderer still needs to measure this same control.
|
||||
- **`onSelected` identity and wrapping are unchanged**, but U+200B break
|
||||
opportunities would split exotic grapheme clusters (acceptable for stage keys).
|
||||
- **Space activation** is a framework default and is not exercised; only
|
||||
Tab + Enter is tested.
|
||||
- **No composition.** No canvas, layout invocation, edge painter, visit menu,
|
||||
shell registration or `main.dart` wiring: the widget is still not visible in
|
||||
the app.
|
||||
- **Not committed.** This stage forbids commit/push/deploy; the paths stay
|
||||
untracked on `flutter/p2-node-widget` for Review and Land.
|
||||
- **Fixture-only browser evidence**: no Pipelines server, real run,
|
||||
authentication change, deployment or production data.
|
||||
- **Mobile unverified**: web test/analyze/build only; no Android/iOS build,
|
||||
emulator, ADB or install.
|
||||
@@ -0,0 +1,210 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
|
||||
|
||||
const _stage = GraphNode(key: 'build', terminal: false, stageIndex: 1);
|
||||
const _long = GraphNode(
|
||||
key: 'implementer-with-an-unshortened-stage-label',
|
||||
terminal: false,
|
||||
stageIndex: 2,
|
||||
);
|
||||
const _longLabel = 'implementer-with-an-unshortened-stage-label';
|
||||
|
||||
Widget _material(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
|
||||
Widget _cupertino(Widget child) => CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
||||
);
|
||||
|
||||
/// The node centred on an opaque page, inside its own repaint boundary so the
|
||||
/// painted result can be read back as pixels.
|
||||
Widget _framed(Key key, Widget Function(Widget) wrap, Widget child) => wrap(
|
||||
RepaintBoundary(
|
||||
key: key,
|
||||
child: ColoredBox(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
child: Center(child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Finder get _materialSurface =>
|
||||
find.descendant(of: find.byType(Card), matching: find.byType(Material));
|
||||
|
||||
Finder _visual(String label) => find.byWidgetPredicate(
|
||||
(widget) => widget is Text && widget.data?.replaceAll('\u200B', '') == label,
|
||||
);
|
||||
|
||||
final class _Shot {
|
||||
_Shot(this.bytes, this.size, this.origin);
|
||||
|
||||
final Uint8List bytes;
|
||||
final Size size;
|
||||
final Offset origin;
|
||||
|
||||
Color at(Offset global) {
|
||||
final x = (global.dx - origin.dx).round();
|
||||
final y = (global.dy - origin.dy).round();
|
||||
expect(x, inInclusiveRange(0, size.width.round() - 1));
|
||||
expect(y, inInclusiveRange(0, size.height.round() - 1));
|
||||
final i = (y * size.width.round() + x) * 4;
|
||||
return Color.fromARGB(bytes[i + 3], bytes[i], bytes[i + 1], bytes[i + 2]);
|
||||
}
|
||||
}
|
||||
|
||||
Future<_Shot> _shot(WidgetTester tester, Key key) async {
|
||||
final boundary = tester.renderObject<RenderRepaintBoundary>(find.byKey(key));
|
||||
final image = (await tester.runAsync(() => boundary.toImage()))!;
|
||||
final data = (await tester.runAsync(
|
||||
() => image.toByteData(format: ui.ImageByteFormat.rawRgba),
|
||||
))!;
|
||||
image.dispose();
|
||||
return _Shot(
|
||||
data.buffer.asUint8List(),
|
||||
tester.getSize(find.byKey(key)),
|
||||
tester.getTopLeft(find.byKey(key)),
|
||||
);
|
||||
}
|
||||
|
||||
double _distance(Color a, Color b) => <double>[
|
||||
(a.r - b.r).abs() * 255,
|
||||
(a.g - b.g).abs() * 255,
|
||||
(a.b - b.b).abs() * 255,
|
||||
].reduce((value, next) => value > next ? value : next);
|
||||
|
||||
void main() {
|
||||
testWidgets('material node paints a rounded surface, not a stadium', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
_material(GraphStageNode(node: _stage, onSelected: (_) {})),
|
||||
);
|
||||
final material = tester.widget<Material>(_materialSurface);
|
||||
expect(
|
||||
material.shape,
|
||||
isA<RoundedRectangleBorder>(),
|
||||
reason:
|
||||
'Material button shapes are stadiums; a stadium border cuts into a '
|
||||
'wrapped label the way the reviewed 2x control did',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('wrapped glyph boxes stay inside the painted material surface', (
|
||||
tester,
|
||||
) async {
|
||||
for (final scale in [1.0, 2.0]) {
|
||||
await tester.pumpWidget(
|
||||
_material(
|
||||
Builder(
|
||||
builder: (context) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(scale)),
|
||||
child: SizedBox(
|
||||
width: 150,
|
||||
child: GraphStageNode(node: _long, onSelected: (_) {}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
final rect = tester.getRect(_materialSurface);
|
||||
final shape = tester.widget<Material>(_materialSurface).shape!;
|
||||
final path = shape.getOuterPath(Offset.zero & rect.size);
|
||||
final paragraph = tester.renderObject<RenderParagraph>(
|
||||
_visual(_longLabel),
|
||||
);
|
||||
final boxes = paragraph.getBoxesForSelection(
|
||||
TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: paragraph.text.toPlainText().length,
|
||||
),
|
||||
);
|
||||
expect(boxes, isNotEmpty);
|
||||
for (final box in boxes) {
|
||||
final corners = <Offset>[
|
||||
Offset(box.left, box.top),
|
||||
Offset(box.right, box.top),
|
||||
Offset(box.left, box.bottom),
|
||||
Offset(box.right, box.bottom),
|
||||
];
|
||||
for (final corner in corners) {
|
||||
final local = paragraph.localToGlobal(corner) - rect.topLeft;
|
||||
expect(
|
||||
path.contains(local),
|
||||
isTrue,
|
||||
reason:
|
||||
'at ${scale}x a glyph box corner at $local escapes the '
|
||||
'painted control boundary $rect',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('unselected cupertino node paints a visible container', (
|
||||
tester,
|
||||
) async {
|
||||
final key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
_framed(
|
||||
key,
|
||||
_cupertino,
|
||||
GraphStageNode(node: _stage, onSelected: (_) {}),
|
||||
),
|
||||
);
|
||||
final shot = await _shot(tester, key);
|
||||
final rect = tester.getRect(find.byType(CupertinoButton));
|
||||
// Just inside the left edge of the control, clear of the label's inset.
|
||||
final body = shot.at(rect.centerLeft + const Offset(4, 0));
|
||||
final page = shot.at(const Offset(4, 4));
|
||||
expect(
|
||||
_distance(body, page),
|
||||
greaterThan(24),
|
||||
reason: 'an unselected cupertino node needs its own visible surface',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('selected state changes the painted surface in both hosts', (
|
||||
tester,
|
||||
) async {
|
||||
for (final wrap in [_material, _cupertino]) {
|
||||
final colors = <bool, Color>{};
|
||||
for (final selected in [false, true]) {
|
||||
final key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
_framed(
|
||||
key,
|
||||
wrap,
|
||||
GraphStageNode(
|
||||
node: _stage,
|
||||
selected: selected,
|
||||
onSelected: (_) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
final shot = await _shot(tester, key);
|
||||
final rect = tester.getRect(find.byType(GraphStageNode));
|
||||
colors[selected] = shot.at(rect.centerLeft + const Offset(4, 0));
|
||||
}
|
||||
expect(
|
||||
_distance(colors[false]!, colors[true]!),
|
||||
greaterThan(16),
|
||||
reason:
|
||||
'selection must be visible, not only announced: the surface fill '
|
||||
'and the outlined border change together',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
import 'dart:ui' show Tristate;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
|
||||
|
||||
const _stage = GraphNode(key: 'build', terminal: false, stageIndex: 1);
|
||||
const _success = GraphNode(key: '#success', terminal: true);
|
||||
const _failure = GraphNode(key: '#failure', terminal: true);
|
||||
|
||||
Widget _material(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
|
||||
Widget _cupertino(Widget child) => CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: Center(child: child)),
|
||||
);
|
||||
|
||||
/// Applies a 2x text scale below the app so the fixture renders as a real
|
||||
/// scale-2 layout rather than a test-only text property.
|
||||
Widget _scaled(Widget child) => Builder(
|
||||
builder: (context) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
/// The merged accessibility node a screen reader receives for one node.
|
||||
SemanticsData _semantics(WidgetTester tester) =>
|
||||
tester.getSemantics(find.byType(MergeSemantics)).getSemanticsData();
|
||||
|
||||
void _expectSelectable(WidgetTester tester, {required bool selected}) {
|
||||
final data = _semantics(tester);
|
||||
expect(data.flagsCollection.isButton, isTrue);
|
||||
expect(data.flagsCollection.isSelected == Tristate.isTrue, selected);
|
||||
expect(data.actions & SemanticsAction.tap.index, isNot(0));
|
||||
}
|
||||
|
||||
/// Finds the visual line for [label], ignoring its invisible break chars.
|
||||
Finder _visual(String label) => find.byWidgetPredicate(
|
||||
(widget) => widget is Text && widget.data?.replaceAll('\u200B', '') == label,
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('selection callback carries the exact definition key', (
|
||||
tester,
|
||||
) async {
|
||||
final picked = <String>[];
|
||||
await tester.pumpWidget(
|
||||
_material(GraphStageNode(node: _success, onSelected: picked.add)),
|
||||
);
|
||||
|
||||
await tester.tap(find.byType(GraphStageNode));
|
||||
await tester.pump();
|
||||
|
||||
expect(picked, ['#success']);
|
||||
_expectSelectable(tester, selected: false);
|
||||
expect(_semantics(tester).label, 'Success');
|
||||
});
|
||||
|
||||
testWidgets('selected node is announced selected in both native hosts', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
_material(
|
||||
GraphStageNode(node: _stage, selected: true, onSelected: (_) {}),
|
||||
),
|
||||
);
|
||||
expect(find.byType(Card), findsOneWidget);
|
||||
expect(find.byType(InkWell), findsOneWidget);
|
||||
_expectSelectable(tester, selected: true);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_cupertino(
|
||||
GraphStageNode(node: _stage, selected: true, onSelected: (_) {}),
|
||||
),
|
||||
);
|
||||
expect(find.byType(CupertinoButton), findsOneWidget);
|
||||
expect(find.byType(Card), findsNothing);
|
||||
_expectSelectable(tester, selected: true);
|
||||
});
|
||||
|
||||
testWidgets('unselected node is not announced selected', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
_material(GraphStageNode(node: _stage, onSelected: (_) {})),
|
||||
);
|
||||
expect(find.byType(Card), findsOneWidget);
|
||||
_expectSelectable(tester, selected: false);
|
||||
});
|
||||
|
||||
testWidgets('keyboard activation selects the node', (tester) async {
|
||||
for (final wrap in [_material, _cupertino]) {
|
||||
final picked = <String>[];
|
||||
await tester.pumpWidget(
|
||||
wrap(GraphStageNode(node: _stage, onSelected: picked.add)),
|
||||
);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked, ['build']);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('keyboard selection keeps focus inside the material node', (
|
||||
tester,
|
||||
) async {
|
||||
var selected = false;
|
||||
await tester.pumpWidget(
|
||||
_material(
|
||||
StatefulBuilder(
|
||||
builder: (context, setState) => GraphStageNode(
|
||||
node: _stage,
|
||||
selected: selected,
|
||||
onSelected: (_) => setState(() => selected = true),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, isTrue);
|
||||
|
||||
final focused = FocusManager.instance.primaryFocus;
|
||||
expect(focused?.context, isNotNull);
|
||||
expect(
|
||||
focused?.context?.findAncestorWidgetOfExactType<Card>(),
|
||||
isNotNull,
|
||||
reason: 'switching card emphasis must not drop keyboard focus',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('long label wraps unshortened in a narrow 2x layout', (
|
||||
tester,
|
||||
) async {
|
||||
const label = 'implementer-with-an-unshortened-stage-label';
|
||||
const node = GraphNode(key: label, terminal: false, stageIndex: 0);
|
||||
for (final wrap in [_material, _cupertino]) {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
_scaled(
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: GraphStageNode(node: node, onSelected: (_) {}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
final text = tester.widget<Text>(_visual(label));
|
||||
expect(text.data!.replaceAll('\u200B', ''), label);
|
||||
expect(text.maxLines, isNull);
|
||||
expect(text.overflow, isNull);
|
||||
final paragraph = tester.renderObject<RenderParagraph>(_visual(label));
|
||||
expect(paragraph.size.width, lessThanOrEqualTo(150));
|
||||
expect(
|
||||
paragraph.size.height,
|
||||
greaterThan(50),
|
||||
reason: 'the 2x label must occupy more than one 2x text line',
|
||||
);
|
||||
// No glyph may paint outside the paragraph: every laid-out line,
|
||||
// including a hyphen-broken segment, fits the width the control gave it.
|
||||
final painter = TextPainter(
|
||||
text: paragraph.text,
|
||||
textDirection: paragraph.textDirection,
|
||||
textScaler: paragraph.textScaler,
|
||||
textAlign: paragraph.textAlign,
|
||||
)..layout(maxWidth: paragraph.size.width);
|
||||
expect(
|
||||
painter.computeLineMetrics().every(
|
||||
(line) => line.width <= paragraph.size.width + 0.5,
|
||||
),
|
||||
isTrue,
|
||||
reason: 'an unshortened label must wrap, not paint over the control',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('terminal shows its definition label and no invented status', (
|
||||
tester,
|
||||
) async {
|
||||
for (final node in [_success, _failure]) {
|
||||
await tester.pumpWidget(
|
||||
_material(GraphStageNode(node: node, onSelected: (_) {})),
|
||||
);
|
||||
final texts = tester
|
||||
.widgetList<Text>(find.byType(Text))
|
||||
.map((text) => text.data?.replaceAll('\u200B', ''))
|
||||
.toList();
|
||||
expect(texts, [node.label]);
|
||||
expect(texts.join(' ').toLowerCase(), isNot(contains('executed')));
|
||||
expect(texts.join(' ').toLowerCase(), isNot(contains('visited')));
|
||||
expect(_semantics(tester).label, node.label);
|
||||
expect(_semantics(tester).label, isNot(contains('\u200B')));
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('a recorded status is shown verbatim', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
_cupertino(
|
||||
GraphStageNode(
|
||||
node: _stage,
|
||||
recordedStatus: 'failed',
|
||||
onSelected: (_) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(_visual('build'), findsOneWidget);
|
||||
expect(_visual('failed'), findsOneWidget);
|
||||
final label = _semantics(tester).label;
|
||||
expect(label, contains('build'));
|
||||
expect(label, contains('failed'));
|
||||
expect(label, isNot(contains('\u200B')));
|
||||
});
|
||||
|
||||
testWidgets('a blank recorded status adds no line', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
_material(
|
||||
GraphStageNode(node: _stage, recordedStatus: ' ', onSelected: (_) {}),
|
||||
),
|
||||
);
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
expect(_semantics(tester).label, 'build');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
|
||||
|
||||
const _longKey = 'implementer-with-an-unshortened-stage-label';
|
||||
const _oneXKey = 'narrow-one-x-stage-key-that-wraps';
|
||||
|
||||
/// Keys rendered in a 150 logical px box, with the text scale applied to them.
|
||||
const _scaled = {_longKey: 2.0, _oneXKey: 1.0};
|
||||
|
||||
const _nodes = [
|
||||
GraphNode(key: 'plan', terminal: false, stageIndex: 0),
|
||||
GraphNode(key: 'build', terminal: false, stageIndex: 1),
|
||||
GraphNode(key: _longKey, terminal: false, stageIndex: 2),
|
||||
GraphNode(key: _oneXKey, terminal: false, stageIndex: 3),
|
||||
GraphNode(key: '#success', terminal: true),
|
||||
GraphNode(key: '#failure', terminal: true),
|
||||
];
|
||||
|
||||
/// A fixture-only page: one measured node per definition identity, with the
|
||||
/// selected key reported so a browser click can prove the exact callback.
|
||||
class _Probe extends StatefulWidget {
|
||||
const _Probe({required this.cupertino});
|
||||
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_Probe> createState() => _ProbeState();
|
||||
}
|
||||
|
||||
class _ProbeState extends State<_Probe> {
|
||||
String? _selected = 'build';
|
||||
|
||||
Widget _node(GraphNode node) {
|
||||
final child = GraphStageNode(
|
||||
node: node,
|
||||
recordedStatus: node.key == 'build' ? 'running' : null,
|
||||
selected: node.key == _selected,
|
||||
onSelected: (key) => setState(() => _selected = key),
|
||||
);
|
||||
final scale = _scaled[node.key];
|
||||
if (scale == null) return child;
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(scale)),
|
||||
child: SizedBox(width: 150, child: child),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final page = ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text('Selected: ${_selected ?? 'none'}'),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: [for (final node in _nodes) _node(node)],
|
||||
),
|
||||
],
|
||||
);
|
||||
return widget.cupertino
|
||||
? CupertinoPageScaffold(child: SafeArea(child: page))
|
||||
: Scaffold(body: SafeArea(child: page));
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
final cupertino = Uri.base.queryParameters['style'] == 'cupertino';
|
||||
runApp(
|
||||
cupertino
|
||||
? CupertinoApp(home: const _Probe(cupertino: true))
|
||||
: MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: const _Probe(cupertino: false),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
// Browser acceptance for the isolated GraphStageNode fixture.
|
||||
//
|
||||
// Serves the probe build (`flutter build web -t tool/graph_node_probe.dart`) on
|
||||
// an OS-assigned loopback port, drives a real headless Chrome, asserts labels,
|
||||
// selection identity and the selected ARIA state, and writes captures.
|
||||
//
|
||||
// PROBE_VARIANT=material|cupertino PROBE_SCHEME=dark|light \
|
||||
// OPENCODE_ARTIFACT_DIR=<dir> node tool/graph_node_probe.mjs
|
||||
import { createServer } from 'node:http';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
import { join, extname, resolve, sep } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
||||
|
||||
const root = resolve(process.env.PROBE_WEB_ROOT ?? join(process.cwd(), 'build/web'));
|
||||
const variant = process.env.PROBE_VARIANT ?? 'material';
|
||||
const scheme = process.env.PROBE_SCHEME ?? 'dark';
|
||||
const artifactDir = process.env.OPENCODE_ARTIFACT_DIR ?? join(tmpdir(), 'graph-node-capture');
|
||||
const prefix = scheme === 'light' ? 'light-' : '';
|
||||
const longKey = 'implementer-with-an-unshortened-stage-label';
|
||||
const oneXKey = 'narrow-one-x-stage-key-that-wraps';
|
||||
await mkdir(artifactDir, { recursive: true });
|
||||
const mime = { '.html': 'text/html', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm', '.png': 'image/png', '.ico': 'image/x-icon' };
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
const path = resolve(root, '.' + decodeURIComponent(new URL(req.url, 'http://localhost').pathname));
|
||||
if (path !== root && !path.startsWith(root + sep)) return res.writeHead(403).end();
|
||||
const filePath = path === root || path.endsWith('/') ? join(path, 'index.html') : path;
|
||||
const file = await readFile(filePath);
|
||||
res.writeHead(200, { 'content-type': mime[extname(filePath)] ?? 'application/octet-stream' }).end(file);
|
||||
} catch { res.writeHead(404).end('not found'); }
|
||||
});
|
||||
server.listen(0, '127.0.0.1');
|
||||
await once(server, 'listening');
|
||||
const port = server.address().port;
|
||||
const profile = await mkdtemp(join(tmpdir(), 'graph-node-chrome-'));
|
||||
const chrome = spawn('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', [
|
||||
'--headless=new', '--no-first-run', '--no-default-browser-check', '--disable-gpu',
|
||||
'--remote-debugging-port=0', `--user-data-dir=${profile}`, 'about:blank',
|
||||
], { stdio: ['ignore', 'ignore', 'pipe'] });
|
||||
let stderr = '';
|
||||
chrome.stderr.on('data', data => { stderr += data; });
|
||||
const waitFor = async fn => {
|
||||
for (let i = 0; i < 100; i++) { const value = await fn(); if (value) return value; await delay(100); }
|
||||
throw new Error('Timed out waiting for Chrome DevTools');
|
||||
};
|
||||
let ws;
|
||||
try {
|
||||
const endpoint = await waitFor(() => stderr.match(/DevTools listening on (ws:\/\/[^\s]+)/)?.[1]);
|
||||
ws = new WebSocket(endpoint);
|
||||
await once(ws, 'open');
|
||||
let id = 0;
|
||||
const pending = new Map();
|
||||
ws.addEventListener('message', event => {
|
||||
const msg = JSON.parse(event.data);
|
||||
if (msg.id && pending.has(msg.id)) { pending.get(msg.id)(msg); pending.delete(msg.id); }
|
||||
});
|
||||
const send = (method, params = {}, sessionId) => new Promise(resolve => {
|
||||
const callId = ++id; pending.set(callId, resolve);
|
||||
ws.send(JSON.stringify({ id: callId, method, params, ...(sessionId ? { sessionId } : {}) }));
|
||||
});
|
||||
const created = await send('Target.createTarget', { url: 'about:blank' });
|
||||
const target = created.result.targetId;
|
||||
const session = (await send('Target.attachToTarget', { targetId: target, flatten: true })).result.sessionId;
|
||||
await send('Page.enable', {}, session);
|
||||
await send('Runtime.enable', {}, session);
|
||||
await send('Emulation.setEmulatedMedia', {
|
||||
features: [{ name: 'prefers-color-scheme', value: scheme }],
|
||||
}, session);
|
||||
const navigation = await send('Page.navigate', { url: `http://127.0.0.1:${port}/?style=${variant}` }, session);
|
||||
if (navigation.error || navigation.result?.errorText) throw new Error(JSON.stringify(navigation));
|
||||
const evaluate = async expression => {
|
||||
const response = await send('Runtime.evaluate', { expression, returnByValue: true, awaitPromise: true }, session);
|
||||
if (response.error) throw new Error(`Runtime.evaluate failed: ${JSON.stringify(response)}`);
|
||||
return response.result?.result?.value;
|
||||
};
|
||||
await delay(3500);
|
||||
const loaded = await evaluate('({url:location.href, ready:document.readyState})');
|
||||
if (!loaded?.url.includes(`127.0.0.1:${port}/?style=${variant}`)) throw new Error(`Fixture did not load: ${JSON.stringify(loaded)}`);
|
||||
await evaluate("document.querySelector('flt-semantics-placeholder')?.click()");
|
||||
await delay(2500);
|
||||
const semantics = () => evaluate("[...document.querySelectorAll('flt-semantics')].map(x=>({label:(x.getAttribute('aria-label')||x.innerText||'').trim(), selected:x.getAttribute('aria-current'), role:x.getAttribute('role')}))");
|
||||
const nodeAt = label => `[...document.querySelectorAll('flt-semantics')].find(x => (x.getAttribute('aria-label')||x.innerText||'').trim() === ${JSON.stringify(label)})`;
|
||||
const initial = await semantics();
|
||||
const labels = initial.map(x => x.label);
|
||||
for (const needle of ['Selected: build', 'plan', 'build', 'running', 'Success', 'Failure']) {
|
||||
if (!labels.some(x => x.includes(needle))) throw new Error(`Missing semantics ${needle}: ${JSON.stringify(labels)}`);
|
||||
}
|
||||
// Flutter web maps Semantics(selected:) to aria-current, not aria-selected.
|
||||
const current = initial.find(x => x.selected === 'true');
|
||||
// The fixture's selected node carries its recorded status, so its accessible
|
||||
// label is 'build\nrunning'.
|
||||
if (!current?.label.startsWith('build')) throw new Error(`Selected node is not announced: ${JSON.stringify(initial)}`);
|
||||
if (process.env.PROBE_DEBUG) console.log(JSON.stringify(initial, null, 2));
|
||||
const clickLabel = async label => {
|
||||
const point = await evaluate(`(() => { const e=${nodeAt(label)}; if (!e) return null; const r=e.getBoundingClientRect(); return {x:r.x+r.width/2,y:r.y+r.height/2}; })()`);
|
||||
if (!point) return false;
|
||||
await send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
|
||||
await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
|
||||
return true;
|
||||
};
|
||||
const nodeRect = async label => evaluate(`(() => { const e=${nodeAt(label)}; if (!e) return null; const r=e.getBoundingClientRect(); return {x:r.x,y:r.y,width:r.width,height:r.height}; })()`);
|
||||
const capture = async (name, width, height, scale = 1) => {
|
||||
await send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: width < 600 }, session);
|
||||
await delay(2500);
|
||||
const data = (await send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: false }, session)).result.data;
|
||||
await writeFile(`${artifactDir}/${prefix}${variant}-${name}.png`, Buffer.from(data, 'base64'));
|
||||
};
|
||||
await capture('nodes-phone', 390, 844);
|
||||
await capture('nodes-desktop', 1280, 800);
|
||||
// Enlarged crops of the wrapped cases: the reviewed Material defect was
|
||||
// glyph ink crossing the painted boundary at 2x.
|
||||
const crops = {};
|
||||
for (const [name, key] of [['long-2x', longKey], ['long-1x', oneXKey]]) {
|
||||
const rect = await nodeRect(key);
|
||||
if (!rect) throw new Error(`Missing node ${key}`);
|
||||
crops[name] = rect;
|
||||
const data = (await send('Page.captureScreenshot', {
|
||||
format: 'png',
|
||||
clip: { x: rect.x - 8, y: rect.y - 8, width: rect.width + 16, height: rect.height + 16, scale: 2 },
|
||||
captureBeyondViewport: false,
|
||||
}, session)).result.data;
|
||||
await writeFile(`${artifactDir}/${prefix}${variant}-${name}-crop.png`, Buffer.from(data, 'base64'));
|
||||
}
|
||||
if (!await clickLabel('plan')) throw new Error('Could not click plan node');
|
||||
await delay(600);
|
||||
const afterPlan = await evaluate('document.body.innerText');
|
||||
if (!afterPlan.includes('Selected: plan')) throw new Error(`plan callback did not carry its key: ${afterPlan}`);
|
||||
const planCurrent = (await semantics()).find(x => x.selected === 'true');
|
||||
if (planCurrent?.label !== 'plan') throw new Error(`plan is not announced selected: ${JSON.stringify(planCurrent)}`);
|
||||
await capture('nodes-selected-plan', 390, 844);
|
||||
if (!await clickLabel('Success')) throw new Error('Could not click Success terminal');
|
||||
await delay(600);
|
||||
const afterTerminal = await evaluate('document.body.innerText');
|
||||
if (!afterTerminal.includes('Selected: #success')) throw new Error(`terminal callback did not carry its key: ${afterTerminal}`);
|
||||
await capture('nodes-selected-terminal', 390, 844);
|
||||
console.log(JSON.stringify({
|
||||
variant, scheme, labels, crops,
|
||||
captures: [`${prefix}${variant}-nodes-phone.png`, `${prefix}${variant}-nodes-desktop.png`,
|
||||
`${prefix}${variant}-nodes-selected-plan.png`, `${prefix}${variant}-nodes-selected-terminal.png`,
|
||||
`${prefix}${variant}-long-2x-crop.png`, `${prefix}${variant}-long-1x-crop.png`],
|
||||
}, null, 2));
|
||||
} finally {
|
||||
ws?.close();
|
||||
chrome.kill('SIGTERM');
|
||||
await Promise.race([once(chrome, 'exit'), delay(3000)]);
|
||||
server.close();
|
||||
await rm(profile, { recursive: true, force: true });
|
||||
}
|
||||
Reference in New Issue
Block a user