b771f3813a
Keep the assigned runs and pipelines UI Material-only by removing alternate icons, host branches, and Cupertino color usage while preserving compatibility parameters needed by other callers. Update mirrored tests and record focused verification for the cleanup.
136 lines
4.6 KiB
Dart
136 lines
4.6 KiB
Dart
import 'dart:ui' show SemanticsRole;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
/// Every bottom tab bar shows icons only, yet each tab keeps its name for
|
|
/// assistive technology (and a Material tooltip), its selected state and its
|
|
/// test key; the icons within a bar, and against the shell's tabs a detail's
|
|
/// bar floats above, are distinct.
|
|
void main() {
|
|
Widget host(Widget bar) => MaterialApp(
|
|
home: Scaffold(
|
|
body: Align(alignment: Alignment.bottomCenter, child: bar),
|
|
),
|
|
);
|
|
|
|
final bars = <String, (Widget, List<(String, String)>)>{
|
|
'run detail': (
|
|
RunDetailTabStrip(selected: RunDetailTab.summary, onSelected: (_) {}),
|
|
[
|
|
for (final tab in renderedRunDetailTabs)
|
|
('run-detail-tab-${tab.name}', tab.label),
|
|
],
|
|
),
|
|
'stage page': (
|
|
RunVisitSectionStrip(
|
|
selected: RunVisitSection.summary,
|
|
onSelected: (_) {},
|
|
),
|
|
[
|
|
for (final section in shownVisitSections)
|
|
('run-visit-tab-${section.name}', section.label),
|
|
],
|
|
),
|
|
'pipeline detail': (
|
|
PipelineDetailTabs(
|
|
selected: PipelineDetailTab.summary,
|
|
onSelected: (_) {},
|
|
),
|
|
[
|
|
for (final tab in PipelineDetailTab.values)
|
|
('pipeline-detail-tab-${tab.name}', tab.label),
|
|
],
|
|
),
|
|
};
|
|
|
|
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
|
|
testWidgets('$label tabs are icons named for assistive '
|
|
'technology', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(host(bar));
|
|
await tester.pumpAndSettle();
|
|
|
|
final floating = find.byType(FloatingDestinationBar);
|
|
// No label is drawn at all.
|
|
expect(
|
|
find.descendant(of: floating, matching: find.byType(Text)),
|
|
findsNothing,
|
|
);
|
|
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
|
final finder = find.byKey(ValueKey(key));
|
|
final node = tester.getSemantics(finder);
|
|
expect(node.label, startsWith(tabLabel), reason: key);
|
|
expect(
|
|
node,
|
|
isSemantics(
|
|
isSelected: index == 0,
|
|
hasSelectedState: true,
|
|
isButton: true,
|
|
hasTapAction: true,
|
|
),
|
|
reason: key,
|
|
);
|
|
expect(node.role, SemanticsRole.tab, reason: key);
|
|
// "Tab n of m", as the host navigation controls announce it.
|
|
final position = 'Tab ${index + 1} of ${tabs.length}';
|
|
expect(node.label, contains(position), reason: key);
|
|
// Material names the tab in its tooltip too.
|
|
expect(
|
|
find.descendant(
|
|
of: finder,
|
|
matching: find.byWidgetPredicate(
|
|
(widget) => widget is Tooltip && widget.message == tabLabel,
|
|
),
|
|
),
|
|
findsOneWidget,
|
|
reason: key,
|
|
);
|
|
// A hit target at least the platform minimum.
|
|
expect(tester.getSize(finder).shortestSide, greaterThanOrEqualTo(48));
|
|
}
|
|
// The tabs make up one tab bar.
|
|
final tabBar = tester.getSemantics(
|
|
find.byKey(FloatingDestinationBar.rowKey),
|
|
);
|
|
expect(tabBar.role, SemanticsRole.tabBar);
|
|
// Distinct glyphs within the bar.
|
|
final icons = tester
|
|
.widgetList<Icon>(
|
|
find.descendant(of: floating, matching: find.byType(Icon)),
|
|
)
|
|
.map((icon) => icon.icon)
|
|
.toSet();
|
|
expect(icons.length, greaterThanOrEqualTo(tabs.length));
|
|
semantics.dispose();
|
|
});
|
|
}
|
|
|
|
test('detail tab icons differ from the shell tabs they float above', () {
|
|
final shell = {
|
|
for (final destination in shellTabDestinations) ...[
|
|
destinationDetails(destination).icon,
|
|
],
|
|
};
|
|
final details = [
|
|
for (final tab in renderedRunDetailTabs) tab.icon,
|
|
for (final section in shownVisitSections) ...[
|
|
section.icon,
|
|
],
|
|
for (final tab in PipelineDetailTab.values) tab.icon,
|
|
];
|
|
for (final icon in details) {
|
|
expect(shell.contains(icon), isFalse, reason: '$icon');
|
|
}
|
|
});
|
|
}
|