diff --git a/gui/packages/ubuntupro/lib/pages/subscribe_now/subscribe_now_widgets.dart b/gui/packages/ubuntupro/lib/pages/subscribe_now/subscribe_now_widgets.dart index e33d6b237..67f012c1e 100644 --- a/gui/packages/ubuntupro/lib/pages/subscribe_now/subscribe_now_widgets.dart +++ b/gui/packages/ubuntupro/lib/pages/subscribe_now/subscribe_now_widgets.dart @@ -70,24 +70,30 @@ class _ProTokenInputFieldState extends State { isExpanded: widget.isExpanded, child: ValueListenableBuilder( valueListenable: _token, - builder: (context, _, __) => TextField( - autofocus: false, - controller: _controller, - decoration: InputDecoration( - hintText: lang.tokenInputHint, - errorText: _token.errorOrNull?.localize(lang), - counterText: '', - suffixIcon: TextButton( - onPressed: canSubmit ? _handleApplyButton : null, - style: TextButton.styleFrom( - // allows the suffix button to stand out when enabled while keeping its custom look. - foregroundColor: Theme.of(context).colorScheme.onSurface, + builder: (context, _, __) => Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: TextField( + autofocus: false, + controller: _controller, + decoration: InputDecoration( + hintText: lang.tokenInputHint, + errorText: _token.errorOrNull?.localize(lang), + counterText: '', + ), + onChanged: _token.update, + onSubmitted: _onSubmitted, ), + ), + const SizedBox( + width: 8.0, + ), + ElevatedButton( + onPressed: canSubmit ? _handleApplyButton : null, child: Text(lang.confirm), ), - ), - onChanged: _token.update, - onSubmitted: _onSubmitted, + ], ), ), ); diff --git a/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_page_test.dart b/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_page_test.dart index 9bb34f6a0..8e83910ec 100644 --- a/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_page_test.dart +++ b/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_page_test.dart @@ -42,12 +42,12 @@ void main() { final context = tester.element(find.byType(SubscribeNowPage)); final lang = AppLocalizations.of(context); - final button = find.byType(ElevatedButton); // check that's the right button - expect( - find.descendant(of: button, matching: find.text(lang.subscribeNow)), - findsOneWidget, + final button = find.ancestor( + of: find.text(lang.subscribeNow), + matching: find.byType(ElevatedButton), ); + expect(button, findsOneWidget); expect(tester.widget(button).enabled, isFalse); }); testWidgets('enabled', (tester) async { @@ -58,12 +58,12 @@ void main() { final context = tester.element(find.byType(SubscribeNowPage)); final lang = AppLocalizations.of(context); - final button = find.byType(ElevatedButton); // check that's the right button - expect( - find.descendant(of: button, matching: find.text(lang.subscribeNow)), - findsOneWidget, + final button = find.ancestor( + of: find.text(lang.subscribeNow), + matching: find.byType(ElevatedButton), ); + expect(button, findsOneWidget); expect(tester.widget(button).enabled, isTrue); }); }); diff --git a/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_widgets_test.dart b/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_widgets_test.dart index 18ff9daf9..355c258ea 100644 --- a/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_widgets_test.dart +++ b/gui/packages/ubuntupro/test/pages/subcribe_now/subscribe_now_widgets_test.dart @@ -89,7 +89,8 @@ void main() { testWidgets('starts with button disabled', (tester) async { await tester.pumpWidget(theApp); - final button = tester.firstWidget(find.byType(TextButton)); + final button = + tester.firstWidget(find.byType(ElevatedButton)); expect(button.enabled, isFalse); }); @@ -105,7 +106,8 @@ void main() { expect(input.decoration!.errorText, isNotNull); expect(input.decoration!.errorText, contains('too short')); - final button = tester.firstWidget(find.byType(TextButton)); + final button = + tester.firstWidget(find.byType(ElevatedButton)); expect(button.enabled, isFalse); }); @@ -120,7 +122,8 @@ void main() { expect(input.decoration!.errorText, isNotNull); expect(input.decoration!.errorText, contains('too long')); - final button = tester.firstWidget(find.byType(TextButton)); + final button = + tester.firstWidget(find.byType(ElevatedButton)); expect(button.enabled, isFalse); }); @@ -134,7 +137,8 @@ void main() { final input = tester.firstWidget(inputField); expect(input.decoration!.errorText, isNull); - final button = tester.firstWidget(find.byType(TextButton)); + final button = + tester.firstWidget(find.byType(ElevatedButton)); expect(button.enabled, isTrue); }); }); @@ -149,7 +153,7 @@ void main() { await tester.pump(); expect(called, isFalse); - final button = find.byType(TextButton); + final button = find.byType(ElevatedButton); await tester.tap(button); await tester.pumpAndSettle(); expect(called, isTrue);