Skip to content

Commit 5820011

Browse files
authored
chore(authenticator): added missing widget keys (#4171)
1 parent ddafa9a commit 5820011

File tree

6 files changed

+29
-41
lines changed

6 files changed

+29
-41
lines changed

packages/authenticator/amplify_authenticator/example/integration_test/sign_in_force_new_password_test.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ void main() {
5858
]),
5959
);
6060

61-
// When I select my country code with status "FORCE_CHANGE_PASSWORD"
62-
await po.selectCountryCode();
63-
64-
// And I type my "phone number" with status "FORCE_CHANGE_PASSWORD"
61+
// When I type my "phone number" with status "FORCE_CHANGE_PASSWORD"
6562
await po.enterUsername(phoneNumber.withOutCountryCode());
6663

6764
// And I type my password
@@ -95,10 +92,7 @@ void main() {
9592
]),
9693
);
9794

98-
// When I select my country code with status "FORCE_CHANGE_PASSWORD"
99-
await po.selectCountryCode();
100-
101-
// And I type my "phone number" with status "FORCE_CHANGE_PASSWORD"
95+
// When I type my "phone number" with status "FORCE_CHANGE_PASSWORD"
10296
await po.enterUsername(phoneNumber.withOutCountryCode());
10397

10498
// And I type my password
@@ -148,10 +142,7 @@ void main() {
148142
]),
149143
);
150144

151-
// When I select my country code with status "FORCE_CHANGE_PASSWORD"
152-
await po.selectCountryCode();
153-
154-
// And I type my "phone number" with status "FORCE_CHANGE_PASSWORD"
145+
// When I type my "phone number" with status "FORCE_CHANGE_PASSWORD"
155146
await po.enterUsername(phoneNumber.withOutCountryCode());
156147

157148
// And I type my password

packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_test.dart

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ void main() {
5858

5959
signInPage.expectUsername(label: 'Phone Number');
6060

61-
// When I select my country code
62-
await signInPage.selectCountryCode();
63-
64-
// And I type my "phone number" with status "CONFIRMED"
61+
// When I type my "phone number" with status "CONFIRMED"
6562
await signInPage.enterUsername(phoneNumber.withOutCountryCode());
6663

6764
// And I type my password
@@ -95,10 +92,7 @@ void main() {
9592

9693
signInPage.expectUsername(label: 'Phone Number');
9794

98-
// When I select my country code
99-
await signInPage.selectCountryCode();
100-
101-
// And I type my "phone number" with status "CONFIRMED"
95+
// When I type my "phone number" with status "CONFIRMED"
10296
await signInPage.enterUsername(phoneNumber.withOutCountryCode());
10397

10498
// And I type my password
@@ -134,10 +128,7 @@ void main() {
134128

135129
signInPage.expectUsername(label: 'Phone Number');
136130

137-
// When I select my country code
138-
await signInPage.selectCountryCode();
139-
140-
// And I type my "phone number" with status "CONFIRMED"
131+
// When I type my "phone number" with status "CONFIRMED"
141132
await signInPage.enterUsername(phoneNumber.withOutCountryCode());
142133

143134
// And I type my password
@@ -174,10 +165,7 @@ void main() {
174165

175166
final signInPage = SignInPage(tester: tester);
176167

177-
// When I select my country code
178-
await signInPage.selectCountryCode();
179-
180-
// And I type my "phone number" with status "UNKNOWN"
168+
// When I type my "phone number" with status "UNKNOWN"
181169
await signInPage.enterUsername(phoneNumber.withOutCountryCode());
182170

183171
// And I type my password

packages/authenticator/amplify_authenticator/example/integration_test/sign_in_with_phone_test.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ void main() {
4343

4444
final signInPage = SignInPage(tester: tester);
4545

46-
// When I select my country code
47-
await signInPage.selectCountryCode();
48-
49-
// And I type my "phone number" with status "UNKNOWN"
46+
// When I type my "phone number" with status "UNKNOWN"
5047
await signInPage.enterUsername(phoneNumber.withOutCountryCode());
5148

5249
// And I type my password
@@ -92,9 +89,6 @@ void main() {
9289

9390
signInPage.expectUsername(label: 'Phone Number');
9491

95-
// When I select my country code
96-
await signInPage.selectCountryCode();
97-
9892
// When I type my "username" with status "unconfirmed"
9993
await signInPage.enterUsername(phoneNumber.withOutCountryCode());
10094

packages/authenticator/amplify_authenticator/example/integration_test/sign_up_with_phone_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ void main() {
9696
final password = generatePassword();
9797
final email = generateEmail();
9898

99-
// When I select my country code
100-
await signUpPage.selectCountryCode();
99+
// When I enter my phone number
101100
await signUpPage.enterUsername(phoneNumber.withOutCountryCode());
102101

103102
// And I type my password

packages/authenticator/amplify_authenticator/lib/src/mixins/authenticator_phone_field.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ mixin AuthenticatorPhoneFieldMixin<FieldType extends Enum,
6868
child: SearchAnchor(
6969
// Always use full screen at small break point. Otherwise use default
7070
// behavior.
71+
key: keySelectCountryCode,
7172
isFullScreen: Breakpoint.of(context) == Breakpoint.small ? true : null,
7273
viewHintText: _dialCodeResolver.resolve(
7374
context,
@@ -93,6 +94,17 @@ mixin AuthenticatorPhoneFieldMixin<FieldType extends Enum,
9394
minWidth: 360,
9495
maxHeight: 300,
9596
),
97+
// Custom suggestion list widget. This displays the output of `suggestionsBuilder`
98+
viewBuilder: (suggestions) {
99+
return ListView.builder(
100+
key: keyCountryDialog,
101+
itemCount: suggestions.length,
102+
itemBuilder: (BuildContext context, int index) {
103+
return suggestions.elementAt(index);
104+
},
105+
);
106+
},
107+
// Custom suggestion item widgets
96108
suggestionsBuilder: ((context, SearchController controller) {
97109
final textStyle = Theme.of(context).listTileTheme.titleTextStyle ??
98110
const TextStyle(fontSize: 15);

packages/authenticator/amplify_authenticator_test/lib/src/pages/authenticator_page.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,17 @@ abstract class AuthenticatorPage {
126126
await tester.tap(countrySelectField);
127127
await tester.pumpAndSettle();
128128
expect(countrySelectDialog, findsOneWidget);
129-
expect(countrySearchField, findsOneWidget);
130-
await tester.enterText(countrySearchField, countryName);
131-
await tester.pumpAndSettle();
132129
final dialCode = find.descendant(
133130
of: find.byKey(keyCountryDialog),
134-
matching: find.textContaining('($countryCode)'),
131+
matching: find.textContaining(countryCode),
132+
);
133+
await tester.dragUntilVisible(
134+
dialCode,
135+
countrySelectDialog,
136+
const Offset(0, -250),
137+
maxIteration: 100, // delta to move
135138
);
139+
await tester.pumpAndSettle();
136140
expect(dialCode, findsOneWidget);
137141
await tester.tap(dialCode);
138142
}

0 commit comments

Comments
 (0)