Skip to content

Commit e11dd0c

Browse files
authored
test(cat-voices): Few more Url checking tests (#2092)
1 parent f21f815 commit e11dd0c

File tree

6 files changed

+105
-29
lines changed

6 files changed

+105
-29
lines changed

catalyst_voices/apps/voices/integration_test/pageobject/onboarding/create_flow/step_16_wallet_list.dart

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_test/flutter_test.dart';
44

5+
import '../../../utils/constants.dart';
6+
import '../../../utils/selector_utils.dart';
57
import '../../../utils/translations_utils.dart';
68
import '../onboarding_base_page.dart';
79
import 'step_15_link_wallet_info.dart';
810

911
class WalletListPanel extends OnboardingPageBase {
1012
WalletListPanel(super.$);
1113

14+
static const seeAllSupportedWalletsBtn = Key('SeeAllSupportedWalletsButton');
15+
1216
@override
1317
Future<void> goto() async {
1418
await LinkWalletInfoPanel($).goto();
@@ -32,7 +36,7 @@ class WalletListPanel extends OnboardingPageBase {
3236
(widget) =>
3337
widget is CatalystSvgPicture &&
3438
(widget.bytesLoader as dynamic).assetName ==
35-
'assets/icons/check.svg',
39+
'assets/images/keychain.svg',
3640
),
3741
findsOneWidget,
3842
);
@@ -41,5 +45,24 @@ class WalletListPanel extends OnboardingPageBase {
4145
expect($(learnMoreButton).$(Text).text, (await t()).learnMore);
4246
}
4347

44-
Future<void> verifyDetailsPanel() async {}
48+
Future<void> verifyDetailsPanel() async {
49+
expect(
50+
$(registrationDetailsTitle).$(Text).text,
51+
(await t()).walletLinkSelectWalletTitle,
52+
);
53+
expect(
54+
$(registrationDetailsBody).$(Text).text,
55+
(await t()).walletLinkSelectWalletContent,
56+
);
57+
final seeAllSupportedWalletsCopy = (await t()).seeAllSupportedWallets;
58+
expect(
59+
$(seeAllSupportedWalletsBtn).$(Text).text,
60+
seeAllSupportedWalletsCopy,
61+
);
62+
await SelectorUtils.checkOpeningLinkByMocking(
63+
$,
64+
seeAllSupportedWalletsCopy,
65+
Urls.supportedWallets,
66+
);
67+
}
4568
}

catalyst_voices/apps/voices/integration_test/pageobject/onboarding/create_flow/step_4_acknowledgments.dart

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_test/flutter_test.dart';
3+
4+
import '../../../utils/constants.dart';
5+
import '../../../utils/selector_utils.dart';
36
import '../../../utils/translations_utils.dart';
47
import '../onboarding_base_page.dart';
58
import 'step_3_setup_base_profile.dart';
@@ -46,18 +49,28 @@ class AcknowledgmentsPanel extends OnboardingPageBase {
4649
);
4750
final tosText =
4851
(await t()).createBaseProfileAcknowledgementsToS.split('{tos}')[0];
49-
expect(
50-
find.byWidgetPredicate(
51-
(widget) {
52-
if (widget is Text) {
53-
return widget.data?.contains(tosText) ?? false;
54-
} else if (widget is RichText) {
55-
return widget.text.toPlainText().contains(tosText);
56-
}
57-
return false;
58-
},
59-
),
60-
findsOneWidget,
52+
final tosTextCurrent = $(tosCheckbox).$(Row).$(RichText);
53+
expect(tosTextCurrent.text?.contains(tosText), true);
54+
final policyText = (await t())
55+
.createBaseProfileAcknowledgementsPrivacyPolicy
56+
.split('{privacy_policy}')[0];
57+
final policyTextCurrent = $(privacyPolicyCheckbox).$(Row).$(RichText);
58+
expect(policyTextCurrent.text?.contains(policyText), true);
59+
final dataUsageText =
60+
(await t()).createBaseProfileAcknowledgementsDataUsage;
61+
final dataUsageTextCurrent = $(dataUsageCheckbox).$(Row).$(Text).text;
62+
expect(dataUsageTextCurrent?.contains(dataUsageText), true);
63+
await verifyOpeningLinks();
64+
}
65+
66+
Future<void> verifyOpeningLinks() async {
67+
final tosLinkText = (await t()).catalystTos;
68+
await SelectorUtils.checkOpeningLinkByMocking($, tosLinkText, Urls.tos);
69+
final policyLinkText = (await t()).catalystPrivacyPolicy;
70+
await SelectorUtils.checkOpeningLinkByMocking(
71+
$,
72+
policyLinkText,
73+
Urls.privacyPolicy,
6174
);
6275
}
6376
}

