From d429b5180e55dcb03a774b827f8203106cbacd30 Mon Sep 17 00:00:00 2001 From: Koji Wakamiya Date: Wed, 23 Sep 2026 13:58:07 +0900 Subject: [PATCH] test(e2e): read the target errors from the action shots The press shot was taken twice: once in the loop, and again to read the two-buttons error. The tap on text:Cancel took one more shot for the no-match error, which the hover and focus shots already produce: every action finds its target the same way. Each action shot now checks the two-buttons error, and the two extra shots are gone. Co-Authored-By: Claude Opus 5.5 (1M context) --- test/e2e/actions_test.dart | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/test/e2e/actions_test.dart b/test/e2e/actions_test.dart index 84ca97c..71de63f 100644 --- a/test/e2e/actions_test.dart +++ b/test/e2e/actions_test.dart @@ -35,16 +35,25 @@ Widget twoButtons() => Row( }); const buttons = 'lib/preview/button_state_preview.dart'; final (plain, _) = await shoot([buttons]); - for (final action in [ - ['--press', 'text:Save'], - ['--hover', 'type:ElevatedButton'], - ['--focus', 'type:ElevatedButton'], + // The two Save buttons match text:Save twice and type:ElevatedButton + // not at all. + for (final (action, twoError) in [ + (['--press', 'text:Save'], 'press text:Save: 2 widgets match; name one'), + ( + ['--hover', 'type:ElevatedButton'], + 'hover type:ElevatedButton: no widget matches', + ), + ( + ['--focus', 'type:ElevatedButton'], + 'focus type:ElevatedButton: no widget matches', + ), ]) { final (run, shots) = await shoot([buttons, ...action]); final button = shots['State / button']!; expect(button.status, ShotStatus.ok, reason: '$action ${button.error}'); expect(button.size, (200.0, 80.0)); final two = shots['State / two buttons']!; + expect(two.error, twoError); expect(two.png, isNull); expect(two.at, startsWith('lib/preview/button_state_preview.dart:')); final diff = await shutter(root, ['diff', plain, run]); @@ -58,19 +67,5 @@ Widget twoButtons() => Row( ); expect(entry['status'], 'changed', reason: '$action'); } - final (_, missed) = await shoot([buttons, '--tap', 'text:Cancel']); - expect( - missed['State / button']!.error, - 'tap text:Cancel: no widget matches', - ); - expect( - missed['State / two buttons']!.error, - 'tap text:Cancel: no widget matches', - ); - final (_, twice) = await shoot([buttons, '--press', 'text:Save']); - expect( - twice['State / two buttons']!.error, - 'press text:Save: 2 widgets match; name one', - ); }); }