Skip to content

Commit f873242

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 f873242

File tree

3 files changed

+241
-4
lines changed

3 files changed

+241
-4
lines changed

.github/workflows/main.yml

+7-4
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: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bin/flutterflow
22
.dart_tool/
3+
export/

test/integration_test.dart

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

0 commit comments

Comments
 (0)