From bbeb90339baf38d11428f509e071d37f41f9caea Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 3 Dec 2026 01:07:34 +0000 Subject: [PATCH] Run tab keys test: read the selected tab from the top segments on wide layouts Co-Authored-By: Claude Opus 5.5 --- .../runs/ui/run_detail_tab_keys_test.dart | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/test/features/runs/ui/run_detail_tab_keys_test.dart b/app/test/features/runs/ui/run_detail_tab_keys_test.dart index 9a0da857..825a7f59 100644 --- a/app/test/features/runs/ui/run_detail_tab_keys_test.dart +++ b/app/test/features/runs/ui/run_detail_tab_keys_test.dart @@ -2,17 +2,25 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; +import 'package:pipelines_app/features/runs/ui/run_detail_top_tabs.dart'; import 'run_detail_graph_support.dart'; -int _current(WidgetTester tester) => tester - .widget( - find.descendant( - of: find.byKey(const Key('run-detail-tabs')), - matching: find.byType(FloatingDestinationBar), - ), - ) - .currentIndex; +/// The selected tab's index, from the bottom bar (narrow) or the top +/// segments (wide), whichever the layout shows. +int _current(WidgetTester tester) { + final bar = find.descendant( + of: find.byKey(const Key('run-detail-tabs')), + matching: find.byType(FloatingDestinationBar), + ); + if (bar.evaluate().isNotEmpty) { + return tester.widget(bar).currentIndex; + } + final segments = tester.widget( + find.byType(RunDetailTopTabs), + ); + return segments.tabs.indexOf(segments.selected); +} void main() { testWidgets('bare 1-4 switch the run detail tabs', (tester) async {