catalyst_voices/apps/voices/integration_test/pageobject/proposals_page.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_test/flutter_test.dart';
44
import 'package:patrol_finders/patrol_finders.dart';
55

6-
import '../utils/mock_url_launcher_platform.dart';
6+
import '../utils/selector_utils.dart';
77
import '../utils/translations_utils.dart';
88
import 'app_bar_page.dart';
99
import 'common_page.dart';
@@ -379,16 +379,13 @@ class ProposalsPage {
379379
.$(itemTitle)
380380
.text;
381381
if (linkTitleText!.contains((await t()).copyLink) == false) {
382-
final mockUrlLauncherPlatform = MockUrlLauncherPlatform();
383382
final linkPartialTextToMatch =
384383
'https://${linkTitleText.split(' ').last.toLowerCase()}.com';
385-
await $(shareProposalDialog).$(shareItem).at(proposalNumber).tap();
386-
expect(
387-
mockUrlLauncherPlatform.capturedUrl.startsWith(linkPartialTextToMatch),
388-
true,
389-
reason: 'Link URL does not match the expected URL',
384+
await SelectorUtils.checkOpeningLinkByMocking(
385+
$,
386+
linkTitleText,
387+
linkPartialTextToMatch,
390388
);
391-
mockUrlLauncherPlatform.tearDownMock();
392389
}
393390
}
394391

catalyst_voices/apps/voices/integration_test/suites/onboarding_test.dart

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,29 @@ void main() async {
5656
await GetStartedPanel($).goto();
5757
await GetStartedPanel($).verifyPageElements();
5858
});
59+
5960
patrolWidgetTest('visitor - create - base profile info screen looks OK',
6061
(PatrolTester $) async {
6162
await $.pumpWidgetAndSettle(App(routerConfig: router));
6263
await BaseProfileInfoPanel($).goto();
6364
await BaseProfileInfoPanel($).verifyPageElements();
6465
});
66+
6567
patrolWidgetTest('visitor - create - base profile setup screen looks OK',
6668
(PatrolTester $) async {
6769
await $.pumpWidgetAndSettle(App(routerConfig: router));
6870
await SetupBaseProfilePanel($).goto();
6971
await SetupBaseProfilePanel($).verifyPageElements();
7072
});
73+
7174
patrolWidgetTest(
7275
'visitor - create - keychain acknowledgement screen looks OK',
7376
(PatrolTester $) async {
7477
await $.pumpWidgetAndSettle(App(routerConfig: router));
7578
await AcknowledgmentsPanel($).goto();
7679
await AcknowledgmentsPanel($).verifyPageElements();
7780
});
81+
7882
patrolWidgetTest('visitor - create - base profile setup screen looks OK',
7983
(PatrolTester $) async {
8084
await $.pumpWidgetAndSettle(App(routerConfig: router));
@@ -137,11 +141,12 @@ void main() async {
137141
await WriteDownSeedphrasePanel($).verifyPageElements();
138142
await WriteDownSeedphrasePanel($).verifyNextButtonIsDisabled();
139143
});
144+
140145
patrolWidgetTest('visitor - create - mnemonic input info screen looks OK',
141146
(PatrolTester $) async {
142147
await $.pumpWidgetAndSettle(App(routerConfig: router));
143148
await WritedownSeedphraseInfoPanel($).goto();
144-
await WritedownSeedphraseInfoPanel($).verifyInfoPanel();
149+
await WritedownSeedphraseInfoPanel($).verifyPageElements();
145150
});
146151

147152
patrolWidgetTest(
@@ -157,7 +162,7 @@ void main() async {
157162
(PatrolTester $) async {
158163
await $.pumpWidgetAndSettle(App(routerConfig: router));
159164
await InputSeedphrasePanel($).goto();
160-
await InputSeedphrasePanel($).verifyInfoPanel();
165+
await InputSeedphrasePanel($).verifyPageElements();
161166
});
162167

163168
patrolWidgetTest(
@@ -177,12 +182,13 @@ void main() async {
177182
await InputSeedphrasePanel($).inputSeedPhraseWords();
178183
await InputSeedphrasePanel($).verifyNextButtonIsEnabled();
179184
});
185+
180186
patrolWidgetTest(
181187
'visitor - create - mnemonic input verified screen looks OK',
182188
(PatrolTester $) async {
183189
await $.pumpWidgetAndSettle(App(routerConfig: router));
184190
await SeedphraseSuccessPanel($).goto();
185-
await SeedphraseSuccessPanel($).verifyInfoPanel();
191+
await SeedphraseSuccessPanel($).verifyPageElements();
186192
});
187193

188194
patrolWidgetTest(
@@ -198,7 +204,7 @@ void main() async {
198204
(PatrolTester $) async {
199205
await $.pumpWidgetAndSettle(App(routerConfig: router));
200206
await PasswordInfoPanel($).goto();
201-
await PasswordInfoPanel($).verifyInfoPanel();
207+
await PasswordInfoPanel($).verifyPageElements();
202208
});
203209

204210
patrolWidgetTest(
@@ -209,11 +215,12 @@ void main() async {
209215
await PasswordInfoPanel($).clickBack();
210216
await PasswordInfoPanel($).verifyInfoPanel();
211217
});
218+
212219
patrolWidgetTest('visitor - create - password input screen looks OK',
213220
(PatrolTester $) async {
214221
await $.pumpWidgetAndSettle(App(routerConfig: router));
215222
await PasswordInputPanel($).goto();
216-
await PasswordInputPanel($).verifyInfoPanel();
223+
await PasswordInputPanel($).verifyPageElements();
217224
});
218225

219226
patrolWidgetTest(
@@ -299,13 +306,21 @@ void main() async {
299306
(PatrolTester $) async {
300307
await $.pumpWidgetAndSettle(App(routerConfig: router));
301308
await KeychainFinalPanel($).goto();
302-
await KeychainFinalPanel($).verifyInfoPanel();
309+
await KeychainFinalPanel($).verifyPageElements();
303310
});
311+
304312
patrolWidgetTest('visitor - create - link wallet info screen looks OK',
305313
(PatrolTester $) async {
306314
await $.pumpWidgetAndSettle(App(routerConfig: router));
307315
await LinkWalletInfoPanel($).goto();
308-
await LinkWalletInfoPanel($).verifyInfoPanel();
316+
await LinkWalletInfoPanel($).verifyPageElements();
317+
});
318+
319+
patrolWidgetTest('visitor - create - link wallet select screen looks OK',
320+
(PatrolTester $) async {
321+
await $.pumpWidgetAndSettle(App(routerConfig: router));
322+
await WalletListPanel($).goto();
323+
await WalletListPanel($).verifyPageElements();
309324
});
310325

311326
patrolWidgetTest(
@@ -553,6 +568,7 @@ void main() async {
553568
await OnboardingPageBase($).incompleteDialogClickClose();
554569
await PasswordInfoPanel($).verifyDetailsPanel();
555570
});
571+
556572
patrolWidgetTest(
557573
tags: 'issues_2004',
558574
skip: true,

catalyst_voices/apps/voices/integration_test/utils/constants.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ enum Time {
77

88
const Time(this.duration);
99
}
10+
11+
class Urls {
12+
static String tos =
13+
'https://docs.projectcatalyst.io/current-fund/fund-basics/project-catalyst-terms-and-conditions';
14+
static String privacyPolicy =
15+
'https://docs.projectcatalyst.io/current-fund/fund-basics/project-catalyst-terms-and-conditions/catalyst-fc-privacy-policy';
16+
static String supportedWallets =
17+
'https://docs.projectcatalyst.io/current-fund/voter-registration/supported-wallets';
18+
}

catalyst_voices/apps/voices/integration_test/utils/selector_utils.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter_test/flutter_test.dart';
22
import 'package:patrol_finders/patrol_finders.dart';
33

4+
import 'mock_url_launcher_platform.dart';
5+
46
class SelectorUtils {
57
static void isDisabled(
68
PatrolTester $,
@@ -19,4 +21,20 @@ class SelectorUtils {
1921
static void isEnabled(PatrolTester $, PatrolFinder widget) {
2022
isDisabled($, widget, reverse: true);
2123
}
24+
25+
static Future<void> checkOpeningLinkByMocking(
26+
PatrolTester $,
27+
String elementText,
28+
String urlPart,
29+
) async {
30+
final mockUrlLauncherPlatform = MockUrlLauncherPlatform();
31+
await $.tester.tapOnText(find.textRange.ofSubstring(elementText));
32+
expect(
33+
mockUrlLauncherPlatform.capturedUrl.contains(urlPart),
34+
true,
35+
reason: 'Link URL does not match: \nexpected $urlPart'
36+
'\ngot ${mockUrlLauncherPlatform.capturedUrl}',
37+
);
38+
mockUrlLauncherPlatform.tearDownMock();
39+
}
2240
}

0 commit comments

Comments
 (0)