Skip to content

Commit 59f5915

Browse files
committed
Add integration tests
Add a test that will export and build using our various flags and check if the command is behaving as expected on all the platforms we support.
1 parent bad3343 commit 59f5915

File tree

3 files changed

+246
-4
lines changed

3 files changed

+246
-4
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ on: push
33

44
env:
55
# Keep this in sync with the version used by FlutterFlow.
6-
DART_VERSION: 3.4.3
6+
DART_VERSION: 3.5.2
7+
FLUTTER_VERSION: 3.24.2
78

89
jobs:
910
check:
@@ -44,10 +45,12 @@ jobs:
4445
- name: Clone repository
4546
uses: actions/checkout@v4
4647

47-
- name: Setup Dart
48-
uses: dart-lang/setup-dart@v1
48+
- name: Setup Flutter
49+
uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2
4950
with:
50-
sdk: ${{ env.DART_VERSION }}
51+
channel: master
52+
flutter-version: ${{ env.FLUTTER_VERSION }}
53+
cache: true
5154

5255
- name: Install dependencies
5356
run: |
@@ -62,5 +65,7 @@ jobs:
6265
dart run bin/flutterflow_cli.dart -h
6366
6467
- name: Test
68+
env:
69+
FF_TESTER_TOKEN: ${{ secrets.FF_TESTER_TOKEN }}
6570
run: |
6671
dart test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bin/flutterflow
22
.dart_tool/
3+
export/

