From 811d39d9011f5861719741706ff3c27d57982409 Mon Sep 17 00:00:00 2001 From: ashuntu Date: Fri, 13 Dec 2024 13:03:59 -0600 Subject: [PATCH] Add URL launch tests --- .../subcribe_now/subscribe_now_page_test.dart | 1 - .../subcribe_now/subscribe_now_widgets_test.dart | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 f2b7a34d2..18594371d 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 @@ -31,7 +31,6 @@ void main() { UrlLauncherPlatform.instance = launcher; testWidgets('launch web page', (tester) async { - // final model = MockSubscribeNowModel(); final model = SubscribeNowModel( MockAgentApiClient(), isPurchaseAllowed: true, 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 b616abc4d..89dfa3ab5 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 @@ -7,12 +7,28 @@ import 'package:ubuntupro/core/agent_api_client.dart'; import 'package:ubuntupro/core/pro_token.dart'; import 'package:ubuntupro/pages/subscribe_now/subscribe_now_model.dart'; import 'package:ubuntupro/pages/subscribe_now/subscribe_now_widgets.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; import '../../utils/build_multiprovider_app.dart'; import '../../utils/token_samples.dart' as tks; +import '../../utils/url_launcher_mock.dart'; import 'subscribe_now_widgets_test.mocks.dart'; @GenerateMocks([AgentApiClient]) void main() { + final launcher = FakeUrlLauncher(); + UrlLauncherPlatform.instance = launcher; + + testWidgets('launch web page', (tester) async { + final theApp = buildApp(onApply: () {}, isExpanded: true); + await tester.pumpWidget(theApp); + + expect(launcher.launched, isFalse); + await tester + .tapOnText(find.textRange.ofSubstring('ubuntu.com/pro/dashboard')); + await tester.pump(); + expect(launcher.launched, isTrue); + }); + group('pro token value', () { test('errors', () async { final value = ProTokenValue();