[Fix] Integration test flakes. (#2635)

* feat: add tearDown and tearDownAll to reset workspaces

* fix: register tearDown and tearDownAll in empty_document_test

* feat: register tearDown and tearDownAll in board_test

* feat: register tearDown and tearDownAll in open_ai
This commit is contained in:
Alex Wallen 2023-05-28 10:23:20 -10:00 committed by GitHub
parent 7ca028942c
commit 5a7339b092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 1 deletions

View File

@ -34,6 +34,8 @@ void main() {
group('board', () {
setUpAll(() async => await service.setUpAll());
setUp(() async => await service.setUp());
tearDown(() async => await service.tearDown());
tearDownAll(() async => await service.tearDownAll());
testWidgets(
'integration test unzips the proper workspace and loads it correctly.',

View File

@ -30,6 +30,8 @@ void main() {
group('Tests on a workspace with only an empty document', () {
setUpAll(() async => await service.setUpAll());
setUp(() async => await service.setUp());
tearDown(() async => await service.tearDown());
tearDownAll(() async => await service.tearDownAll());
testWidgets('/board shortcut creates a new board and view of the board',
(tester) async {
@ -69,6 +71,7 @@ void main() {
],
tester: tester,
);
await tester.pumpAndSettle();
// Checks whether new board is referenced and properly on the page.
expect(find.byType(BuiltInPageWidget), findsOneWidget);
@ -113,7 +116,12 @@ void main() {
expect(find.byType(SelectionMenuItemWidget), findsAtLeastNWidgets(2));
// Finalizes the slash command that creates the board.
await simulateKeyDownEvent(LogicalKeyboardKey.enter);
await FlowyTestKeyboard.simulateKeyDownEvent(
[
LogicalKeyboardKey.enter,
],
tester: tester,
);
await tester.pumpAndSettle();
// Checks whether new board is referenced and properly on the page.

View File

@ -16,6 +16,8 @@ void main() {
group('integration tests for open-ai smart menu', () {
setUpAll(() async => await service.setUpAll());
setUp(() async => await service.setUp());
tearDown(() async => await service.tearDown());
tearDownAll(() async => await service.tearDownAll());
testWidgets('testing selection on open-ai smart menu replace', (tester) async {
final appFlowyEditor = await setUpOpenAITesting(tester);

View File

@ -39,6 +39,13 @@ enum TestWorkspace {
return root;
}
Future<void> clean() async {
final Directory workspaceRoot = await root;
if (await workspaceRoot.exists()) {
workspaceRoot.delete(recursive: true);
}
}
String get _asset => 'assets/test/workspaces/$_name.zip';
}
@ -67,4 +74,12 @@ class TestWorkspaceService {
await TestWorkspace._parent.then((value) => value.path),
);
}
Future<void> tearDown() async {
await workspace.clean();
}
Future<void> tearDownAll() async {
await SharedPreferences.getInstance().then((value) => value.remove(kSettingsLocationDefaultLocation));
}
}