545291e04a
- 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>
174 lines
6.2 KiB
Dart
174 lines
6.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
|
|
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
|
|
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_fullscreen.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
|
|
|
import 'artifact_visit_list_fixture.dart';
|
|
|
|
const _endpoint = 'ws://127.0.0.1:8081/connect';
|
|
const _shellBar = Key('shell-tab-bar');
|
|
|
|
final ArtifactRecord _report = recordedArtifact(
|
|
'report.html',
|
|
url: '/artifacts/1/1/report.html',
|
|
contentType: 'text/html',
|
|
);
|
|
final ArtifactRecord _log = recordedArtifact(
|
|
'build.log',
|
|
url: '/artifacts/1/1/build.log',
|
|
contentType: 'text/plain',
|
|
);
|
|
final ArtifactGroup _group = visitGroup(artifacts: [_report, _log]);
|
|
|
|
/// Each rendered HTML document, with whether it rendered in full screen.
|
|
typedef _Rendered = List<(String, bool)>;
|
|
|
|
Future<({_Rendered rendered, List<Uri> opened})> _pump(
|
|
WidgetTester tester,
|
|
) async {
|
|
final rendered = <(String, bool)>[];
|
|
final opened = <Uri>[];
|
|
final page = ArtifactViewerPage(
|
|
groups: [_group],
|
|
selectedIdentity: artifactVisitIdentity(_group, _report),
|
|
configuredEndpoint: _endpoint,
|
|
fetch: (uri) async => ArtifactFetchResult(
|
|
status: 200,
|
|
bytes: utf8.encode(uri.path.endsWith('.html') ? '<h1>Hi</h1>' : 'ok'),
|
|
),
|
|
openExternal: (uri) async {
|
|
opened.add(uri);
|
|
return true;
|
|
},
|
|
htmlBuilder: (context, html) {
|
|
rendered.add((html, ArtifactFullscreenScope.maybeOf(context) != null));
|
|
return Text('html:$html');
|
|
},
|
|
);
|
|
// A stand-in for the shell: a nested navigator holding the viewer above a
|
|
// tab bar the full-screen view must cover.
|
|
final shell = Column(
|
|
children: [
|
|
Expanded(
|
|
child: Navigator(
|
|
onGenerateRoute: (_) => MaterialPageRoute<void>(builder: (_) => page),
|
|
),
|
|
),
|
|
const SizedBox(key: _shellBar, height: 56, child: Text('Tabs')),
|
|
],
|
|
);
|
|
await tester.pumpWidget(MaterialApp(home: shell));
|
|
await tester.pumpAndSettle();
|
|
return (rendered: rendered, opened: opened);
|
|
}
|
|
|
|
Future<void> _enter(WidgetTester tester) async {
|
|
await tester.tap(find.byKey(artifactFullscreenKey));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
/// A bar control by its Material tooltip.
|
|
/// A control named [name]: by its tooltip on desktop, or by its accessible
|
|
/// name where touch shows the name as a caption instead.
|
|
Finder _named(String name) => find.byWidgetPredicate(
|
|
(widget) =>
|
|
(widget is Tooltip && widget.message == name) ||
|
|
(widget is LabelledIconButton && widget.label == name),
|
|
);
|
|
|
|
void main() {
|
|
testWidgets('the bottom actions offer Full screen', (tester) async {
|
|
final result = await _pump(tester);
|
|
final bar = find.byKey(const Key('artifact-viewer-actions'));
|
|
expect(
|
|
find.descendant(of: bar, matching: find.byKey(artifactFullscreenKey)),
|
|
findsOneWidget,
|
|
);
|
|
expect(_named('Full screen'), findsOneWidget);
|
|
expect(result.rendered.single, ('<h1>Hi</h1>', false));
|
|
});
|
|
|
|
testWidgets('full screen covers the shell, keeps the actions and '
|
|
'renders the fetched document in the app', (tester) async {
|
|
final result = await _pump(tester);
|
|
await _enter(tester);
|
|
|
|
expect(find.byKey(_shellBar), findsNothing);
|
|
// The same document, fetched once with the app's session, now in the
|
|
// full-screen scope; nothing was handed to the system browser.
|
|
expect(result.rendered.last, ('<h1>Hi</h1>', true));
|
|
expect(result.opened, isEmpty);
|
|
final bar = find.byKey(const Key('artifact-viewer-actions'));
|
|
expect(bar, findsOneWidget);
|
|
for (final key in const [
|
|
Key('artifact-open'),
|
|
Key('artifact-copy-link'),
|
|
artifactPreviousKey,
|
|
artifactNextKey,
|
|
]) {
|
|
expect(find.descendant(of: bar, matching: find.byKey(key)), findsOne);
|
|
}
|
|
expect(_named('Exit full screen'), findsOneWidget);
|
|
expect(_named('Open in browser'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Exit full screen returns to the viewer', (tester) async {
|
|
await _pump(tester);
|
|
await _enter(tester);
|
|
await tester.tap(find.byKey(artifactFullscreenKey));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(_shellBar), findsOneWidget);
|
|
expect(_named('Full screen'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Escape and the system back leave full screen', (tester) async {
|
|
await _pump(tester);
|
|
await _enter(tester);
|
|
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(_shellBar), findsOneWidget);
|
|
expect(find.text('html:<h1>Hi</h1>'), findsOneWidget);
|
|
|
|
await _enter(tester);
|
|
await tester.binding.handlePopRoute();
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(_shellBar), findsOneWidget);
|
|
// Back left full screen only, not the viewer as well.
|
|
expect(find.text('html:<h1>Hi</h1>'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('paging in full screen follows the viewer, any kind', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester);
|
|
await _enter(tester);
|
|
await tester.tap(find.byKey(artifactNextKey));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('build.log'), findsOneWidget);
|
|
expect(find.byKey(const Key('artifact-text-preview')), findsOneWidget);
|
|
expect(find.byKey(_shellBar), findsNothing);
|
|
|
|
await tester.tap(find.byKey(artifactFullscreenKey));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('build.log'), findsOneWidget);
|
|
expect(find.byKey(_shellBar), findsOneWidget);
|
|
});
|
|
|
|
test('zoom steps walk the list and hold at both ends', () {
|
|
expect(artifactHtmlZoomStep(1, 1), 1.1);
|
|
expect(artifactHtmlZoomStep(1, -1), 0.9);
|
|
expect(artifactHtmlZoomStep(4, 1), 4);
|
|
expect(artifactHtmlZoomStep(0.5, -1), 0.5);
|
|
expect(artifactHtmlZoomStep(1.3, -1), 1.25);
|
|
});
|
|
}
|