test/integration_test.dart

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
import 'package:flutterflow_cli/src/flutterflow_main.dart';
2+
3+
// See: https://pub.dev/packages/test#timeouts
4+
// ignore: invalid_annotation_target
5+
@Timeout(Duration(seconds: 360))
6+
import 'package:test/test.dart';
7+
8+
import 'dart:io';
9+
10+
String kProjectId = 'app-with-assets-and-custom-fonts-qxwg6o';
11+
String kToken = Platform.environment['FF_TESTER_TOKEN'] ?? 'not-set';
12+
13+
bool buildProject(String project) {
14+
var result =
15+
Process.runSync('flutter', ['build', 'web'], workingDirectory: project);
16+
17+
return result.exitCode == 0;
18+
}
19+
20+
bool checkAssets(String project) {
21+
var assets = [
22+
'assets/images/6740bca9ed26c9a34b1ab1ce.png',
23+
'assets/images/6785366c3e83b0072fdc8ef4.png',
24+
'assets/images/6740b4b5cf7b4fdf95795e2c.png',
25+
'assets/images/6740af8ffbd4c3414fcf5728.png',
26+
'assets/images/6740aff03c7e45b220ed9775.png',
27+
'assets/images/6740b3cca8e014dee9325b5d.png',
28+
'assets/images/6740b4b5c0adf773476a5452.png',
29+
'assets/images/67895d616be6f220ee4ec9c3.png',
30+
'assets/images/6740b4b494d7239248fa491e.png',
31+
'assets/images/67895d6177fc072b5e166fd1.png',
32+
'assets/images/6740ae761553efad6aa2a5d4.png',
33+
'assets/images/6740bca9c28f22a68495d368.png',
34+
'assets/images/6744ab4d50d5a3dad758fa39.png',
35+
'assets/images/6785366c77c17f02779e160c.png',
36+
'assets/images/6740aff0d10e0295e5fe33e6.png',
37+
'assets/images/6785366c215b774f00c041a3.png',
38+
'assets/images/67895d61a7af8d11cb9aa957.png',
39+
'assets/images/6740ae76c0adf77347645294.png',
40+
'assets/images/6740b3cc6d3624484183520b.png',
41+
'assets/fonts/JetBrainsMonoNerdFont-Regular.ttf',
42+
'assets/fonts/MartianMonoNerdFont-Medium.ttf',
43+
'assets/fonts/JetBrainsMonoNerdFont-Bold.ttf',
44+
'assets/fonts/ProFontIIxNerdFontMono-Regular.ttf',
45+
'assets/fonts/ProFontIIxNerdFontPropo-Regular.ttf',
46+
'assets/fonts/JetBrainsMonoNerdFont-Italic.ttf',
47+
'assets/fonts/favicon.png',
48+
'assets/fonts/MartianMonoNerdFont-Regular.ttf',
49+
'assets/fonts/MartianMonoNerdFont-Bold.ttf',
50+
'assets/fonts/ProFontIIxNerdFont-Regular.ttf',
51+
];
52+
53+
for (var asset in assets) {
54+
if (File('$project/$asset').existsSync() == false) {
55+
return false;
56+
}
57+
}
58+
59+
return true;
60+
}
61+
62+
void main() {
63+
test('Default parameters', () async {
64+
final project = 'export/app_with_assets_and_custom_fonts';
65+
66+
await appMain([
67+
'export-code',
68+
'--project',
69+
kProjectId,
70+
'--token',
71+
kToken,
72+
'-d',
73+
'export',
74+
]);
75+
76+
// Missing assets
77+
expect(checkAssets(project), false);
78+
expect(buildProject(project), false);
79+
});
80+
81+
test('Fix code', () async {
82+
final project = 'export/fix_code';
83+
84+
await appMain([
85+
'export-code',
86+
'--no-parent-folder',
87+
'--include-assets',
88+
'--project',
89+
kProjectId,
90+
'--token',
91+
kToken,
92+
'-d',
93+
project,
94+
'--fix',
95+
]);
96+
97+
// Fix will add 'const' to a lot of stuff :-)
98+
expect(
99+
File('$project/lib/main.dart')
100+
.readAsStringSync()
101+
.contains('localizationsDelegates: const ['),
102+
true);
103+
104+
expect(checkAssets(project), true);
105+
expect(buildProject(project), true);
106+
});
107+
108+
test('Branch', () async {
109+
final project = 'export/branch';
110+
111+
await appMain([
112+
'export-code',
113+
'--no-parent-folder',
114+
'--include-assets',
115+
'--project',
116+
kProjectId,
117+
'--token',
118+
kToken,
119+
'-d',
120+
project,
121+
'--branch-name',
122+
'TestBranch',
123+
]);
124+
125+
expect(
126+
File('$project/lib/pages/page_only_on_this_branch/page_only_on_this_branch_widget.dart')
127+
.existsSync(),
128+
true);
129+
130+
expect(checkAssets(project), true);
131+
expect(buildProject(project), true);
132+
});
133+
134+
test('Commit', () async {
135+
final project = 'export/commit';
136+
137+
await appMain([
138+
'export-code',
139+
'--no-parent-folder',
140+
'--include-assets',
141+
'--project',
142+
kProjectId,
143+
'--token',
144+
kToken,
145+
'-d',
146+
project,
147+
'--commit-hash',
148+
'0jfsCktnCmIcNp02q3yW',
149+
]);
150+
151+
expect(
152+
File('$project/lib/pages/page_only_on_this_commit/page_only_on_this_commit_widget.dart')
153+
.existsSync(),
154+
true);
155+
156+
expect(checkAssets(project), true);
157+
expect(buildProject(project), true);
158+
});
159+
160+
test('Debug', () async {
161+
final project = 'export/debug';
162+
163+
await appMain([
164+
'export-code',
165+
'--no-parent-folder',
166+
'--include-assets',
167+
'--project',
168+
kProjectId,
169+
'--token',
170+
kToken,
171+
'-d',
172+
project,
173+
'--as-debug',
174+
]);
175+
176+
// Debug instrumentation added by the flag
177+
expect(
178+
File('$project/lib/main.dart')
179+
.readAsStringSync()
180+
.contains('debugLogGlobalProperty'),
181+
true);
182+
183+
expect(checkAssets(project), true);
184+
expect(buildProject(project), true);
185+
});
186+
187+
test('Module', () async {
188+
final project = 'export/module';
189+
190+
await appMain([
191+
'export-code',
192+
'--no-parent-folder',
193+
'--include-assets',
194+
'--project',
195+
kProjectId,
196+
'--token',
197+
kToken,
198+
'-d',
199+
project,
200+
'--as-module',
201+
]);
202+
203+
expect(File('$project/pubspec.yaml').readAsStringSync().contains('module:'),
204+
true);
205+
206+
expect(checkAssets(project), true);
207+
expect(buildProject(project), true);
208+
});
209+
210+
test('Environment', () async {
211+
final project = 'export/environment';
212+
213+
await appMain([
214+
'export-code',
215+
'--no-parent-folder',
216+
'--include-assets',
217+
'--project',
218+
kProjectId,
219+
'--token',
220+
kToken,
221+
'-d',
222+
project,
223+
'--project-environment',
224+
'Development',
225+
]);
226+
227+
expect(
228+
File('$project/assets/environment_values/environment.json')
229+
.readAsStringSync()
230+
.contains('"foobar": "barfoo"'),
231+
true);
232+
233+
expect(checkAssets(project), true);
234+
expect(buildProject(project), true);
235+
});
236+
}

0 commit comments

Comments
 (0)