Files
pipelines/app/test/ui/status/error_notice_test.dart
T
alan 545291e04a App: run failure reasons, Run again, labelled tabs, actionable errors, nav fixes
- Run rows show a failed run's reason (else its diagnostic's first line,
  full text in a tooltip) or a short result preview; the Summary leads
  with "Why it failed".
- Run again for succeeded/canceled/interrupted runs opens the New run form
  pre-filled (prompt, workspace, report format) at the latest version with
  the original offered.
- Run detail and stage tabs show their names; touch shows captions on the
  Runs header and artifact viewer actions (desktop keeps tooltips).
- ErrorNotice maps not connected / server too old / permission / timeout
  to what to do, raw detail behind Details (Schedules, create chat, Runs,
  Pipelines banners).
- Settings has no Back arrow; Schedules keeps the rail on wide windows;
  phone Settings leads with Connection and Notifications and has a
  Jump to topic menu.
- Walkthrough: Open Connection (skipped when connected), labelled Copy.
- Pluralised counts; no duplicate status/rail names for screen readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 20:16:22 +00:00

81 lines
2.6 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/error_advice.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/ui/status/error_notice.dart';
import 'package:pipelines_app/ui/text/plural.dart';
/// Common failures read as what to do, with the raw detail kept behind
/// Details; any other failure reads exactly as reported.
void main() {
test('common failures map to their kind', () {
expect(
errorAdviceKind(const NotConnectedError()),
ErrorAdviceKind.notConnected,
);
expect(
errorAdviceKind(StateError('Connection closed')),
ErrorAdviceKind.notConnected,
);
expect(
errorAdviceKind(const ProtocolError('unknown command: list_schedules')),
ErrorAdviceKind.serverTooOld,
);
expect(
errorAdviceKind(const ProtocolError('x', code: 'elevation_required')),
ErrorAdviceKind.permission,
);
expect(
errorAdviceKind('permission denied: /srv'),
ErrorAdviceKind.permission,
);
expect(
errorAdviceKind(TimeoutException('request timed out after 30000ms')),
ErrorAdviceKind.timeout,
);
expect(errorAdviceKind('pipeline 4 has no stage review'), isNull);
final advice = errorAdvice(StateError('Connection closed'));
expect(advice?.detail, 'Connection closed');
expect(advice?.sentence, contains('Settings'));
});
testWidgets('a common failure says what to do and keeps its detail', (
tester,
) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ErrorNotice(error: 'unknown command: list_schedules'),
),
),
);
expect(
find.text(errorAdviceSentence(ErrorAdviceKind.serverTooOld)),
findsOneWidget,
);
expect(find.text('unknown command: list_schedules'), findsNothing);
await tester.tap(find.byKey(errorNoticeDetailsKey));
await tester.pump();
expect(find.text('unknown command: list_schedules'), findsOneWidget);
expect(find.byKey(errorNoticeCopyKey), findsOneWidget);
});
testWidgets('any other failure reads as reported', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: ErrorNotice(error: 'Bad state: pipeline gone')),
),
);
expect(find.text('Bad state: pipeline gone'), findsOneWidget);
expect(find.byKey(errorNoticeDetailsKey), findsNothing);
});
test('counts are pluralised', () {
expect(countLabel(1, 'stage'), '1 stage');
expect(countLabel(3, 'stage'), '3 stages');
expect(countLabel(0, 'file'), '0 files');
});
}