Skip to content

Commit 7e5c5c2

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 e3b7af7 commit 7e5c5c2

File tree

3 files changed

+262
-5
lines changed

3 files changed

+262
-5
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 5 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:
@@ -38,16 +39,18 @@ jobs:
3839

3940
strategy:
4041
matrix:
41-
os: [ubuntu-24.04, windows-2022, macos-14]
42+
os: [ubuntu-24.04, windows-2025, windows-2022, macos-14]
4243

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

0 commit comments

Comments
 (0)