Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: enable codecov action (#2741)

Lucas.Xud5887b0a12d1
diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml
index a46cb8034d..0cd9086ee1 100644
--- a/.github/workflows/flutter_ci.yaml
+++ b/.github/workflows/flutter_ci.yaml
@@ -68,7 +68,7 @@ jobs:
with:
prefix-key: ${{ matrix.os }}
workspaces: |
- frontend/rust-lib
+ frontend/rust-lib
- uses: davidB/rust-cargo-make@v1
with:
@@ -118,3 +118,10 @@ jobs:
working-directory: frontend
run: |
cargo make dart_unit_test
+
+ - uses: codecov/codecov-action@v3
+ with:
+ name: appflowy
+ flags: appflowy_flutter_unit_test
+ fail_ci_if_error: true
+ verbose: true
\ No newline at end of file
diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml
index ef8fb0c0b1..16a004c1d3 100644
--- a/.github/workflows/integration_test.yml
+++ b/.github/workflows/integration_test.yml
@@ -116,10 +116,9 @@ jobs:
fi
shell: bash
- # - uses: codecov/codecov-action@v3
- # with:
- # name: appflowy
- # flags: appflowy
- # env_vars: ${{ matrix.os }}
- # fail_ci_if_error: true
- # verbose: true
+ - uses: codecov/codecov-action@v3
+ with:
+ name: appflowy
+ flags: appflowy_flutter_integrateion_test
+ fail_ci_if_error: true
+ verbose: true
diff --git a/frontend/appflowy_flutter/.gitignore b/frontend/appflowy_flutter/.gitignore
index a0886f8dbc..8bf1c9abfe 100644
--- a/frontend/appflowy_flutter/.gitignore
+++ b/frontend/appflowy_flutter/.gitignore
@@ -70,3 +70,5 @@ windows/flutter/dart_ffi/
**/.vscode/
*.env
+
+coverage/
diff --git a/frontend/appflowy_flutter/assets/test/workspaces/board.zip b/frontend/appflowy_flutter/assets/test/workspaces/board.zip
index 1a8f6b0dd4..1177d03996 100644
Binary files a/frontend/appflowy_flutter/assets/test/workspaces/board.zip and b/frontend/appflowy_flutter/assets/test/workspaces/board.zip differ
diff --git a/frontend/appflowy_flutter/assets/test/workspaces/cover_image.zip b/frontend/appflowy_flutter/assets/test/workspaces/cover_image.zip
index 65501f52fb..d705090c3b 100644
Binary files a/frontend/appflowy_flutter/assets/test/workspaces/cover_image.zip and b/frontend/appflowy_flutter/assets/test/workspaces/cover_image.zip differ
diff --git a/frontend/appflowy_flutter/assets/test/workspaces/empty_document.zip b/frontend/appflowy_flutter/assets/test/workspaces/empty_document.zip
index 1399d640ad..ec70e5dcb3 100644
Binary files a/frontend/appflowy_flutter/assets/test/workspaces/empty_document.zip and b/frontend/appflowy_flutter/assets/test/workspaces/empty_document.zip differ
diff --git a/frontend/appflowy_flutter/integration_test/board_test.dart b/frontend/appflowy_flutter/integration_test/board_test.dart
index c67f7b0624..3ac479bd70 100644
--- a/frontend/appflowy_flutter/integration_test/board_test.dart
+++ b/frontend/appflowy_flutter/integration_test/board_test.dart
@@ -35,9 +35,7 @@ void main() {
setUpAll(() async => await service.setUpAll());
setUp(() async => await service.setUp());
- testWidgets(
- 'integration test unzips the proper workspace and loads it correctly.',
- (tester) async {
+ testWidgets('open the board with data structure in v0.2.0', (tester) async {
await tester.initializeAppFlowy();
expect(find.byType(AppFlowyBoard), findsOneWidget);
});
diff --git a/frontend/appflowy_flutter/integration_test/cover_image_test.dart b/frontend/appflowy_flutter/integration_test/cover_image_test.dart
index 22db65240f..1d5f092992 100644
--- a/frontend/appflowy_flutter/integration_test/cover_image_test.dart
+++ b/frontend/appflowy_flutter/integration_test/cover_image_test.dart
@@ -1,54 +1,35 @@
-import 'package:flowy_infra_ui/widget/rounded_button.dart';
-import 'package:flutter/gestures.dart';
-import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
+
import 'util/util.dart';
-/// Integration tests for an empty board. The [TestWorkspaceService] will load
-/// a workspace from an empty board `assets/test/workspaces/board.zip` for all
-/// tests.
-///
-/// To create another integration test with a preconfigured workspace.
-/// Use the following steps.
-/// 1. Create a new workspace from the AppFlowy launch screen.
-/// 2. Modify the workspace until it is suitable as the starting point for
-/// the integration test you need to land.
-/// 3. Use a zip utility program to zip the workspace folder that you created.
-/// 4. Add the zip file under `assets/test/workspaces/`
-/// 5. Add a new enumeration to [TestWorkspace] in `integration_test/utils/data.dart`.
-/// For example, if you added a workspace called `empty_calendar.zip`,
-/// then [TestWorkspace] should have the following value:
-/// ```dart
-/// enum TestWorkspace {
-/// board('board'),
-/// empty_calendar('empty_calendar');
-///
-/// /* code */
-/// }
-/// ```
-/// 6. Double check that the .zip file that you added is included as an asset in
-/// the pubspec.yaml file under appflowy_flutter.
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
- const service = TestWorkspaceService(TestWorkspace.coverImage);
group('cover image', () {
- setUpAll(() async => await service.setUpAll());
- setUp(() async => await service.setUp());
+ const location = 'cover_image';
+
+ setUp(() async {
+ await TestFolder.cleanTestLocation(location);
+ await TestFolder.setTestLocation(location);
+ });
+
+ tearDown(() async {
+ await TestFolder.cleanTestLocation(location);
+ });
+
+ tearDownAll(() async {
+ await TestFolder.cleanTestLocation(null);
+ });
testWidgets(
'hovering on cover image will display change and delete cover image buttons',
(tester) async {
await tester.initializeAppFlowy();
- expect(find.byType(Image), findsOneWidget);
-
- final TestPointer pointer = TestPointer(1, PointerDeviceKind.mouse);
- final imageFinder = find.byType(Image);
- final Offset offset = tester.getCenter(imageFinder);
- pointer.hover(offset);
- expect(find.byType(RoundedTextButton), findsOneWidget);
+ await tester.tapGoButton();
+ await tester.hoverOnCoverPluginAddButton();
+ await tester.expectToSeePluginAddCoverAndIconButton();
});
});
}
diff --git a/frontend/appflowy_flutter/integration_test/runner.dart b/frontend/appflowy_flutter/integration_test/runner.dart
index 41a78d4eef..6547e795fa 100644
--- a/frontend/appflowy_flutter/integration_test/runner.dart
+++ b/frontend/appflowy_flutter/integration_test/runner.dart
@@ -1,10 +1,8 @@
import 'package:integration_test/integration_test.dart';
-import 'board_test.dart' as board_test;
import 'switch_folder_test.dart' as switch_folder_test;
-import 'empty_document_test.dart' as empty_document_test;
-import 'open_ai_smart_menu_test.dart' as smart_menu_test;
import 'document_test.dart' as document_test;
+import 'cover_image_test.dart' as cover_image_test;
/// The main task runner for all integration tests in AppFlowy.
///
@@ -16,8 +14,9 @@ import 'document_test.dart' as document_test;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
switch_folder_test.main();
- board_test.main();
- empty_document_test.main();
- smart_menu_test.main();
+ cover_image_test.main();
document_test.main();
+ // board_test.main();
+ // empty_document_test.main();
+ // smart_menu_test.main();
}
diff --git a/frontend/appflowy_flutter/integration_test/switch_folder_test.dart b/frontend/appflowy_flutter/integration_test/switch_folder_test.dart
index 40862b5c0d..9fcda587f3 100644
--- a/frontend/appflowy_flutter/integration_test/switch_folder_test.dart
+++ b/frontend/appflowy_flutter/integration_test/switch_folder_test.dart
@@ -1,5 +1,4 @@
-import 'package:appflowy/user/presentation/folder/folder_widget.dart';
-import 'package:flowy_infra_ui/style_widget/text_field.dart';
+import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
@@ -25,60 +24,12 @@ void main() {
await TestFolder.cleanTestLocation(null);
});
- testWidgets(
- 'customize folder name and path when launching app in first time',
- (tester) async {
- const folderName = 'appflowy';
- await TestFolder.cleanTestLocation(folderName);
-
- await tester.initializeAppFlowy();
-
- // Click create button
- await tester.tapCreateButton();
-
- // Set directory
- final cfw = find.byType(CreateFolderWidget);
- expect(cfw, findsOneWidget);
- final state = tester.state(cfw) as CreateFolderWidgetState;
- final dir = await TestFolder.testLocation(null);
- state.directory = dir.path;
-
- // input folder name
- final ftf = find.byType(FlowyTextField);
- expect(ftf, findsOneWidget);
- await tester.enterText(ftf, 'appflowy');
-
- // Click create button again
- await tester.tapCreateButton();
-
- tester.expectToSeeWelcomePage();
-
- await TestFolder.cleanTestLocation(folderName);
- });
-
- testWidgets('open a new folder when launching app in first time',
- (tester) async {
- const folderName = 'appflowy';
- await TestFolder.cleanTestLocation(folderName);
- await TestFolder.setTestLocation(folderName);
-
- await tester.initializeAppFlowy();
-
- // tap open button
- await mockGetDirectoryPath(folderName);
- await tester.tapOpenFolderButton();
-
- await tester.wait(1000);
- tester.expectToSeeWelcomePage();
-
- await TestFolder.cleanTestLocation(folderName);
- });
-
testWidgets('switch to B from A, then switch to A again', (tester) async {
const String userA = 'userA';
const String userB = 'userB';
await TestFolder.cleanTestLocation(userA);
+ await TestFolder.cleanTestLocation(userB);
await TestFolder.setTestLocation(userA);
await tester.initializeAppFlowy();
@@ -88,6 +39,7 @@ void main() {
// switch to user B
{
+ // set user name to userA
await tester.openSettings();
await tester.openSettingsPage(SettingsPage.user);
await tester.enterUserName(userA);
@@ -100,14 +52,15 @@ void main() {
await tester.tapCustomLocationButton();
await tester.pumpAndSettle();
tester.expectToSeeWelcomePage();
- }
- // switch to the userA
- {
+ // set user name to userB
await tester.openSettings();
await tester.openSettingsPage(SettingsPage.user);
await tester.enterUserName(userB);
+ }
+ // switch to the userA
+ {
await tester.openSettingsPage(SettingsPage.files);
await tester.pumpAndSettle();
@@ -117,7 +70,7 @@ void main() {
await tester.pumpAndSettle();
tester.expectToSeeWelcomePage();
- expect(find.textContaining(userA), findsOneWidget);
+ tester.expectToSeeUserName(userA);
}
// switch to the userB again
@@ -132,7 +85,7 @@ void main() {
await tester.pumpAndSettle();
tester.expectToSeeWelcomePage();
- expect(find.textContaining(userB), findsOneWidget);
+ tester.expectToSeeUserName(userB);
}
await TestFolder.cleanTestLocation(userA);
diff --git a/frontend/appflowy_flutter/integration_test/util/launch.dart b/frontend/appflowy_flutter/integration_test/util/common_operations.dart
similarity index 75%
rename from frontend/appflowy_flutter/integration_test/util/launch.dart
rename to frontend/appflowy_flutter/integration_test/util/common_operations.dart
index 39cb23fc4d..7114b2f285 100644
--- a/frontend/appflowy_flutter/integration_test/util/launch.dart
+++ b/frontend/appflowy_flutter/integration_test/util/common_operations.dart
@@ -7,6 +7,7 @@ import 'package:appflowy/user/presentation/skip_log_in_screen.dart';
import 'package:appflowy/workspace/presentation/home/home_stack.dart';
import 'package:appflowy/workspace/presentation/home/menu/app/header/add_button.dart';
import 'package:appflowy/workspace/presentation/home/menu/app/section/item.dart';
+import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -15,7 +16,7 @@ import 'base.dart';
const String readme = 'Read me';
-extension AppFlowyLaunch on WidgetTester {
+extension CommonOperations on WidgetTester {
Future<void> tapGoButton() async {
final goButton = find.byType(GoButton);
await tapButton(goButton);
@@ -27,7 +28,7 @@ extension AppFlowyLaunch on WidgetTester {
void expectToSeeWelcomePage() {
expect(find.byType(HomeStack), findsOneWidget);
- expect(find.textContaining('Read me'), findsNWidgets(2));
+ expect(find.textContaining('Read me'), findsOneWidget);
}
Future<void> tapAddButton() async {
@@ -122,4 +123,36 @@ extension AppFlowyLaunch on WidgetTester {
);
expect(exportSuccess, findsOneWidget);
}
+
+ Future<void> hoverOnCoverPluginAddButton() async {
+ final editor = find.byWidgetPredicate(
+ (widget) => widget is AppFlowyEditor,
+ );
+
+ final gesture = await createGesture(kind: PointerDeviceKind.mouse);
+ await gesture.addPointer(location: Offset.zero);
+ addTearDown(gesture.removePointer);
+ await pump();
+ final topLeft = getTopLeft(editor).translate(20, 20);
+ await gesture.moveTo(topLeft);
+ await pumpAndSettle();
+ }
+
+ Future<void> expectToSeePluginAddCoverAndIconButton() async {
+ final addCover = find.textContaining(
+ LocaleKeys.document_plugins_cover_addCover.tr(),
+ );
+ final addIcon = find.textContaining(
+ LocaleKeys.document_plugins_cover_addIcon.tr(),
+ );
+ expect(addCover, findsOneWidget);
+ expect(addIcon, findsOneWidget);
+ }
+
+ void expectToSeeUserName(String name) {
+ final userName = find.byWidgetPredicate(
+ (widget) => widget is FlowyText && widget.title == name,
+ );
+ expect(userName, findsOneWidget);
+ }
}
diff --git a/frontend/appflowy_flutter/integration_test/util/data.dart b/frontend/appflowy_flutter/integration_test/util/data.dart
index 6725f2958b..5532904aca 100644
--- a/frontend/appflowy_flutter/integration_test/util/data.dart
+++ b/frontend/appflowy_flutter/integration_test/util/data.dart
@@ -49,9 +49,11 @@ class TestWorkspaceService {
/// Instructs the application to read workspace data from the workspace found under this [TestWorkspace]'s path.
Future<void> setUpAll() async {
+ final root = await workspace.root;
+ final path = root.path;
SharedPreferences.setMockInitialValues(
{
- KVKeys.pathLocation: await workspace.root.then((value) => value.path),
+ KVKeys.pathLocation: path,
},
);
}
diff --git a/frontend/appflowy_flutter/integration_test/util/settings.dart b/frontend/appflowy_flutter/integration_test/util/settings.dart
index 4b01c2d791..4f350522cb 100644
--- a/frontend/appflowy_flutter/integration_test/util/settings.dart
+++ b/frontend/appflowy_flutter/integration_test/util/settings.dart
@@ -1,33 +1,13 @@
import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:appflowy/workspace/presentation/settings/settings_dialog.dart';
+import 'package:appflowy/workspace/presentation/settings/widgets/settings_menu_element.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/settings_user_view.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_test/flutter_test.dart';
import 'base.dart';
-enum SettingsPage {
- appearance,
- language,
- files,
- user,
-}
-
-extension on SettingsPage {
- String get name {
- switch (this) {
- case SettingsPage.appearance:
- return LocaleKeys.settings_menu_appearance.tr();
- case SettingsPage.language:
- return LocaleKeys.settings_menu_language.tr();
- case SettingsPage.files:
- return LocaleKeys.settings_menu_files.tr();
- case SettingsPage.user:
- return LocaleKeys.settings_menu_user.tr();
- }
- }
-}
-
extension AppFlowySettings on WidgetTester {
/// Open settings page
Future<void> openSettings() async {
@@ -41,7 +21,9 @@ extension AppFlowySettings on WidgetTester {
/// Open the page that insides the settings page
Future<void> openSettingsPage(SettingsPage page) async {
- final button = find.text(page.name, findRichText: true);
+ final button = find.byWidgetPredicate(
+ (widget) => widget is SettingsMenuElement && widget.page == page,
+ );
expect(button, findsOneWidget);
await tapButton(button);
return;
@@ -50,7 +32,7 @@ extension AppFlowySettings on WidgetTester {
/// Restore the AppFlowy data storage location
Future<void> restoreLocation() async {
final button =
- find.byTooltip(LocaleKeys.settings_files_restoreLocation.tr());
+ find.byTooltip(LocaleKeys.settings_files_recoverLocationTooltips.tr());
expect(button, findsOneWidget);
await tapButton(button);
return;
@@ -64,8 +46,9 @@ extension AppFlowySettings on WidgetTester {
}
Future<void> tapCustomLocationButton() async {
- final button =
- find.byTooltip(LocaleKeys.settings_files_customizeLocation.tr());
+ final button = find.byTooltip(
+ LocaleKeys.settings_files_changeLocationTooltips.tr(),
+ );
expect(button, findsOneWidget);
await tapButton(button);
return;
diff --git a/frontend/appflowy_flutter/integration_test/util/util.dart b/frontend/appflowy_flutter/integration_test/util/util.dart
index 20606483d3..e629589665 100644
--- a/frontend/appflowy_flutter/integration_test/util/util.dart
+++ b/frontend/appflowy_flutter/integration_test/util/util.dart
@@ -1,4 +1,4 @@
export 'base.dart';
-export 'launch.dart';
+export 'common_operations.dart';
export 'settings.dart';
export 'data.dart';
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart
index f0ba9122f4..df4c2c3663 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_customize_location_view.dart
@@ -70,8 +70,10 @@ class SettingsFileLocationCustomizerState
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
- _ChangeStoragePathButton(
- usingPath: path,
+ Flexible(
+ child: _ChangeStoragePathButton(
+ usingPath: path,
+ ),
),
const HSpace(10),
_OpenStorageButton(
diff --git a/frontend/scripts/makefile/tests.toml b/frontend/scripts/makefile/tests.toml
index ad246b3836..3f3e41a722 100644
--- a/frontend/scripts/makefile/tests.toml
+++ b/frontend/scripts/makefile/tests.toml
@@ -33,7 +33,7 @@ dependencies = ["inner_build_test_backend"]
description = "Run flutter unit tests"
script = '''
cd appflowy_flutter
-flutter test --dart-define=RUST_LOG=${RUST_LOG} -j, --concurrency=1
+flutter test --dart-define=RUST_LOG=${RUST_LOG} -j, --concurrency=1 --coverage --verbose
'''
[tasks.rust_unit_test]