-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
241 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bin/flutterflow | ||
.dart_tool/ | ||
export/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
import 'package:flutterflow_cli/src/flutterflow_main.dart'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
import 'dart:io'; | ||
|
||
String kProjectId = 'app-with-assets-and-custom-fonts-qxwg6o'; | ||
String kToken = Platform.environment['FF_TESTER_TOKEN'] ?? 'not-set'; | ||
|
||
bool buildProject(String project) { | ||
var result = | ||
Process.runSync('flutter', ['build', 'web'], workingDirectory: project); | ||
|
||
return result.exitCode == 0; | ||
} | ||
|
||
bool checkAssets(String project) { | ||
var assets = [ | ||
'assets/images/6740bca9ed26c9a34b1ab1ce.png', | ||
'assets/images/6785366c3e83b0072fdc8ef4.png', | ||
'assets/images/6740b4b5cf7b4fdf95795e2c.png', | ||
'assets/images/6740af8ffbd4c3414fcf5728.png', | ||
'assets/images/6740aff03c7e45b220ed9775.png', | ||
'assets/images/6740b3cca8e014dee9325b5d.png', | ||
'assets/images/6740b4b5c0adf773476a5452.png', | ||
'assets/images/67895d616be6f220ee4ec9c3.png', | ||
'assets/images/6740b4b494d7239248fa491e.png', | ||
'assets/images/67895d6177fc072b5e166fd1.png', | ||
'assets/images/6740ae761553efad6aa2a5d4.png', | ||
'assets/images/6740bca9c28f22a68495d368.png', | ||
'assets/images/6744ab4d50d5a3dad758fa39.png', | ||
'assets/images/6785366c77c17f02779e160c.png', | ||
'assets/images/6740aff0d10e0295e5fe33e6.png', | ||
'assets/images/6785366c215b774f00c041a3.png', | ||
'assets/images/67895d61a7af8d11cb9aa957.png', | ||
'assets/images/6740ae76c0adf77347645294.png', | ||
'assets/images/6740b3cc6d3624484183520b.png', | ||
'assets/fonts/JetBrainsMonoNerdFont-Regular.ttf', | ||
'assets/fonts/MartianMonoNerdFont-Medium.ttf', | ||
'assets/fonts/JetBrainsMonoNerdFont-Bold.ttf', | ||
'assets/fonts/ProFontIIxNerdFontMono-Regular.ttf', | ||
'assets/fonts/ProFontIIxNerdFontPropo-Regular.ttf', | ||
'assets/fonts/JetBrainsMonoNerdFont-Italic.ttf', | ||
'assets/fonts/favicon.png', | ||
'assets/fonts/MartianMonoNerdFont-Regular.ttf', | ||
'assets/fonts/MartianMonoNerdFont-Bold.ttf', | ||
'assets/fonts/ProFontIIxNerdFont-Regular.ttf', | ||
]; | ||
|
||
for (var asset in assets) { | ||
if (File('$project/$asset').existsSync() == false) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void main() { | ||
test('Default parameters', () async { | ||
final project = 'export/app_with_assets_and_custom_fonts'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
'export', | ||
]); | ||
|
||
// Missing assets | ||
expect(checkAssets(project), false); | ||
expect(buildProject(project), false); | ||
}); | ||
|
||
test('Fix code', () async { | ||
final project = 'export/fix_code'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--no-parent-folder', | ||
'--include-assets', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
project, | ||
'--fix', | ||
]); | ||
|
||
// Fix will add 'const' to a lot of stuff :-) | ||
expect( | ||
File('$project/lib/main.dart') | ||
.readAsStringSync() | ||
.contains('localizationsDelegates: const ['), | ||
true); | ||
|
||
expect(checkAssets(project), true); | ||
expect(buildProject(project), true); | ||
}); | ||
|
||
test('Branch', () async { | ||
final project = 'export/branch'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--no-parent-folder', | ||
'--include-assets', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
project, | ||
'--branch-name', | ||
'TestBranch', | ||
]); | ||
|
||
expect( | ||
File('$project/lib/pages/page_only_on_this_branch/page_only_on_this_branch_widget.dart') | ||
.existsSync(), | ||
true); | ||
|
||
expect(checkAssets(project), true); | ||
expect(buildProject(project), true); | ||
}); | ||
|
||
test('Commit', () async { | ||
final project = 'export/commit'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--no-parent-folder', | ||
'--include-assets', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
project, | ||
'--commit-hash', | ||
'0jfsCktnCmIcNp02q3yW', | ||
]); | ||
|
||
expect( | ||
File('$project/lib/pages/page_only_on_this_commit/page_only_on_this_commit_widget.dart') | ||
.existsSync(), | ||
true); | ||
|
||
expect(checkAssets(project), true); | ||
expect(buildProject(project), true); | ||
}); | ||
|
||
test('Debug', () async { | ||
final project = 'export/debug'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--no-parent-folder', | ||
'--include-assets', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
project, | ||
'--as-debug', | ||
]); | ||
|
||
// Debug instrumentation added by the flag | ||
expect( | ||
File('$project/lib/main.dart') | ||
.readAsStringSync() | ||
.contains('debugLogGlobalProperty'), | ||
true); | ||
|
||
expect(checkAssets(project), true); | ||
expect(buildProject(project), true); | ||
}); | ||
|
||
test('Module', () async { | ||
final project = 'export/module'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--no-parent-folder', | ||
'--include-assets', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
project, | ||
'--as-module', | ||
]); | ||
|
||
expect(File('$project/pubspec.yaml').readAsStringSync().contains('module:'), | ||
true); | ||
|
||
expect(checkAssets(project), true); | ||
expect(buildProject(project), true); | ||
}); | ||
|
||
test('Environment', () async { | ||
final project = 'export/environment'; | ||
|
||
await appMain([ | ||
'export-code', | ||
'--no-parent-folder', | ||
'--include-assets', | ||
'--project', | ||
kProjectId, | ||
'--token', | ||
kToken, | ||
'-d', | ||
project, | ||
'--project-environment', | ||
'Development', | ||
]); | ||
|
||
expect( | ||
File('$project/assets/environment_values/environment.json') | ||
.readAsStringSync() | ||
.contains('"foobar": "barfoo"'), | ||
true); | ||
|
||
expect(checkAssets(project), true); | ||
expect(buildProject(project), true); | ||
}); | ||
} |