Skip to content

Commit f85dc82

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 88e97e6 commit f85dc82

File tree

3 files changed

+263
-5
lines changed

3 files changed

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

0 commit comments

Comments
 (0)