Skip to content

Commit 3ac1f77

Browse files
authored
chore: fix ci (#182)
* try latest macos runner * bump firestore-ios-sdk-frameworks version * try reactivecircus/android-emulator-runner * wip * add manual invokation * disable macos and ios * default target * tune target and arch * api level 31 * uncomment actual wf * add target and arch * fix script * fix working directory * run flutter devices * install flutter before flutter devices * complete android setup * use pixel 5 * enable ios and macos e2e * use profile * use anyIPv4 * move some email form tests from e2e to unit * update avd cache key * fix device name * disable email link to anonymous user * fix unit test * fix sms code input error test
1 parent 74b4817 commit 3ac1f77

File tree

7 files changed

+192
-155
lines changed

7 files changed

+192
-155
lines changed

.github/workflows/e2e.yml

+38-36
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,26 @@ on:
2121
- "**.md"
2222
- "**.png"
2323
- "**.jpg"
24+
workflow_dispatch:
2425

2526
jobs:
2627
android:
27-
runs-on: macos-13
28+
runs-on: macos-latest
2829
timeout-minutes: 45
2930
steps:
3031
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
32+
- name: Create AVD and generate snapshot for caching
33+
if: steps.avd-cache.outputs.cache-hit != 'true'
34+
uses: reactivecircus/android-emulator-runner@v2
35+
with:
36+
api-level: 31
37+
force-avd-creation: false
38+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
39+
disable-animations: false
40+
target: google_apis
41+
arch: x86_64
42+
profile: pixel_5
43+
script: echo "Generated AVD snapshot for caching."
3144
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
3245
name: Install Node.js 16
3346
with:
@@ -36,30 +49,27 @@ jobs:
3649
with:
3750
distribution: "temurin"
3851
java-version: "11"
39-
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
40-
name: Gradle Cache
41-
with:
42-
path: ~/.gradle/caches
43-
key: ${{ runner.os }}-gradle-v4-${{ hashFiles('**/*.gradle*') }}
44-
restore-keys: ${{ runner.os }}-gradle-v4
45-
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
46-
name: AVD Cache
52+
- name: Gradle cache
53+
uses: gradle/gradle-build-action@v2
54+
55+
- name: AVD cache
56+
uses: actions/cache@v3
4757
id: avd-cache
4858
with:
4959
path: |
5060
~/.android/avd/*
5161
~/.android/adb*
52-
key: avd
62+
key: avd-pixel
63+
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
64+
with:
65+
channel: "stable"
66+
cache: true
5367
- name: Firebase Emulator Cache
5468
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
5569
with:
5670
path: ~/.cache/firebase/emulators
5771
key: firebase-emulators-v2-${{ github.run_id }}
5872
restore-keys: firebase-emulators-v2
59-
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
60-
with:
61-
channel: "stable"
62-
cache: true
6373
- uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a
6474
with:
6575
run-bootstrap: false
@@ -77,29 +87,21 @@ jobs:
7787
cd ../emulator_proxy
7888
echo "Starting emulator proxy"
7989
dart run emulator_proxy:start 100 &
80-
- name: Create and start emulator
81-
# We use the installed SDK in the macOS image to create and start the emulator
82-
run: |
83-
echo "List installed packages"
84-
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed
85-
86-
echo "Installing system image"
87-
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-33;google_apis;x86_64"
88-
89-
echo "Creating AVD"
90-
echo "no" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n test_emulator -k "system-images;android-33;google_apis;x86_64" --force --device "pixel_5"
91-
92-
echo "Starting emulator"
93-
$ANDROID_SDK_ROOT/emulator/emulator -avd test_emulator -no-audio -no-boot-anim -no-window &
94-
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
95-
- name: "E2E Tests"
96-
working-directory: tests
97-
run: |
98-
flutter test integration_test/firebase_ui_test.dart --dart-define=CI=true
90+
- name: E2E Tests
91+
uses: reactivecircus/android-emulator-runner@v2
92+
with:
93+
working-directory: tests
94+
api-level: 31
95+
force-avd-creation: false
96+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
97+
disable-animations: true
98+
target: google_apis
99+
arch: x86_64
100+
profile: pixel_5
101+
script: flutter devices && flutter test integration_test/firebase_ui_test.dart --dart-define=CI=true
99102

100103
ios:
101-
# Dropped down to macos-12 as macos-13 was timing out. This suspected issue:https://github.com/actions/runner-images/issues/8023
102-
runs-on: macos-12
104+
runs-on: macos-latest
103105
timeout-minutes: 45
104106
steps:
105107
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
@@ -176,7 +178,7 @@ jobs:
176178
flutter test ./integration_test/firebase_ui_test.dart -d "$SIMULATOR" --dart-define=CI=true
177179
178180
macos:
179-
runs-on: macos-13
181+
runs-on: macos-latest
180182
timeout-minutes: 45
181183
steps:
182184
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

emulator_proxy/lib/emulator_proxy.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class EmulatorProxy {
1919

2020
Future<void> serve() async {
2121
final server = await HttpServer.bind(
22-
InternetAddress.loopbackIPv4,
22+
InternetAddress.anyIPv4,
2323
proxyPort,
2424
);
2525

packages/firebase_ui_auth/test/widgets/email_form_test.dart

+126
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:firebase_ui_localizations/firebase_ui_localizations.dart';
56
import 'package:flutter/material.dart';
67
import 'package:flutter_test/flutter_test.dart';
78
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
@@ -15,6 +16,8 @@ import '../test_utils.dart';
1516
class MockFirebaseAuth extends Mock implements fba.FirebaseAuth {}
1617

1718
void main() {
19+
const labels = DefaultLocalizations();
20+
1821
group('EmailForm', () {
1922
late Widget widget;
2023

@@ -153,5 +156,128 @@ void main() {
153156
isFalse,
154157
);
155158
});
159+
160+
testWidgets('validates email', (tester) async {
161+
await tester.pumpWidget(
162+
TestMaterialApp(
163+
child: EmailForm(
164+
auth: MockAuth(),
165+
),
166+
),
167+
);
168+
169+
final inputs = find.byType(TextFormField);
170+
final emailInput = inputs.first;
171+
172+
await tester.enterText(emailInput, 'not a vailid email');
173+
await tester.testTextInput.receiveAction(TextInputAction.done);
174+
await tester.pumpAndSettle();
175+
176+
expect(find.text(labels.isNotAValidEmailErrorText), findsOneWidget);
177+
});
178+
179+
testWidgets('requires password', (tester) async {
180+
await tester.pumpWidget(
181+
TestMaterialApp(
182+
child: EmailForm(
183+
auth: MockAuth(),
184+
),
185+
),
186+
);
187+
188+
final inputs = find.byType(TextFormField);
189+
final emailInput = inputs.first;
190+
final passwordInput = inputs.at(1);
191+
192+
await tester.enterText(emailInput, '[email protected]');
193+
await tester.testTextInput.receiveAction(TextInputAction.done);
194+
195+
await tester.enterText(passwordInput, '');
196+
await tester.pumpAndSettle();
197+
198+
expect(find.text(labels.passwordIsRequiredErrorText), findsOneWidget);
199+
});
200+
201+
testWidgets(
202+
'shows password confirmation if action is sign up',
203+
(tester) async {
204+
await tester.pumpWidget(
205+
TestMaterialApp(
206+
child: EmailForm(
207+
auth: MockAuth(),
208+
action: AuthAction.signUp,
209+
),
210+
),
211+
);
212+
213+
final inputs = find.byType(TextFormField);
214+
expect(inputs, findsNWidgets(3));
215+
},
216+
);
217+
218+
testWidgets(
219+
'requires password confirmation',
220+
(tester) async {
221+
await tester.pumpWidget(
222+
TestMaterialApp(
223+
child: EmailForm(
224+
auth: MockAuth(),
225+
action: AuthAction.signUp,
226+
),
227+
),
228+
);
229+
230+
final inputs = find.byType(TextFormField);
231+
232+
await tester.enterText(inputs.at(0), '[email protected]');
233+
await tester.testTextInput.receiveAction(TextInputAction.done);
234+
235+
await tester.enterText(inputs.at(1), 'password');
236+
await tester.testTextInput.receiveAction(TextInputAction.done);
237+
238+
await tester.enterText(inputs.at(2), '');
239+
await tester.testTextInput.receiveAction(TextInputAction.done);
240+
241+
await tester.pumpAndSettle();
242+
243+
expect(
244+
find.text(labels.confirmPasswordIsRequiredErrorText),
245+
findsOneWidget,
246+
);
247+
},
248+
);
249+
250+
testWidgets(
251+
'verifies that password confirmation matches password',
252+
(tester) async {
253+
await tester.pumpWidget(
254+
TestMaterialApp(
255+
child: EmailForm(
256+
auth: MockAuth(),
257+
action: AuthAction.signUp,
258+
),
259+
),
260+
);
261+
262+
final inputs = find.byType(TextFormField);
263+
264+
await tester.enterText(inputs.at(0), '[email protected]');
265+
await tester.testTextInput.receiveAction(TextInputAction.done);
266+
await tester.pump();
267+
268+
await tester.enterText(inputs.at(1), 'password');
269+
await tester.testTextInput.receiveAction(TextInputAction.done);
270+
await tester.pump();
271+
272+
await tester.enterText(inputs.at(2), 'psasword');
273+
await tester.testTextInput.receiveAction(TextInputAction.done);
274+
await tester.pumpAndSettle();
275+
276+
expect(
277+
find.text(labels.confirmPasswordDoesNotMatchErrorText),
278+
findsOneWidget,
279+
);
280+
},
281+
);
156282
});
157283
}

0 commit comments

Comments
 (0)