repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/cloud
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/cloud/workspace/change_name_and_icon_test.dart
// ignore_for_file: unused_import import 'package:appflowy/env/cloud_env.dart'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/shared/feature_flags.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart'; import 'package:appflowy/user/application/auth/auth_service.dart'; import 'package:appflowy/workspace/application/settings/prelude.dart'; import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_icon.dart'; import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart'; import 'package:appflowy/workspace/presentation/settings/widgets/settings_user_view.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/uuid.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:path/path.dart' as p; import '../../shared/mock/mock_file_picker.dart'; import '../../shared/util.dart'; import '../../shared/workspace.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); const icon = '😄'; const name = 'AppFlowy'; final email = '${uuid()}@appflowy.io'; testWidgets('change name and icon', (tester) async { // only run the test when the feature flag is on if (!FeatureFlag.collaborativeWorkspace.isOn) { return; } await tester.initializeAppFlowy( cloudType: AuthenticatorType.appflowyCloudSelfHost, email: email, // use the same email to check the next test ); await tester.tapGoogleLoginInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); var workspaceIcon = tester.widget<WorkspaceIcon>( find.byType(WorkspaceIcon), ); expect(workspaceIcon.workspace.icon, ''); await tester.openWorkspaceMenu(); await tester.changeWorkspaceIcon(icon); await tester.changeWorkspaceName(name); workspaceIcon = tester.widget<WorkspaceIcon>( find.byType(WorkspaceIcon), ); expect(workspaceIcon.workspace.icon, icon); expect(find.findTextInFlowyText(name), findsOneWidget); }); testWidgets('verify the result again after relaunching', (tester) async { // only run the test when the feature flag is on if (!FeatureFlag.collaborativeWorkspace.isOn) { return; } await tester.initializeAppFlowy( cloudType: AuthenticatorType.appflowyCloudSelfHost, email: email, // use the same email to check the next test ); await tester.tapGoogleLoginInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); // check the result again final workspaceIcon = tester.widget<WorkspaceIcon>( find.byType(WorkspaceIcon), ); expect(workspaceIcon.workspace.icon, icon); expect(workspaceIcon.workspace.name, name); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/sidebar/sidebar_expand_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart'; import 'package:appflowy/workspace/presentation/home/menu/sidebar/sidebar_folder.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('sidebar expand test', () { bool isExpanded({required FolderCategoryType type}) { if (type == FolderCategoryType.private) { return find .descendant( of: find.byType(PrivateSectionFolder), matching: find.byType(ViewItem), ) .evaluate() .isNotEmpty; } return false; } testWidgets('first time the personal folder is expanded', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // first time is expanded expect(isExpanded(type: FolderCategoryType.private), true); // collapse the personal folder await tester.tapButton( find.byTooltip(LocaleKeys.sideBar_clickToHidePrivate.tr()), ); expect(isExpanded(type: FolderCategoryType.private), false); // expand the personal folder await tester.tapButton( find.byTooltip(LocaleKeys.sideBar_clickToHidePrivate.tr()), ); expect(isExpanded(type: FolderCategoryType.private), true); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/sidebar/rename_current_item_test.dart
import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; import 'package:appflowy/workspace/presentation/widgets/rename_view_popover.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flowy_infra_ui/style_widget/text_field.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/keyboard.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Rename current view item', () { testWidgets('by F2 shortcut', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await FlowyTestKeyboard.simulateKeyDownEvent( [LogicalKeyboardKey.f2], tester: tester, ); await tester.pumpAndSettle(); expect(find.byType(RenameViewPopover), findsOneWidget); await tester.enterText( find.descendant( of: find.byType(RenameViewPopover), matching: find.byType(FlowyTextField), ), 'hello', ); await tester.pumpAndSettle(); // Dismiss rename popover await tester.tap(find.byType(AppFlowyEditor)); await tester.pumpAndSettle(); expect( find.descendant( of: find.byType(SingleInnerViewItem), matching: find.text('hello'), ), findsOneWidget, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/sidebar/sidebar_icon_test.dart
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/base.dart'; import '../../shared/common_operations.dart'; import '../../shared/expectation.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); const emoji = '😁'; group('Icon', () { testWidgets('Update page icon in sidebar', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create document, board, grid and calendar views for (final value in ViewLayoutPB.values) { await tester.createNewPageWithNameUnderParent( name: value.name, parentName: gettingStarted, layout: value, ); // update its icon await tester.updatePageIconInSidebarByName( name: value.name, parentName: gettingStarted, layout: value, icon: emoji, ); tester.expectViewHasIcon( value.name, value, emoji, ); } }); testWidgets('Update page icon in title bar', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create document, board, grid and calendar views for (final value in ViewLayoutPB.values) { await tester.createNewPageWithNameUnderParent( name: value.name, parentName: gettingStarted, layout: value, ); // update its icon await tester.updatePageIconInTitleBarByName( name: value.name, layout: value, icon: emoji, ); tester.expectViewHasIcon( value.name, value, emoji, ); tester.expectViewTitleHasIcon( value.name, value, emoji, ); } }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/sidebar/sidebar_test_runner.dart
import 'package:integration_test/integration_test.dart'; import 'sidebar_favorites_test.dart' as sidebar_favorite_test; import 'sidebar_icon_test.dart' as sidebar_icon_test; import 'sidebar_test.dart' as sidebar_test; void startTesting() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // Sidebar integration tests sidebar_test.main(); // sidebar_expanded_test.main(); sidebar_favorite_test.main(); sidebar_icon_test.main(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/sidebar/sidebar_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/database/board/presentation/board_page.dart'; import 'package:appflowy/plugins/database/calendar/presentation/calendar_page.dart'; import 'package:appflowy/plugins/database/grid/presentation/grid_page.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/draggable_view_item.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_add_button.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_more_action_button.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('sidebar test', () { testWidgets('create a new page', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new page await tester.tapNewPageButton(); // expect to see a new document tester.expectToSeePageName( LocaleKeys.menuAppHeader_defaultNewPageName.tr(), ); // and with one paragraph block expect(find.byType(ParagraphBlockComponentWidget), findsOneWidget); }); testWidgets('create a new document, grid, board and calendar', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); for (final layout in ViewLayoutPB.values) { // create a new page final name = 'AppFlowy_$layout'; await tester.createNewPageWithNameUnderParent( name: name, layout: layout, ); // expect to see a new page tester.expectToSeePageName( name, layout: layout, ); switch (layout) { case ViewLayoutPB.Document: // and with one paragraph block expect(find.byType(ParagraphBlockComponentWidget), findsOneWidget); break; case ViewLayoutPB.Grid: expect(find.byType(GridPage), findsOneWidget); break; case ViewLayoutPB.Board: expect(find.byType(BoardPage), findsOneWidget); break; case ViewLayoutPB.Calendar: expect(find.byType(CalendarPage), findsOneWidget); break; } await tester.openPage(gettingStarted); } }); testWidgets('create some nested pages, and move them', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final names = [1, 2, 3, 4].map((e) => 'document_$e').toList(); for (var i = 0; i < names.length; i++) { final parentName = i == 0 ? gettingStarted : names[i - 1]; await tester.createNewPageWithNameUnderParent( name: names[i], parentName: parentName, ); tester.expectToSeePageName(names[i], parentName: parentName); } // move the document_3 to the getting started page await tester.movePageToOtherPage( name: names[3], parentName: gettingStarted, layout: ViewLayoutPB.Document, parentLayout: ViewLayoutPB.Document, ); final fromId = tester .widget<SingleInnerViewItem>(tester.findPageName(names[3])) .view .parentViewId; final toId = tester .widget<SingleInnerViewItem>(tester.findPageName(gettingStarted)) .view .id; expect(fromId, toId); // move the document_2 before document_1 await tester.movePageToOtherPage( name: names[2], parentName: gettingStarted, layout: ViewLayoutPB.Document, parentLayout: ViewLayoutPB.Document, position: DraggableHoverPosition.bottom, ); final childViews = tester .widget<SingleInnerViewItem>(tester.findPageName(gettingStarted)) .view .childViews; expect( childViews[0].id, tester .widget<SingleInnerViewItem>(tester.findPageName(names[2])) .view .id, ); expect( childViews[1].id, tester .widget<SingleInnerViewItem>(tester.findPageName(names[0])) .view .id, ); expect( childViews[2].id, tester .widget<SingleInnerViewItem>(tester.findPageName(names[3])) .view .id, ); }); testWidgets('unable to move a document into a database', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); const document = 'document'; await tester.createNewPageWithNameUnderParent( name: document, openAfterCreated: false, ); tester.expectToSeePageName(document); const grid = 'grid'; await tester.createNewPageWithNameUnderParent( name: grid, layout: ViewLayoutPB.Grid, openAfterCreated: false, ); tester.expectToSeePageName(grid, layout: ViewLayoutPB.Grid); // move the document to the grid page await tester.movePageToOtherPage( name: document, parentName: grid, layout: ViewLayoutPB.Document, parentLayout: ViewLayoutPB.Grid, ); // it should not be moved final childViews = tester .widget<SingleInnerViewItem>(tester.findPageName(gettingStarted)) .view .childViews; expect( childViews[0].name, document, ); expect( childViews[1].name, grid, ); }); testWidgets('unable to create a new database inside the existing one', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); const grid = 'grid'; await tester.createNewPageWithNameUnderParent( name: grid, layout: ViewLayoutPB.Grid, ); tester.expectToSeePageName(grid, layout: ViewLayoutPB.Grid); await tester.hoverOnPageName( grid, layout: ViewLayoutPB.Grid, onHover: () async { expect(find.byType(ViewAddButton), findsNothing); expect(find.byType(ViewMoreActionButton), findsOneWidget); }, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/sidebar/sidebar_favorites_test.dart
import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart'; import 'package:appflowy/workspace/presentation/home/menu/sidebar/folder/_favorite_folder.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; import 'package:appflowy_popover/appflowy_popover.dart'; import 'package:flowy_infra_ui/style_widget/hover.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/base.dart'; import '../../shared/common_operations.dart'; import '../../shared/expectation.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Favorites', () { testWidgets( 'Toggle favorites for views creates / removes the favorite header along with favorite views', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // no favorite folder expect(find.byType(FavoriteFolder), findsNothing); // create the nested views final names = [ 1, 2, ].map((e) => 'document_$e').toList(); for (var i = 0; i < names.length; i++) { final parentName = i == 0 ? gettingStarted : names[i - 1]; await tester.createNewPageWithNameUnderParent( name: names[i], parentName: parentName, ); tester.expectToSeePageName(names[i], parentName: parentName); } await tester.favoriteViewByName(gettingStarted); expect( tester.findFavoritePageName(gettingStarted), findsOneWidget, ); await tester.favoriteViewByName(names[1]); expect( tester.findFavoritePageName(names[1]), findsNWidgets(2), ); await tester.unfavoriteViewByName(gettingStarted); expect( tester.findFavoritePageName(gettingStarted), findsNothing, ); expect( tester.findFavoritePageName( names[1], ), findsOneWidget, ); await tester.unfavoriteViewByName(names[1]); expect( tester.findFavoritePageName( names[1], ), findsNothing, ); }); testWidgets( 'renaming a favorite view updates name under favorite header', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); const name = 'test'; await tester.favoriteViewByName(gettingStarted); await tester.hoverOnPageName( gettingStarted, onHover: () async { await tester.renamePage(name); await tester.pumpAndSettle(); }, ); expect( tester.findPageName(name), findsNWidgets(2), ); expect( tester.findFavoritePageName(name), findsOneWidget, ); }, ); testWidgets( 'deleting first level favorite view removes its instance from favorite header, deleting root level views leads to removal of all favorites that are its children', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final names = [1, 2].map((e) => 'document_$e').toList(); for (var i = 0; i < names.length; i++) { final parentName = i == 0 ? gettingStarted : names[i - 1]; await tester.createNewPageWithNameUnderParent( name: names[i], parentName: parentName, ); tester.expectToSeePageName(names[i], parentName: parentName); } await tester.favoriteViewByName(gettingStarted); await tester.favoriteViewByName(names[0]); await tester.favoriteViewByName(names[1]); expect( find.byWidgetPredicate( (widget) => widget is SingleInnerViewItem && widget.view.isFavorite && widget.categoryType == FolderCategoryType.favorite, ), findsNWidgets(6), ); await tester.hoverOnPageName( names[1], onHover: () async { await tester.tapDeletePageButton(); await tester.pumpAndSettle(); }, ); expect( tester.findAllFavoritePages(), findsNWidgets(3), ); await tester.hoverOnPageName( gettingStarted, onHover: () async { await tester.tapDeletePageButton(); await tester.pumpAndSettle(); }, ); expect( tester.findAllFavoritePages(), findsNothing, ); }, ); testWidgets( 'view selection is synced between favorites and personal folder', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(); await tester.favoriteViewByName(gettingStarted); expect( find.byWidgetPredicate( (widget) => widget is FlowyHover && widget.isSelected != null && widget.isSelected!(), ), findsNWidgets(2), ); }, ); testWidgets( 'context menu opens up for favorites', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(); await tester.favoriteViewByName(gettingStarted); await tester.hoverOnPageName( gettingStarted, useLast: false, onHover: () async { await tester.tapPageOptionButton(); await tester.pumpAndSettle(); expect( find.byType(PopoverContainer), findsOneWidget, ); }, ); await tester.pumpAndSettle(); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/share_markdown_test.dart
import 'dart:io'; import 'package:appflowy/plugins/document/presentation/share/share_button.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:path/path.dart' as p; import '../../shared/mock/mock_file_picker.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('share markdown in document page', () { testWidgets('click the share button in document page', (tester) async { final context = await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // mock the file picker final path = await mockSaveFilePath( p.join(context.applicationDataDirectory, 'test.md'), ); // click the share button and select markdown await tester.tapShareButton(); await tester.tapMarkdownButton(); // expect to see the success dialog tester.expectToExportSuccess(); final file = File(path); final isExist = file.existsSync(); expect(isExist, true); final markdown = file.readAsStringSync(); expect(markdown, expectedMarkdown); }); testWidgets( 'share the markdown after renaming the document name', (tester) async { final context = await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // expect to see a getting started page tester.expectToSeePageName(gettingStarted); // rename the document await tester.hoverOnPageName( gettingStarted, onHover: () async { await tester.renamePage('example'); }, ); final shareButton = find.byType(ShareActionList); final shareButtonState = tester.state(shareButton) as ShareActionListState; final path = await mockSaveFilePath( p.join( context.applicationDataDirectory, '${shareButtonState.name}.md', ), ); // click the share button and select markdown await tester.tapShareButton(); await tester.tapMarkdownButton(); // expect to see the success dialog tester.expectToExportSuccess(); final file = File(path); final isExist = file.existsSync(); expect(isExist, true); }, ); }); } const expectedMarkdown = ''' # Welcome to AppFlowy! ## Here are the basics - [ ] Click anywhere and just start typing. - [ ] Highlight any text, and use the editing menu to _style_ **your** <u>writing</u> `however` you ~~like.~~ - [ ] As soon as you type `/` a menu will pop up. Select different types of content blocks you can add. - [ ] Type `/` followed by `/bullet` or `/num` to create a list. - [x] Click `+ New Page `button at the bottom of your sidebar to add a new page. - [ ] Click `+` next to any page title in the sidebar to quickly add a new subpage, `Document`, `Grid`, or `Kanban Board`. --- ## Keyboard shortcuts, markdown, and code block 1. Keyboard shortcuts [guide](https://appflowy.gitbook.io/docs/essential-documentation/shortcuts) 1. Markdown [reference](https://appflowy.gitbook.io/docs/essential-documentation/markdown) 1. Type `/code` to insert a code block ```rust // This is the main function. fn main() { // Print text to the console. println!("Hello World!"); } ``` ## Have a question❓ > Click `?` at the bottom right for help and support. > 🥰 > > Like AppFlowy? Follow us: > [GitHub](https://github.com/AppFlowy-IO/AppFlowy) > [Twitter](https://twitter.com/appflowy): @appflowy > [Newsletter](https://blog-appflowy.ghost.io/) > ''';
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/hotkeys_test.dart
import 'dart:io'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/workspace/application/settings/prelude.dart'; import 'package:appflowy/workspace/presentation/home/menu/sidebar/sidebar.dart'; import 'package:appflowy/workspace/presentation/settings/settings_dialog.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/keyboard.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('hotkeys test', () { testWidgets('toggle theme mode', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); await tester.openSettings(); await tester.openSettingsPage(SettingsPage.appearance); await tester.pumpAndSettle(); tester.expectToSeeText( LocaleKeys.settings_appearance_themeMode_system.tr(), ); await tester.tapButton( find.bySemanticsLabel( LocaleKeys.settings_appearance_themeMode_system.tr(), ), ); await tester.pumpAndSettle(); await tester.tapButton( find.bySemanticsLabel( LocaleKeys.settings_appearance_themeMode_dark.tr(), ), ); await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.tap(find.byType(SettingsDialog)); await tester.pumpAndSettle(); await FlowyTestKeyboard.simulateKeyDownEvent( [ Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control, LogicalKeyboardKey.shift, LogicalKeyboardKey.keyL, ], tester: tester, ); await tester.pumpAndSettle(); tester.expectToSeeText( LocaleKeys.settings_appearance_themeMode_light.tr(), ); }); testWidgets('show or hide home menu', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); await tester.pumpAndSettle(); expect(find.byType(HomeSideBar), findsOneWidget); await FlowyTestKeyboard.simulateKeyDownEvent( [ Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control, LogicalKeyboardKey.backslash, ], tester: tester, ); await tester.pumpAndSettle(); expect(find.byType(HomeSideBar), findsNothing); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/import_files_test.dart
import 'dart:io'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:path/path.dart' as p; import '../../shared/mock/mock_file_picker.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('import files', () { testWidgets('import multiple markdown files', (tester) async { final context = await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // expect to see a getting started page tester.expectToSeePageName(gettingStarted); await tester.tapAddViewButton(); await tester.tapImportButton(); final testFileNames = ['test1.md', 'test2.md']; final paths = <String>[]; for (final fileName in testFileNames) { final str = await rootBundle.loadString( 'assets/test/workspaces/markdowns/$fileName', ); final path = p.join(context.applicationDataDirectory, fileName); paths.add(path); File(path).writeAsStringSync(str); } // mock get files mockPickFilePaths( paths: testFileNames .map((e) => p.join(context.applicationDataDirectory, e)) .toList(), ); await tester.tapTextAndMarkdownButton(); tester.expectToSeePageName('test1'); tester.expectToSeePageName('test2'); }); testWidgets('import markdown file with table', (tester) async { final context = await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // expect to see a getting started page tester.expectToSeePageName(gettingStarted); await tester.tapAddViewButton(); await tester.tapImportButton(); const testFileName = 'markdown_with_table.md'; final paths = <String>[]; final str = await rootBundle.loadString( 'assets/test/workspaces/markdowns/$testFileName', ); final path = p.join(context.applicationDataDirectory, testFileName); paths.add(path); File(path).writeAsStringSync(str); // mock get files mockPickFilePaths( paths: paths, ); await tester.tapTextAndMarkdownButton(); tester.expectToSeePageName('markdown_with_table'); // expect to see all content of markdown file along with table await tester.openPage('markdown_with_table'); final importedPageEditorState = tester.editor.getCurrentEditorState(); expect( importedPageEditorState.getNodeAtPath([0])!.type, HeadingBlockKeys.type, ); expect( importedPageEditorState.getNodeAtPath([2])!.type, HeadingBlockKeys.type, ); expect( importedPageEditorState.getNodeAtPath([4])!.type, TableBlockKeys.type, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/switch_folder_test.dart
import 'dart:io'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy/startup/tasks/prelude.dart'; import 'package:appflowy/workspace/application/settings/prelude.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('customize the folder path', () { if (Platform.isWindows) { return; } // testWidgets('switch to B from A, then switch to A again', (tester) async { // const userA = 'UserA'; // const userB = 'UserB'; // final initialPath = p.join(userA, appFlowyDataFolder); // final context = await tester.initializeAppFlowy( // pathExtension: initialPath, // ); // // remove the last extension // final rootPath = context.applicationDataDirectory.replaceFirst( // initialPath, // '', // ); // await tester.tapGoButton(); // await tester.expectToSeeHomePageWithGetStartedPage(); // // switch to user B // { // // set user name for userA // await tester.openSettings(); // await tester.openSettingsPage(SettingsPage.user); // await tester.enterUserName(userA); // await tester.openSettingsPage(SettingsPage.files); // await tester.pumpAndSettle(); // // mock the file_picker result // await mockGetDirectoryPath( // p.join(rootPath, userB), // ); // await tester.tapCustomLocationButton(); // await tester.pumpAndSettle(); // await tester.expectToSeeHomePageWithGetStartedPage(); // // set user name for 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(); // // mock the file_picker result // await mockGetDirectoryPath( // p.join(rootPath, userA), // ); // await tester.tapCustomLocationButton(); // await tester.pumpAndSettle(); // await tester.expectToSeeHomePageWithGetStartedPage(); // tester.expectToSeeUserName(userA); // } // // switch to the userB again // { // await tester.openSettings(); // await tester.openSettingsPage(SettingsPage.files); // await tester.pumpAndSettle(); // // mock the file_picker result // await mockGetDirectoryPath( // p.join(rootPath, userB), // ); // await tester.tapCustomLocationButton(); // await tester.pumpAndSettle(); // await tester.expectToSeeHomePageWithGetStartedPage(); // tester.expectToSeeUserName(userB); // } // }); testWidgets('reset to default location', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // home and readme document await tester.expectToSeeHomePageWithGetStartedPage(); // open settings and restore the location await tester.openSettings(); await tester.openSettingsPage(SettingsPage.files); await tester.restoreLocation(); expect( await appFlowyApplicationDataDirectory().then((value) => value.path), await getIt<ApplicationDataStorage>().getPath(), ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/language_test.dart
import 'package:appflowy/workspace/presentation/settings/widgets/settings_language_view.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('document', () { testWidgets( 'change the language successfully when launching the app for the first time', (tester) async { await tester.initializeAppFlowy(); await tester.tapLanguageSelectorOnWelcomePage(); expect(find.byType(LanguageItemsListView), findsOneWidget); await tester.tapLanguageItem(languageCode: 'zh', countryCode: 'CN'); tester.expectToSeeText('开始'); await tester.tapLanguageItem(languageCode: 'en', scrollDelta: -100); tester.expectToSeeText('Quick Start'); await tester.tapLanguageItem(languageCode: 'it', countryCode: 'IT'); tester.expectToSeeText('Andiamo'); }); /// Make sure this test is executed after the test above. testWidgets('check the language after relaunching the app', (tester) async { await tester.initializeAppFlowy(); tester.expectToSeeText('Andiamo'); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/board_test.dart
import 'package:appflowy_board/appflowy_board.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/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.board); group('board', () { setUpAll(() async => service.setUpAll()); setUp(() async => service.setUp()); testWidgets('open the board with data structure in v0.2.0', (tester) async { await tester.initializeAppFlowy(); expect(find.byType(AppFlowyBoard), findsOneWidget); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/tabs_test.dart
import 'dart:io'; import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart'; import 'package:appflowy/workspace/presentation/home/tabs/tabs_manager.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/base.dart'; import '../../shared/common_operations.dart'; import '../../shared/expectation.dart'; import '../../shared/keyboard.dart'; const _documentName = 'First Doc'; const _documentTwoName = 'Second Doc'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Tabs', () { testWidgets('Open AppFlowy and open/navigate/close tabs', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); expect( find.descendant( of: find.byType(TabsManager), matching: find.byType(TabBar), ), findsNothing, ); await tester.createNewPageWithNameUnderParent(name: _documentName); await tester.createNewPageWithNameUnderParent(name: _documentTwoName); /// Open second menu item in a new tab await tester.openAppInNewTab(gettingStarted, ViewLayoutPB.Document); /// Open third menu item in a new tab await tester.openAppInNewTab(_documentName, ViewLayoutPB.Document); expect( find.descendant( of: find.byType(TabBar), matching: find.byType(FlowyTab), ), findsNWidgets(3), ); /// Navigate to the second tab await tester.tap( find.descendant( of: find.byType(FlowyTab), matching: find.text(gettingStarted), ), ); /// Close tab by shortcut await FlowyTestKeyboard.simulateKeyDownEvent( [ Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control, LogicalKeyboardKey.keyW, ], tester: tester, ); expect( find.descendant( of: find.byType(TabBar), matching: find.byType(FlowyTab), ), findsNWidgets(2), ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/emoji_shortcut_test.dart
import 'dart:io'; import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_picker.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/src/editor/editor_component/service/editor.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/keyboard.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // May be better to move this to an existing test but unsure what it fits with group('Keyboard shortcuts related to emojis', () { testWidgets('cmd/ctrl+alt+e shortcut opens the emoji picker', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final Finder editor = find.byType(AppFlowyEditor); await tester.tap(editor); await tester.pumpAndSettle(); expect(find.byType(EmojiSelectionMenu), findsNothing); await FlowyTestKeyboard.simulateKeyDownEvent( [ Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control, LogicalKeyboardKey.alt, LogicalKeyboardKey.keyE, ], tester: tester, ); expect(find.byType(EmojiSelectionMenu), findsOneWidget); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/open_ai_smart_menu_test.dart
import 'package:appflowy/plugins/document/presentation/editor_plugins/openai/service/openai_client.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/src/render/toolbar/toolbar_widget.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/mock/mock_openai_repository.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); const service = TestWorkspaceService(TestWorkspace.aiWorkSpace); group('integration tests for open-ai smart menu', () { setUpAll(() async => service.setUpAll()); setUp(() async => service.setUp()); testWidgets('testing selection on open-ai smart menu replace', (tester) async { final appFlowyEditor = await setUpOpenAITesting(tester); final editorState = appFlowyEditor.editorState; editorState.service.selectionService.updateSelection( Selection( start: Position(path: [1], offset: 4), end: Position(path: [1], offset: 10), ), ); await tester.pumpAndSettle(const Duration(milliseconds: 500)); await tester.pumpAndSettle(); expect(find.byType(ToolbarWidget), findsAtLeastNWidgets(1)); await tester.tap(find.byTooltip('AI Assistants')); await tester.pumpAndSettle(const Duration(milliseconds: 500)); await tester.tap(find.text('Summarize')); await tester.pumpAndSettle(); await tester .tap(find.byType(FlowyRichTextButton, skipOffstage: false).first); await tester.pumpAndSettle(); expect( editorState.service.selectionService.currentSelection.value, Selection( start: Position(path: [1], offset: 4), end: Position(path: [1], offset: 84), ), ); }); testWidgets('testing selection on open-ai smart menu insert', (tester) async { final appFlowyEditor = await setUpOpenAITesting(tester); final editorState = appFlowyEditor.editorState; editorState.service.selectionService.updateSelection( Selection( start: Position(path: [1]), end: Position(path: [1], offset: 5), ), ); await tester.pumpAndSettle(const Duration(milliseconds: 500)); await tester.pumpAndSettle(); expect(find.byType(ToolbarWidget), findsAtLeastNWidgets(1)); await tester.tap(find.byTooltip('AI Assistants')); await tester.pumpAndSettle(const Duration(milliseconds: 500)); await tester.tap(find.text('Summarize')); await tester.pumpAndSettle(); await tester .tap(find.byType(FlowyRichTextButton, skipOffstage: false).at(1)); await tester.pumpAndSettle(); expect( editorState.service.selectionService.currentSelection.value, Selection( start: Position(path: [2]), end: Position(path: [3]), ), ); }); }); } Future<AppFlowyEditor> setUpOpenAITesting(WidgetTester tester) async { await tester.initializeAppFlowy(); await mockOpenAIRepository(); await simulateKeyDownEvent(LogicalKeyboardKey.controlLeft); await simulateKeyDownEvent(LogicalKeyboardKey.backslash); await tester.pumpAndSettle(); final Finder editor = find.byType(AppFlowyEditor); await tester.tap(editor); await tester.pumpAndSettle(); return tester.state(editor).widget as AppFlowyEditor; } Future<void> mockOpenAIRepository() async { await getIt.unregister<OpenAIRepository>(); getIt.registerFactoryAsync<OpenAIRepository>( () => Future.value( MockOpenAIRepository(), ), ); return; }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/empty_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; // This test is meaningless, just for preventing the CI from failing. void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Empty', () { testWidgets('toggle theme mode', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/appearance_settings_test.dart
import 'package:appflowy/workspace/application/appearance_defaults.dart'; import 'package:appflowy/workspace/application/settings/prelude.dart'; import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance/settings_appearance.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('appearance settings tests', () { testWidgets('after editing text field, button should be able to be clicked', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); await tester.openSettings(); await tester.openSettingsPage(SettingsPage.appearance); final dropDown = find.byKey(ThemeFontFamilySetting.popoverKey); await tester.tap(dropDown); await tester.pumpAndSettle(); final textField = find.byKey(ThemeFontFamilySetting.textFieldKey); await tester.tap(textField); await tester.pumpAndSettle(); await tester.enterText(textField, 'Abel'); await tester.pumpAndSettle(); final fontFamilyButton = find.byKey(const Key('Abel')); expect(fontFamilyButton, findsOneWidget); await tester.tap(fontFamilyButton); await tester.pumpAndSettle(); // just switch the page and verify that the font family was set after that await tester.openSettingsPage(SettingsPage.files); await tester.openSettingsPage(SettingsPage.appearance); expect(find.textContaining('Abel'), findsOneWidget); }); testWidgets('reset the font family', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); await tester.openSettings(); await tester.openSettingsPage(SettingsPage.appearance); final dropDown = find.byKey(ThemeFontFamilySetting.popoverKey); await tester.tap(dropDown); await tester.pumpAndSettle(); final textField = find.byKey(ThemeFontFamilySetting.textFieldKey); await tester.tap(textField); await tester.pumpAndSettle(); await tester.enterText(textField, 'Abel'); await tester.pumpAndSettle(); final fontFamilyButton = find.byKey(const Key('Abel')); expect(fontFamilyButton, findsOneWidget); await tester.tap(fontFamilyButton); await tester.pumpAndSettle(); // just switch the page and verify that the font family was set after that await tester.openSettingsPage(SettingsPage.files); await tester.openSettingsPage(SettingsPage.appearance); final resetButton = find.byKey(ThemeFontFamilySetting.resetButtonkey); await tester.tap(resetButton); await tester.pumpAndSettle(); // just switch the page and verify that the font family was set after that await tester.openSettingsPage(SettingsPage.files); await tester.openSettingsPage(SettingsPage.appearance); expect( find.textContaining(DefaultAppearanceSettings.kDefaultFontFamily), findsOneWidget, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/uncategorized/empty_document_test.dart
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/built_in_page_widget.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/keyboard.dart'; import '../../shared/util.dart'; /// Integration tests for an empty document. The [TestWorkspaceService] will load a workspace from an empty document `assets/test/workspaces/empty_document.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.emptyDocument); group('Tests on a workspace with only an empty document', () { setUpAll(() async => service.setUpAll()); setUp(() async => service.setUp()); testWidgets('/board shortcut creates a new board and view of the board', (tester) async { await tester.initializeAppFlowy(); // Needs tab to obtain focus for the app flowy editor. // by default the tap appears at the center of the widget. final Finder editor = find.byType(AppFlowyEditor); await tester.tap(editor); await tester.pumpAndSettle(); // tester.sendText() cannot be used since the editor // does not contain any EditableText widgets. // to interact with the app during an integration test, // simulate physical keyboard events. await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.slash, LogicalKeyboardKey.keyB, LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyA, LogicalKeyboardKey.keyR, LogicalKeyboardKey.keyD, LogicalKeyboardKey.arrowDown, ], tester: tester, ); // Checks whether the options in the selection menu // for /board exist. expect(find.byType(SelectionMenuItemWidget), findsAtLeastNWidgets(2)); // Finalizes the slash command that creates the board. await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.enter, ], tester: tester, ); // Checks whether new board is referenced and properly on the page. expect(find.byType(BuiltInPageWidget), findsOneWidget); // Checks whether the new database was created const newBoardLabel = "Untitled"; expect(find.text(newBoardLabel), findsOneWidget); // Checks whether a view of the database was created const viewOfBoardLabel = "View of Untitled"; expect(find.text(viewOfBoardLabel), findsNWidgets(2)); }); testWidgets('/grid shortcut creates a new grid and view of the grid', (tester) async { await tester.initializeAppFlowy(); // Needs tab to obtain focus for the app flowy editor. // by default the tap appears at the center of the widget. final Finder editor = find.byType(AppFlowyEditor); await tester.tap(editor); await tester.pumpAndSettle(); // tester.sendText() cannot be used since the editor // does not contain any EditableText widgets. // to interact with the app during an integration test, // simulate physical keyboard events. await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.slash, LogicalKeyboardKey.keyG, LogicalKeyboardKey.keyR, LogicalKeyboardKey.keyI, LogicalKeyboardKey.keyD, LogicalKeyboardKey.arrowDown, ], tester: tester, ); // Checks whether the options in the selection menu // for /grid exist. expect(find.byType(SelectionMenuItemWidget), findsAtLeastNWidgets(2)); // Finalizes the slash command that creates the board. await simulateKeyDownEvent(LogicalKeyboardKey.enter); await tester.pumpAndSettle(); // Checks whether new board is referenced and properly on the page. expect(find.byType(BuiltInPageWidget), findsOneWidget); // Checks whether the new database was created const newTableLabel = "Untitled"; expect(find.text(newTableLabel), findsOneWidget); // Checks whether a view of the database was created const viewOfTableLabel = "View of Untitled"; expect(find.text(viewOfTableLabel), findsNWidgets(2)); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_filter_test.dart
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/checkbox.dart'; import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/text.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('grid filter:', () { testWidgets('add text filter', (tester) async { await tester.openV020database(); // create a filter await tester.tapDatabaseFilterButton(); await tester.tapCreateFilterByFieldType(FieldType.RichText, 'Name'); await tester.tapFilterButtonInGrid('Name'); // enter 'A' in the filter text field await tester.assertNumberOfRowsInGridPage(10); await tester.enterTextInTextFilter('A'); await tester.assertNumberOfRowsInGridPage(1); // after remove the filter, the grid should show all rows await tester.enterTextInTextFilter(''); await tester.assertNumberOfRowsInGridPage(10); await tester.enterTextInTextFilter('B'); await tester.assertNumberOfRowsInGridPage(1); // open the menu to delete the filter await tester.tapDisclosureButtonInFinder(find.byType(TextFilterEditor)); await tester.tapDeleteFilterButtonInGrid(); await tester.assertNumberOfRowsInGridPage(10); await tester.pumpAndSettle(); }); testWidgets('add checkbox filter', (tester) async { await tester.openV020database(); // create a filter await tester.tapDatabaseFilterButton(); await tester.tapCreateFilterByFieldType(FieldType.Checkbox, 'Done'); await tester.assertNumberOfRowsInGridPage(5); await tester.tapFilterButtonInGrid('Done'); await tester.tapCheckboxFilterButtonInGrid(); await tester.tapUnCheckedButtonOnCheckboxFilter(); await tester.assertNumberOfRowsInGridPage(5); await tester .tapDisclosureButtonInFinder(find.byType(CheckboxFilterEditor)); await tester.tapDeleteFilterButtonInGrid(); await tester.assertNumberOfRowsInGridPage(10); await tester.pumpAndSettle(); }); testWidgets('add checklist filter', (tester) async { await tester.openV020database(); // create a filter await tester.tapDatabaseFilterButton(); await tester.tapCreateFilterByFieldType(FieldType.Checklist, 'checklist'); // By default, the condition of checklist filter is 'uncompleted' await tester.assertNumberOfRowsInGridPage(9); await tester.tapFilterButtonInGrid('checklist'); await tester.tapChecklistFilterButtonInGrid(); await tester.tapCompletedButtonOnChecklistFilter(); await tester.assertNumberOfRowsInGridPage(1); await tester.pumpAndSettle(); }); testWidgets('add single select filter', (tester) async { await tester.openV020database(); // create a filter await tester.tapDatabaseFilterButton(); await tester.tapCreateFilterByFieldType(FieldType.SingleSelect, 'Type'); await tester.tapFilterButtonInGrid('Type'); // select the option 's6' await tester.tapOptionFilterWithName('s6'); await tester.assertNumberOfRowsInGridPage(0); // unselect the option 's6' await tester.tapOptionFilterWithName('s6'); await tester.assertNumberOfRowsInGridPage(10); // select the option 's5' await tester.tapOptionFilterWithName('s5'); await tester.assertNumberOfRowsInGridPage(1); // select the option 's4' await tester.tapOptionFilterWithName('s4'); // The row with 's4' should be shown. await tester.assertNumberOfRowsInGridPage(1); await tester.pumpAndSettle(); }); testWidgets('add multi select filter', (tester) async { await tester.openV020database(); // create a filter await tester.tapDatabaseFilterButton(); await tester.tapCreateFilterByFieldType( FieldType.MultiSelect, 'multi-select', ); await tester.tapFilterButtonInGrid('multi-select'); await tester.scrollOptionFilterListByOffset(const Offset(0, -200)); // select the option 'm1'. Any option with 'm1' should be shown. await tester.tapOptionFilterWithName('m1'); await tester.assertNumberOfRowsInGridPage(5); await tester.tapOptionFilterWithName('m1'); // select the option 'm2'. Any option with 'm2' should be shown. await tester.tapOptionFilterWithName('m2'); await tester.assertNumberOfRowsInGridPage(4); await tester.tapOptionFilterWithName('m2'); // select the option 'm4'. Any option with 'm4' should be shown. await tester.tapOptionFilterWithName('m4'); await tester.assertNumberOfRowsInGridPage(1); await tester.pumpAndSettle(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_row_test.dart
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('grid', () { testWidgets('create row of the grid', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.tapCreateRowButtonInGrid(); // 3 initial rows + 1 created await tester.assertNumberOfRowsInGridPage(4); await tester.pumpAndSettle(); }); testWidgets('create row from row menu of the grid', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.hoverOnFirstRowOfGrid(); await tester.tapCreateRowButtonInRowMenuOfGrid(); // 3 initial rows + 1 created await tester.assertNumberOfRowsInGridPage(4); await tester.pumpAndSettle(); }); testWidgets('delete row of the grid', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.hoverOnFirstRowOfGrid(); // Open the row menu and then click the delete await tester.tapRowMenuButtonInGrid(); await tester.tapDeleteOnRowMenu(); // 3 initial rows - 1 deleted await tester.assertNumberOfRowsInGridPage(2); await tester.pumpAndSettle(); }); testWidgets('check number of row indicator in the initial grid', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.pumpAndSettle(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart
import 'package:flutter/material.dart'; import 'package:appflowy/plugins/database/widgets/row/row_banner.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/emoji.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('grid row detail page:', () { testWidgets('opens', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); // Make sure that the row page is opened tester.assertRowDetailPageOpened(); // Each row detail page should have a document await tester.assertDocumentExistInRowDetailPage(); }); testWidgets('add emoji', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); await tester.hoverRowBanner(); await tester.openEmojiPicker(); await tester.tapEmoji('😀'); // After select the emoji, the EmojiButton will show up await tester.tapButton(find.byType(EmojiButton)); }); testWidgets('update emoji', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); await tester.hoverRowBanner(); await tester.openEmojiPicker(); await tester.tapEmoji('😀'); // Update existing selected emoji await tester.tapButton(find.byType(EmojiButton)); await tester.tapEmoji('😅'); // The emoji already displayed in the row banner final emojiText = find.byWidgetPredicate( (widget) => widget is FlowyText && widget.text == '😅', ); // The number of emoji should be two. One in the row displayed in the grid // one in the row detail page. expect(emojiText, findsNWidgets(2)); }); testWidgets('remove emoji', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); await tester.hoverRowBanner(); await tester.openEmojiPicker(); await tester.tapEmoji('😀'); // Remove the emoji await tester.tapButton(find.byType(RemoveEmojiButton)); final emojiText = find.byWidgetPredicate( (widget) => widget is FlowyText && widget.text == '😀', ); expect(emojiText, findsNothing); }); testWidgets('create list of fields', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); for (final fieldType in [ FieldType.Checklist, FieldType.DateTime, FieldType.Number, FieldType.URL, FieldType.MultiSelect, FieldType.LastEditedTime, FieldType.CreatedTime, FieldType.Checkbox, ]) { await tester.tapRowDetailPageCreatePropertyButton(); await tester.renameField(fieldType.name); // Open the type option menu await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(fieldType); // After update the field type, the cells should be updated await tester.findCellByFieldType(fieldType); await tester.scrollRowDetailByOffset(const Offset(0, -50)); } }); testWidgets('change order of fields and cells', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); // Assert that the first field in the row details page is the select // option type tester.assertFirstFieldInRowDetailByType(FieldType.SingleSelect); // Reorder first field in list final gesture = await tester.hoverOnFieldInRowDetail(index: 0); await tester.pumpAndSettle(); await tester.reorderFieldInRowDetail(offset: 30); // Orders changed, now the checkbox is first tester.assertFirstFieldInRowDetailByType(FieldType.Checkbox); await gesture.removePointer(); await tester.pumpAndSettle(); // Reorder second field in list await tester.hoverOnFieldInRowDetail(index: 1); await tester.pumpAndSettle(); await tester.reorderFieldInRowDetail(offset: -30); // First field is now back to select option tester.assertFirstFieldInRowDetailByType(FieldType.SingleSelect); }); testWidgets('hide and show hidden fields', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); // Assert that the show hidden fields button isn't visible tester.assertToggleShowHiddenFieldsVisibility(false); // Hide the first field in the field list await tester.tapGridFieldWithNameInRowDetailPage("Type"); await tester.tapHidePropertyButtonInFieldEditor(); // Assert that the field is now hidden tester.noFieldWithName("Type"); // Assert that the show hidden fields button appears tester.assertToggleShowHiddenFieldsVisibility(true); // Click on the show hidden fields button await tester.toggleShowHiddenFields(); // Assert that the hidden field is shown again and that the show // hidden fields button is still present tester.findFieldWithName("Type"); tester.assertToggleShowHiddenFieldsVisibility(true); // Click hide hidden fields await tester.toggleShowHiddenFields(); // Assert that the hidden field has vanished tester.noFieldWithName("Type"); // Click show hidden fields await tester.toggleShowHiddenFields(); // delete the hidden field await tester.tapGridFieldWithNameInRowDetailPage("Type"); await tester.tapDeletePropertyInFieldEditor(); // Assert that the that the show hidden fields button is gone tester.assertToggleShowHiddenFieldsVisibility(false); }); testWidgets('update the contents of the document and re-open it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); // Wait for the document to be loaded await tester.wait(500); // Focus on the editor final textBlock = find.byType(ParagraphBlockComponentWidget); await tester.tapAt(tester.getCenter(textBlock)); await tester.pumpAndSettle(); // Input some text const inputText = 'Hello World'; await tester.ime.insertText(inputText); expect( find.textContaining(inputText, findRichText: true), findsOneWidget, ); // Tap outside to dismiss the field await tester.tapAt(Offset.zero); await tester.pumpAndSettle(); // Re-open the document await tester.openFirstRowDetailPage(); expect( find.textContaining(inputText, findRichText: true), findsOneWidget, ); }); testWidgets( 'check if the title wraps properly when a long text is inserted', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); // Wait for the document to be loaded await tester.wait(500); // Focus on the editor final textField = find .descendant( of: find.byType(SimpleDialog), matching: find.byType(TextField), ) .first; // Input a long text await tester.enterText(textField, 'Long text' * 25); await tester.pumpAndSettle(); // Tap outside to dismiss the field await tester.tapAt(Offset.zero); await tester.pumpAndSettle(); // Check if there is any overflow in the widget tree expect(tester.takeException(), isNull); // Re-open the document await tester.openFirstRowDetailPage(); // Check again if there is any overflow in the widget tree expect(tester.takeException(), isNull); }); testWidgets('delete row', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); await tester.tapRowDetailPageRowActionButton(); await tester.tapRowDetailPageDeleteRowButton(); await tester.tapEscButton(); await tester.assertNumberOfRowsInGridPage(2); }); testWidgets('duplicate row', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Hover first row and then open the row page await tester.openFirstRowDetailPage(); await tester.tapRowDetailPageRowActionButton(); await tester.tapRowDetailPageDuplicateRowButton(); await tester.tapEscButton(); await tester.assertNumberOfRowsInGridPage(4); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_setting_test.dart
import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('grid', () { testWidgets('update layout', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // open setting await tester.tapDatabaseSettingButton(); // select the layout await tester.tapDatabaseLayoutButton(); // select layout by board await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Board); await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Board); await tester.pumpAndSettle(); }); testWidgets('update layout multiple times', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // open setting await tester.tapDatabaseSettingButton(); await tester.tapDatabaseLayoutButton(); await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Board); await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Board); await tester.tapDatabaseSettingButton(); await tester.tapDatabaseLayoutButton(); await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Calendar); await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Calendar); await tester.pumpAndSettle(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_field_test.dart
import 'package:appflowy/plugins/database/grid/presentation/grid_page.dart'; import 'package:appflowy/plugins/database/widgets/field/type_option_editor/select/select_option.dart'; import 'package:appflowy/util/field_type_extension.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:intl/intl.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('grid field editor:', () { testWidgets('rename existing field', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Invoke the field editor await tester.tapGridFieldWithName('Name'); await tester.tapEditFieldButton(); await tester.renameField('hello world'); await tester.dismissFieldEditor(); await tester.tapGridFieldWithName('hello world'); await tester.pumpAndSettle(); }); testWidgets('update field type of existing field', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Invoke the field editor await tester.changeFieldTypeOfFieldWithName('Type', FieldType.Checkbox); await tester.assertFieldTypeWithFieldName( 'Type', FieldType.Checkbox, ); await tester.pumpAndSettle(); }); testWidgets('create a field and rename it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new grid await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // create a field await tester.createField(FieldType.Checklist, 'checklist'); // check the field is created successfully tester.findFieldWithName('checklist'); await tester.pumpAndSettle(); }); testWidgets('delete field', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // create a field await tester.createField(FieldType.Checkbox, 'New field 1'); // Delete the field await tester.tapGridFieldWithName('New field 1'); await tester.tapDeletePropertyButton(); // confirm delete await tester.tapDialogOkButton(); tester.noFieldWithName('New field 1'); await tester.pumpAndSettle(); }); testWidgets('duplicate field', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // create a field await tester.scrollToRight(find.byType(GridPage)); await tester.tapNewPropertyButton(); await tester.renameField('New field 1'); await tester.dismissFieldEditor(); // duplicate the field await tester.tapGridFieldWithName('New field 1'); await tester.tapDuplicatePropertyButton(); tester.findFieldWithName('New field 1 (copy)'); await tester.pumpAndSettle(); }); testWidgets('insert field on either side of a field', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.scrollToRight(find.byType(GridPage)); // insert new field to the right await tester.tapGridFieldWithName('Type'); await tester.tapInsertFieldButton(left: false, name: 'Right'); await tester.dismissFieldEditor(); tester.findFieldWithName('Right'); // insert new field to the right await tester.tapGridFieldWithName('Type'); await tester.tapInsertFieldButton(left: true, name: "Left"); await tester.dismissFieldEditor(); tester.findFieldWithName('Left'); await tester.pumpAndSettle(); }); testWidgets('create checklist field', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.scrollToRight(find.byType(GridPage)); await tester.tapNewPropertyButton(); // Open the type option menu await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(FieldType.Checklist); // After update the field type, the cells should be updated await tester.findCellByFieldType(FieldType.Checklist); await tester.pumpAndSettle(); }); testWidgets('create list of fields', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); for (final fieldType in [ FieldType.Checklist, FieldType.DateTime, FieldType.Number, FieldType.URL, FieldType.MultiSelect, FieldType.LastEditedTime, FieldType.CreatedTime, FieldType.Checkbox, ]) { await tester.scrollToRight(find.byType(GridPage)); await tester.tapNewPropertyButton(); await tester.renameField(fieldType.name); // Open the type option menu await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(fieldType); await tester.dismissFieldEditor(); // After update the field type, the cells should be updated await tester.findCellByFieldType(fieldType); await tester.pumpAndSettle(); } }); testWidgets('field types with empty type option editor', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); for (final fieldType in [ FieldType.RichText, FieldType.Checkbox, FieldType.Checklist, FieldType.URL, ]) { // create the field await tester.scrollToRight(find.byType(GridPage)); await tester.tapNewPropertyButton(); await tester.renameField(fieldType.i18n); // change field type await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(fieldType); await tester.dismissFieldEditor(); // open the field editor await tester.tapGridFieldWithName(fieldType.i18n); await tester.tapEditFieldButton(); // check type option editor is empty tester.expectEmptyTypeOptionEditor(); await tester.dismissFieldEditor(); } }); testWidgets('number field type option', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.scrollToRight(find.byType(GridPage)); // create a number field await tester.tapNewPropertyButton(); await tester.renameField("Number"); await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(FieldType.Number); await tester.dismissFieldEditor(); // enter some data into the first number cell await tester.editCell( rowIndex: 0, fieldType: FieldType.Number, input: '123', ); // edit the next cell to force the previous cell at row 0 to lose focus await tester.editCell( rowIndex: 1, fieldType: FieldType.Number, input: '0.2', ); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.Number, content: '123', ); // open editor and change number format await tester.tapGridFieldWithName('Number'); await tester.tapEditFieldButton(); await tester.changeNumberFieldFormat(); await tester.dismissFieldEditor(); // assert number format has been changed tester.assertCellContent( rowIndex: 0, fieldType: FieldType.Number, content: '\$123', ); }); testWidgets('add option', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( layout: ViewLayoutPB.Grid, ); // invoke the field editor await tester.tapGridFieldWithName('Type'); await tester.tapEditFieldButton(); // tap 'add option' button await tester.tapAddSelectOptionButton(); const text = 'Hello AppFlowy'; final inputField = find.descendant( of: find.byType(CreateOptionTextField), matching: find.byType(TextField), ); await tester.enterText(inputField, text); await tester.pumpAndSettle(); await tester.testTextInput.receiveAction(TextInputAction.done); await tester.pumpAndSettle(const Duration(milliseconds: 500)); // check the result tester.expectToSeeText(text); }); testWidgets('date time field type options', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.scrollToRight(find.byType(GridPage)); // create a date field await tester.tapNewPropertyButton(); await tester.renameField(FieldType.DateTime.i18n); await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(FieldType.DateTime); await tester.dismissFieldEditor(); // edit the first date cell await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.toggleIncludeTime(); final now = DateTime.now(); await tester.selectDay(content: now.day); await tester.dismissCellEditor(); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: DateFormat('MMM dd, y HH:mm').format(now), ); // open editor and change date & time format await tester.tapGridFieldWithName(FieldType.DateTime.i18n); await tester.tapEditFieldButton(); await tester.changeDateFormat(); await tester.changeTimeFormat(); await tester.dismissFieldEditor(); // assert date format has been changed tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: DateFormat('dd/MM/y hh:mm a').format(now), ); }); // Disable this test because it fails on CI randomly // testWidgets('last modified and created at field type options', // (tester) async { // await tester.initializeAppFlowy(); // await tester.tapGoButton(); // await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // final created = DateTime.now(); // // create a created at field // await tester.tapNewPropertyButton(); // await tester.renameField(FieldType.CreatedTime.i18n); // await tester.tapSwitchFieldTypeButton(); // await tester.selectFieldType(FieldType.CreatedTime); // await tester.dismissFieldEditor(); // // create a last modified field // await tester.tapNewPropertyButton(); // await tester.renameField(FieldType.LastEditedTime.i18n); // await tester.tapSwitchFieldTypeButton(); // // get time just before modifying // final modified = DateTime.now(); // // create a last modified field (cont'd) // await tester.selectFieldType(FieldType.LastEditedTime); // await tester.dismissFieldEditor(); // tester.assertCellContent( // rowIndex: 0, // fieldType: FieldType.CreatedTime, // content: DateFormat('MMM dd, y HH:mm').format(created), // ); // tester.assertCellContent( // rowIndex: 0, // fieldType: FieldType.LastEditedTime, // content: DateFormat('MMM dd, y HH:mm').format(modified), // ); // // open field editor and change date & time format // await tester.tapGridFieldWithName(FieldType.LastEditedTime.i18n); // await tester.tapEditFieldButton(); // await tester.changeDateFormat(); // await tester.changeTimeFormat(); // await tester.dismissFieldEditor(); // // open field editor and change date & time format // await tester.tapGridFieldWithName(FieldType.CreatedTime.i18n); // await tester.tapEditFieldButton(); // await tester.changeDateFormat(); // await tester.changeTimeFormat(); // await tester.dismissFieldEditor(); // // assert format has been changed // tester.assertCellContent( // rowIndex: 0, // fieldType: FieldType.CreatedTime, // content: DateFormat('dd/MM/y hh:mm a').format(created), // ); // tester.assertCellContent( // rowIndex: 0, // fieldType: FieldType.LastEditedTime, // content: DateFormat('dd/MM/y hh:mm a').format(modified), // ); // }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_cell_test.dart
import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:intl/intl.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('edit grid cell:', () { testWidgets('text', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.editCell( rowIndex: 0, fieldType: FieldType.RichText, input: 'hello world', ); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.RichText, content: 'hello world', ); await tester.pumpAndSettle(); }); // Make sure the text cells are filled with the right content when there are // multiple text cell testWidgets('multiple text cells', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( name: 'my grid', layout: ViewLayoutPB.Grid, ); await tester.createField(FieldType.RichText, 'description'); await tester.editCell( rowIndex: 0, fieldType: FieldType.RichText, input: 'hello', ); await tester.editCell( rowIndex: 0, fieldType: FieldType.RichText, input: 'world', cellIndex: 1, ); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.RichText, content: 'hello', ); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.RichText, content: 'world', cellIndex: 1, ); await tester.pumpAndSettle(); }); testWidgets('number', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); const fieldType = FieldType.Number; // Create a number field await tester.createField(fieldType, fieldType.name); await tester.editCell( rowIndex: 0, fieldType: fieldType, input: '-1', ); // edit the next cell to force the previous cell at row 0 to lose focus await tester.editCell( rowIndex: 1, fieldType: fieldType, input: '0.2', ); // -1 -> -1 tester.assertCellContent( rowIndex: 0, fieldType: fieldType, content: '-1', ); // edit the next cell to force the previous cell at row 1 to lose focus await tester.editCell( rowIndex: 2, fieldType: fieldType, input: '.1', ); // 0.2 -> 0.2 tester.assertCellContent( rowIndex: 1, fieldType: fieldType, content: '0.2', ); // edit the next cell to force the previous cell at row 2 to lose focus await tester.editCell( rowIndex: 0, fieldType: fieldType, input: '', ); // .1 -> 0.1 tester.assertCellContent( rowIndex: 2, fieldType: fieldType, content: '0.1', ); await tester.pumpAndSettle(); }); testWidgets('checkbox', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.assertCheckboxCell(rowIndex: 0, isSelected: false); await tester.tapCheckboxCellInGrid(rowIndex: 0); await tester.assertCheckboxCell(rowIndex: 0, isSelected: true); await tester.tapCheckboxCellInGrid(rowIndex: 1); await tester.tapCheckboxCellInGrid(rowIndex: 2); await tester.assertCheckboxCell(rowIndex: 1, isSelected: true); await tester.assertCheckboxCell(rowIndex: 2, isSelected: true); await tester.pumpAndSettle(); }); testWidgets('created time', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); const fieldType = FieldType.CreatedTime; // Create a create time field // The create time field is not editable await tester.createField(fieldType, fieldType.name); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsNothing); await tester.pumpAndSettle(); }); testWidgets('last modified time', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); const fieldType = FieldType.LastEditedTime; // Create a last time field // The last time field is not editable await tester.createField(fieldType, fieldType.name); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsNothing); await tester.pumpAndSettle(); }); testWidgets('date time', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); const fieldType = FieldType.DateTime; await tester.createField(fieldType, fieldType.name); // Tap the cell to invoke the field editor await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsOneWidget); // Toggle include time await tester.toggleIncludeTime(); // Dismiss the cell editor await tester.dismissCellEditor(); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsOneWidget); // Turn off include time await tester.toggleIncludeTime(); // Select a date final today = DateTime.now(); await tester.selectDay(content: today.day); await tester.dismissCellEditor(); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: DateFormat('MMM dd, y').format(today), ); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); // Toggle include time final now = DateTime.now(); await tester.toggleIncludeTime(); await tester.dismissCellEditor(); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: DateFormat('MMM dd, y HH:mm').format(now), ); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsOneWidget); // Change date format await tester.tapChangeDateTimeFormatButton(); await tester.changeDateFormat(); await tester.dismissCellEditor(); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: DateFormat('dd/MM/y HH:mm').format(now), ); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsOneWidget); // Change time format await tester.tapChangeDateTimeFormatButton(); await tester.changeTimeFormat(); await tester.dismissCellEditor(); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: DateFormat('dd/MM/y hh:mm a').format(now), ); await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findDateEditor(findsOneWidget); // Clear the date and time await tester.clearDate(); tester.assertCellContent( rowIndex: 0, fieldType: FieldType.DateTime, content: '', ); await tester.pumpAndSettle(); }); testWidgets('single select', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); const fieldType = FieldType.SingleSelect; // When create a grid, it will create a single select field by default await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Tap the cell to invoke the selection option editor await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Create a new select option await tester.createOption(name: 'tag 1'); await tester.dismissCellEditor(); // Make sure the option is created and displayed in the cell await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: 'tag 1', ); await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Create another select option await tester.createOption(name: 'tag 2'); await tester.dismissCellEditor(); await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: 'tag 2', ); await tester.assertNumberOfSelectedOptionsInGrid( rowIndex: 0, matcher: findsOneWidget, ); await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // switch to first option await tester.selectOption(name: 'tag 1'); await tester.dismissCellEditor(); await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: 'tag 1', ); await tester.assertNumberOfSelectedOptionsInGrid( rowIndex: 0, matcher: findsOneWidget, ); await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Deselect the currently-selected option await tester.selectOption(name: 'tag 1'); await tester.dismissCellEditor(); await tester.assertNumberOfSelectedOptionsInGrid( rowIndex: 0, matcher: findsNothing, ); await tester.pumpAndSettle(); }); testWidgets('multi select', (tester) async { final tags = [ 'tag 1', 'tag 2', 'tag 3', 'tag 4', ]; await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); const fieldType = FieldType.MultiSelect; await tester.createField(fieldType, fieldType.name); // Tap the cell to invoke the selection option editor await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Create a new select option await tester.createOption(name: tags.first); await tester.dismissCellEditor(); // Make sure the option is created and displayed in the cell await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: tags.first, ); await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Create some other select options await tester.createOption(name: tags[1]); await tester.createOption(name: tags[2]); await tester.createOption(name: tags[3]); await tester.dismissCellEditor(); for (final tag in tags) { await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: tag, ); } await tester.assertNumberOfSelectedOptionsInGrid( rowIndex: 0, matcher: findsNWidgets(4), ); await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Deselect all options for (final tag in tags) { await tester.selectOption(name: tag); } await tester.dismissCellEditor(); await tester.assertNumberOfSelectedOptionsInGrid( rowIndex: 0, matcher: findsNothing, ); await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType); await tester.findSelectOptionEditor(findsOneWidget); // Select some options await tester.selectOption(name: tags[1]); await tester.selectOption(name: tags[3]); await tester.dismissCellEditor(); await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: tags[1], ); await tester.findSelectOptionWithNameInGrid( rowIndex: 0, name: tags[3], ); await tester.assertNumberOfSelectedOptionsInGrid( rowIndex: 0, matcher: findsNWidgets(2), ); await tester.pumpAndSettle(); }); testWidgets('checklist', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); const fieldType = FieldType.Checklist; await tester.createField(fieldType, fieldType.name); // assert that there is no progress bar in the grid tester.assertChecklistCellInGrid(rowIndex: 0, percent: null); // tap on the first checklist cell await tester.tapChecklistCellInGrid(rowIndex: 0); // assert that the checklist editor is shown tester.assertChecklistEditorVisible(visible: true); // create a new task with enter await tester.createNewChecklistTask(name: "task 0", enter: true); // assert that the task is displayed tester.assertChecklistTaskInEditor( index: 0, name: "task 0", isChecked: false, ); // update the task's name await tester.renameChecklistTask(index: 0, name: "task 1"); // assert that the task's name is updated tester.assertChecklistTaskInEditor( index: 0, name: "task 1", isChecked: false, ); // dismiss new task editor await tester.dismissCellEditor(); // dismiss checklist cell editor await tester.dismissCellEditor(); // assert that progress bar is shown in grid at 0% tester.assertChecklistCellInGrid(rowIndex: 0, percent: 0); // start editing the first checklist cell again await tester.tapChecklistCellInGrid(rowIndex: 0); // create another task with the create button await tester.createNewChecklistTask(name: "task 2", button: true); // assert that the task was inserted tester.assertChecklistTaskInEditor( index: 1, name: "task 2", isChecked: false, ); // mark it as complete await tester.checkChecklistTask(index: 1); // assert that the task was checked in the editor tester.assertChecklistTaskInEditor( index: 1, name: "task 2", isChecked: true, ); // dismiss checklist editor await tester.dismissCellEditor(); await tester.dismissCellEditor(); // assert that progressbar is shown in grid at 50% tester.assertChecklistCellInGrid(rowIndex: 0, percent: 0.5); // re-open the cell editor await tester.tapChecklistCellInGrid(rowIndex: 0); // hover over first task and delete it await tester.deleteChecklistTask(index: 0); // dismiss cell editor await tester.dismissCellEditor(); // assert that progressbar is shown in grid at 100% tester.assertChecklistCellInGrid(rowIndex: 0, percent: 1); // re-open the cell edior await tester.tapChecklistCellInGrid(rowIndex: 0); // delete the remaining task await tester.deleteChecklistTask(index: 0); // dismiss the cell editor await tester.dismissCellEditor(); // check that the progress bar is not viisble tester.assertChecklistCellInGrid(rowIndex: 0, percent: null); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_share_test.dart
import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('database', () { testWidgets('import v0.2.0 database data', (tester) async { await tester.openV020database(); // wait the database data is loaded await tester.pumpAndSettle(const Duration(microseconds: 500)); // check the text cell final textCells = <String>['A', 'B', 'C', 'D', 'E', '', '', '', '', '']; for (final (index, content) in textCells.indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.RichText, content: content, ); } // check the checkbox cell final checkboxCells = <bool>[ true, true, true, true, true, false, false, false, false, false, ]; for (final (index, content) in checkboxCells.indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } // check the number cell final numberCells = <String>[ '-1', '-2', '0.1', '0.2', '1', '2', '10', '11', '12', '', ]; for (final (index, content) in numberCells.indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.Number, content: content, ); } // check the url cell final urlCells = <String>[ 'appflowy.io', 'no url', 'appflowy.io', 'https://github.com/AppFlowy-IO/', '', '', ]; for (final (index, content) in urlCells.indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.URL, content: content, ); } // check the single select cell final singleSelectCells = <String>[ 's1', 's2', 's3', 's4', 's5', '', '', '', '', '', ]; for (final (index, content) in singleSelectCells.indexed) { await tester.assertSingleSelectOption( rowIndex: index, content: content, ); } // check the multi select cell final List<List<String>> multiSelectCells = [ ['m1'], ['m1', 'm2'], ['m1', 'm2', 'm3'], ['m1', 'm2', 'm3'], ['m1', 'm2', 'm3', 'm4', 'm5'], [], [], [], [], [], ]; for (final (index, contents) in multiSelectCells.indexed) { await tester.assertMultiSelectOption( rowIndex: index, contents: contents, ); } // check the checklist cell final List<double?> checklistCells = [ 0.67, 0.33, 1.0, null, null, null, null, null, null, null, ]; for (final (index, percent) in checklistCells.indexed) { tester.assertChecklistCellInGrid( rowIndex: index, percent: percent, ); } // check the date cell final List<String> dateCells = [ 'Jun 01, 2023', 'Jun 02, 2023', 'Jun 03, 2023', 'Jun 04, 2023', 'Jun 05, 2023', 'Jun 05, 2023', 'Jun 16, 2023', '', '', '', ]; for (final (index, content) in dateCells.indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.DateTime, content: content, ); } }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_sort_test.dart
import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('grid', () { testWidgets('add text sort', (tester) async { await tester.openV020database(); // create a sort await tester.tapDatabaseSortButton(); await tester.tapCreateSortByFieldType(FieldType.RichText, 'Name'); // check the text cell order final textCells = <String>[ 'A', 'B', 'C', 'D', 'E', '', '', '', '', '', ]; for (final (index, content) in textCells.indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.RichText, content: content, ); } // open the sort menu and select order by descending await tester.tapSortMenuInSettingBar(); await tester.tapSortButtonByName('Name'); await tester.tapSortByDescending(); for (final (index, content) in <String>[ 'E', 'D', 'C', 'B', 'A', '', '', '', '', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.RichText, content: content, ); } // delete all sorts await tester.tapSortMenuInSettingBar(); await tester.tapAllSortButton(); // check the text cell order for (final (index, content) in <String>[ 'A', 'B', 'C', 'D', 'E', '', '', '', '', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.RichText, content: content, ); } await tester.pumpAndSettle(); }); testWidgets('add checkbox sort', (tester) async { await tester.openV020database(); // create a sort await tester.tapDatabaseSortButton(); await tester.tapCreateSortByFieldType(FieldType.Checkbox, 'Done'); // check the checkbox cell order for (final (index, content) in <bool>[ false, false, false, false, false, true, true, true, true, true, ].indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } // open the sort menu and select order by descending await tester.tapSortMenuInSettingBar(); await tester.tapSortButtonByName('Done'); await tester.tapSortByDescending(); for (final (index, content) in <bool>[ true, true, true, true, true, false, false, false, false, false, ].indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } await tester.pumpAndSettle(); }); testWidgets('add number sort', (tester) async { await tester.openV020database(); // create a sort await tester.tapDatabaseSortButton(); await tester.tapCreateSortByFieldType(FieldType.Number, 'number'); // check the number cell order for (final (index, content) in <String>[ '-2', '-1', '0.1', '0.2', '1', '2', '10', '11', '12', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.Number, content: content, ); } // open the sort menu and select order by descending await tester.tapSortMenuInSettingBar(); await tester.tapSortButtonByName('number'); await tester.tapSortByDescending(); for (final (index, content) in <String>[ '12', '11', '10', '2', '1', '0.2', '0.1', '-1', '-2', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.Number, content: content, ); } await tester.pumpAndSettle(); }); testWidgets('add checkbox and number sort', (tester) async { await tester.openV020database(); // create a sort await tester.tapDatabaseSortButton(); await tester.tapCreateSortByFieldType(FieldType.Checkbox, 'Done'); // open the sort menu and sort checkbox by descending await tester.tapSortMenuInSettingBar(); await tester.tapSortButtonByName('Done'); await tester.tapSortByDescending(); for (final (index, content) in <bool>[ true, true, true, true, true, false, false, false, false, false, ].indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } // add another sort, this time by number descending await tester.tapSortMenuInSettingBar(); await tester.tapCreateSortByFieldTypeInSortMenu( FieldType.Number, 'number', ); await tester.tapSortButtonByName('number'); await tester.tapSortByDescending(); // check checkbox cell order for (final (index, content) in <bool>[ true, true, true, true, true, false, false, false, false, false, ].indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } // check number cell order for (final (index, content) in <String>[ '1', '0.2', '0.1', '-1', '-2', '12', '11', '10', '2', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.Number, content: content, ); } await tester.pumpAndSettle(); }); testWidgets('reorder sort', (tester) async { await tester.openV020database(); // create a sort await tester.tapDatabaseSortButton(); await tester.tapCreateSortByFieldType(FieldType.Checkbox, 'Done'); // open the sort menu and sort checkbox by descending await tester.tapSortMenuInSettingBar(); await tester.tapSortButtonByName('Done'); await tester.tapSortByDescending(); // add another sort, this time by number descending await tester.tapSortMenuInSettingBar(); await tester.tapCreateSortByFieldTypeInSortMenu( FieldType.Number, 'number', ); await tester.tapSortButtonByName('number'); await tester.tapSortByDescending(); // check checkbox cell order for (final (index, content) in <bool>[ true, true, true, true, true, false, false, false, false, false, ].indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } // check number cell order for (final (index, content) in <String>[ '1', '0.2', '0.1', '-1', '-2', '12', '11', '10', '2', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.Number, content: content, ); } // reorder sort await tester.tapSortMenuInSettingBar(); await tester.reorderSort( (FieldType.Number, 'number'), (FieldType.Checkbox, 'Done'), ); // check checkbox cell order for (final (index, content) in <bool>[ false, false, false, false, true, true, true, true, true, false, ].indexed) { await tester.assertCheckboxCell( rowIndex: index, isSelected: content, ); } // check the number cell order for (final (index, content) in <String>[ '12', '11', '10', '2', '1', '0.2', '0.1', '-1', '-2', '', ].indexed) { tester.assertCellContent( rowIndex: index, fieldType: FieldType.Number, content: content, ); } }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_calendar_test.dart
import 'package:appflowy/plugins/database/calendar/presentation/calendar_event_editor.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pbenum.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('calendar', () { testWidgets('update calendar layout', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( layout: ViewLayoutPB.Calendar, ); // open setting await tester.tapDatabaseSettingButton(); await tester.tapDatabaseLayoutButton(); await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Board); await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Board); await tester.tapDatabaseSettingButton(); await tester.tapDatabaseLayoutButton(); await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Grid); await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Grid); await tester.pumpAndSettle(); }); testWidgets('calendar start from day setting', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create calendar view const name = 'calendar'; await tester.createNewPageWithNameUnderParent( name: name, layout: ViewLayoutPB.Calendar, ); // Open setting await tester.tapDatabaseSettingButton(); await tester.tapCalendarLayoutSettingButton(); // select the first day of week is Monday await tester.tapFirstDayOfWeek(); await tester.tapFirstDayOfWeekStartFromMonday(); // Open the other page and open the new calendar page again await tester.openPage(gettingStarted); await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.openPage(name, layout: ViewLayoutPB.Calendar); // Open setting again and check the start from Monday is selected await tester.tapDatabaseSettingButton(); await tester.tapCalendarLayoutSettingButton(); await tester.tapFirstDayOfWeek(); tester.assertFirstDayOfWeekStartFromMonday(); await tester.pumpAndSettle(); }); testWidgets('creating and editing calendar events', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create the calendar view await tester.createNewPageWithNameUnderParent( layout: ViewLayoutPB.Calendar, ); // Scroll until today's date cell is visible await tester.scrollToToday(); // Hover over today's calendar cell await tester.hoverOnTodayCalendarCell( // Tap on create new event button onHover: tester.tapAddCalendarEventButton, ); // Make sure that the event editor popup is shown tester.assertEventEditorOpen(); tester.assertNumberOfEventsInCalendar(1); // Dismiss the event editor popup await tester.dismissEventEditor(); // Double click on today's calendar cell to create a new event await tester.doubleClickCalendarCell(DateTime.now()); // Make sure that the event is inserted in the cell tester.assertNumberOfEventsInCalendar(2); // Click on the event await tester.openCalendarEvent(index: 0); tester.assertEventEditorOpen(); // Change the title of the event await tester.editEventTitle('hello world'); await tester.dismissEventEditor(); // Make sure that the event is edited tester.assertNumberOfEventsInCalendar(1, title: 'hello world'); tester.assertNumberOfEventsOnSpecificDay(2, DateTime.now()); // Click on the event await tester.openCalendarEvent(index: 0); tester.assertEventEditorOpen(); // Click on the open icon await tester.openEventToRowDetailPage(); tester.assertRowDetailPageOpened(); // Duplicate the event await tester.tapRowDetailPageRowActionButton(); await tester.tapRowDetailPageDuplicateRowButton(); await tester.dismissRowDetailPage(); // Check that there are 2 events tester.assertNumberOfEventsInCalendar(2, title: 'hello world'); tester.assertNumberOfEventsOnSpecificDay(3, DateTime.now()); // Delete an event await tester.openCalendarEvent(index: 1); await tester.deleteEventFromEventEditor(); // Check that there is 1 event tester.assertNumberOfEventsInCalendar(1, title: 'hello world'); tester.assertNumberOfEventsOnSpecificDay(2, DateTime.now()); // Delete event from row detail page await tester.openCalendarEvent(index: 0); await tester.openEventToRowDetailPage(); tester.assertRowDetailPageOpened(); await tester.tapRowDetailPageRowActionButton(); await tester.tapRowDetailPageDeleteRowButton(); // Check that there is 0 event tester.assertNumberOfEventsInCalendar(0, title: 'hello world'); tester.assertNumberOfEventsOnSpecificDay(1, DateTime.now()); }); testWidgets('create and duplicate calendar event', (tester) async { const customTitle = "EventTitleCustom"; await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create the calendar view await tester.createNewPageWithNameUnderParent( layout: ViewLayoutPB.Calendar, ); // Scroll until today's date cell is visible await tester.scrollToToday(); // Hover over today's calendar cell await tester.hoverOnTodayCalendarCell( // Tap on create new event button onHover: () async => tester.tapAddCalendarEventButton(), ); // Make sure that the event editor popup is shown tester.assertEventEditorOpen(); tester.assertNumberOfEventsInCalendar(1); // Change the title of the event await tester.editEventTitle(customTitle); // Duplicate event final duplicateBtnFinder = find .descendant( of: find.byType(CalendarEventEditor), matching: find.byType( FlowyIconButton, ), ) .first; await tester.tap(duplicateBtnFinder); await tester.pumpAndSettle(); tester.assertNumberOfEventsInCalendar(2, title: customTitle); }); testWidgets('rescheduling events', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // Create the calendar view await tester.createNewPageWithNameUnderParent( layout: ViewLayoutPB.Calendar, ); // Create a new event on the first of this month final today = DateTime.now(); final firstOfThisMonth = DateTime(today.year, today.month); await tester.doubleClickCalendarCell(firstOfThisMonth); await tester.dismissEventEditor(); // Drag and drop the event onto the next week, same day await tester.dragDropRescheduleCalendarEvent(); // Make sure that the event has been rescheduled to the new date final sameDayNextWeek = firstOfThisMonth.add(const Duration(days: 7)); tester.assertNumberOfEventsInCalendar(1); tester.assertNumberOfEventsOnSpecificDay(1, sameDayNextWeek); // Delete the event await tester.openCalendarEvent(index: 0, date: sameDayNextWeek); await tester.deleteEventFromEventEditor(); // Create another event on the 5th of this month final fifthOfThisMonth = DateTime(today.year, today.month, 5); await tester.doubleClickCalendarCell(fifthOfThisMonth); await tester.dismissEventEditor(); // Make sure that the event is on the 4t tester.assertNumberOfEventsOnSpecificDay(1, fifthOfThisMonth); // Click on the event await tester.openCalendarEvent(index: 0, date: fifthOfThisMonth); // Open the date editor of the event await tester.tapDateCellInRowDetailPage(); await tester.findDateEditor(findsOneWidget); // Edit the event's date final newDate = fifthOfThisMonth.add(const Duration(days: 1)); await tester.selectDay(content: newDate.day); await tester.dismissCellEditor(); // Dismiss the event editor await tester.dismissEventEditor(); // Make sure that the event is edited tester.assertNumberOfEventsInCalendar(1); tester.assertNumberOfEventsOnSpecificDay(1, newDate); // Click on the unscheduled events button await tester.openUnscheduledEventsPopup(); // Assert that nothing shows up tester.findUnscheduledPopup(findsNothing, 0); // Click on the event in the calendar await tester.openCalendarEvent(index: 0, date: newDate); // Open the date editor of the event await tester.tapDateCellInRowDetailPage(); await tester.findDateEditor(findsOneWidget); // Clear the date of the event await tester.clearDate(); // Dismiss the event editor await tester.dismissEventEditor(); tester.assertNumberOfEventsInCalendar(0); // Click on the unscheduled events button await tester.openUnscheduledEventsPopup(); // Assert that a popup appears and 1 unscheduled event tester.findUnscheduledPopup(findsOneWidget, 1); // Click on the unscheduled event await tester.clickUnscheduledEvent(); tester.assertRowDetailPageOpened(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_view_test.dart
import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('database', () { testWidgets('create linked view', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Create board view await tester.tapCreateLinkedDatabaseViewButton(DatabaseLayoutPB.Board); tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board); // Create grid view await tester.tapCreateLinkedDatabaseViewButton(DatabaseLayoutPB.Grid); tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Grid); // Create calendar view await tester.tapCreateLinkedDatabaseViewButton(DatabaseLayoutPB.Calendar); tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Calendar); await tester.pumpAndSettle(); }); testWidgets('rename and delete linked view', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Create board view await tester.tapCreateLinkedDatabaseViewButton(DatabaseLayoutPB.Board); tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board); // rename board view await tester.renameLinkedView( tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board), 'new board', ); final findBoard = tester.findTabBarLinkViewByViewName('new board'); expect(findBoard, findsOneWidget); // delete the board await tester.deleteDatebaseView(findBoard); expect(tester.findTabBarLinkViewByViewName('new board'), findsNothing); await tester.pumpAndSettle(); }); testWidgets('delete the last database view', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Create board view await tester.tapCreateLinkedDatabaseViewButton(DatabaseLayoutPB.Board); tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board); // delete the board await tester.deleteDatebaseView( tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board), ); await tester.pumpAndSettle(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_reminder_test.dart
import 'package:appflowy/workspace/presentation/notifications/widgets/notification_item.dart'; import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/reminder_selector.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('reminder in database', () { testWidgets('add date field and add reminder', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Invoke the field editor await tester.tapGridFieldWithName('Type'); await tester.tapEditFieldButton(); // Change to date type await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(FieldType.DateTime); await tester.dismissFieldEditor(); // Open date picker await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Select date final isToday = await tester.selectLastDateInPicker(); // Select "On day of event" reminder await tester.selectReminderOption(ReminderOption.onDayOfEvent); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); // Dismiss the cell/date editor await tester.dismissCellEditor(); // Open date picker again await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); // Dismiss the cell/date editor await tester.dismissCellEditor(); int tabIndex = 1; final now = DateTime.now(); if (isToday && now.hour >= 9) { tabIndex = 0; } // Open "Upcoming" in Notification hub await tester.openNotificationHub(tabIndex: tabIndex); // Expect 1 notification tester.expectNotificationItems(1); }); testWidgets('navigate from reminder to open row', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Invoke the field editor await tester.tapGridFieldWithName('Type'); await tester.tapEditFieldButton(); // Change to date type await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(FieldType.DateTime); await tester.dismissFieldEditor(); // Open date picker await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Select date final isToday = await tester.selectLastDateInPicker(); // Select "On day of event"-reminder await tester.selectReminderOption(ReminderOption.onDayOfEvent); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); // Dismiss the cell/date editor await tester.dismissCellEditor(); // Open date picker again await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); // Dismiss the cell/date editor await tester.dismissCellEditor(); // Create and Navigate to a new document await tester.createNewPageWithNameUnderParent(); await tester.pumpAndSettle(); int tabIndex = 1; final now = DateTime.now(); if (isToday && now.hour >= 9) { tabIndex = 0; } // Open correct tab in Notification hub await tester.openNotificationHub(tabIndex: tabIndex); // Expect 1 notification tester.expectNotificationItems(1); // Tap on the notification await tester.tap(find.byType(NotificationItem)); await tester.pumpAndSettle(); // Expect to see Row Editor Dialog tester.expectToSeeRowDetailsPageDialog(); }); testWidgets( 'toggle include time sets reminder option correctly', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( layout: ViewLayoutPB.Grid, ); // Invoke the field editor await tester.tapGridFieldWithName('Type'); await tester.tapEditFieldButton(); // Change to date type await tester.tapSwitchFieldTypeButton(); await tester.selectFieldType(FieldType.DateTime); await tester.dismissFieldEditor(); // Open date picker await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Select date await tester.selectLastDateInPicker(); // Select "On day of event"-reminder await tester.selectReminderOption(ReminderOption.onDayOfEvent); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); // Dismiss the cell/date editor await tester.dismissCellEditor(); // Open date picker again await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); // Toggle include time on await tester.toggleIncludeTime(); // Expect "At time of event" to be displayed tester.expectSelectedReminder(ReminderOption.atTimeOfEvent); // Dismiss the cell/date editor await tester.dismissCellEditor(); // Open date picker again await tester.tapCellInGrid(rowIndex: 0, fieldType: FieldType.DateTime); await tester.findDateEditor(findsOneWidget); // Expect "At time of event" to be displayed tester.expectSelectedReminder(ReminderOption.atTimeOfEvent); // Select "One hour before"-reminder await tester.selectReminderOption(ReminderOption.oneHourBefore); // Expect "One hour before" to be displayed tester.expectSelectedReminder(ReminderOption.oneHourBefore); // Toggle include time off await tester.toggleIncludeTime(); // Expect "On day of event" to be displayed tester.expectSelectedReminder(ReminderOption.onDayOfEvent); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/database/database_field_settings_test.dart
import 'package:appflowy/plugins/database/grid/presentation/grid_page.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pbenum.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('database field settings', () { testWidgets('field visibility', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); await tester.tapCreateLinkedDatabaseViewButton(DatabaseLayoutPB.Grid); // create a field await tester.scrollToRight(find.byType(GridPage)); await tester.tapNewPropertyButton(); await tester.renameField('New field 1'); await tester.dismissFieldEditor(); // hide the field await tester.tapGridFieldWithName('New field 1'); await tester.tapHidePropertyButton(); tester.noFieldWithName('New field 1'); // go back to inline database view, expect field to be shown await tester.tapTabBarLinkedViewByViewName('Untitled'); tester.findFieldWithName('New field 1'); // go back to linked database view, expect field to be hidden await tester.tapTabBarLinkedViewByViewName('Grid'); tester.noFieldWithName('New field 1'); // use the settings button to show the field await tester.tapDatabaseSettingButton(); await tester.tapViewPropertiesButton(); await tester.tapViewTogglePropertyVisibilityButtonByName('New field 1'); await tester.dismissFieldEditor(); tester.findFieldWithName('New field 1'); // open first row in popup then hide the field await tester.openFirstRowDetailPage(); await tester.tapGridFieldWithNameInRowDetailPage('New field 1'); await tester.tapHidePropertyButtonInFieldEditor(); await tester.dismissRowDetailPage(); tester.noFieldWithName('New field 1'); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/command_palette/folder_search_test.dart
import 'package:appflowy/workspace/presentation/command_palette/command_palette.dart'; import 'package:appflowy/workspace/presentation/command_palette/widgets/search_field.dart'; import 'package:appflowy/workspace/presentation/command_palette/widgets/search_result_tile.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Folder Search', () { testWidgets('Search for views', (tester) async { const firstDocument = "ViewOne"; const secondDocument = "ViewOna"; await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(name: firstDocument); await tester.createNewPageWithNameUnderParent(name: secondDocument); await tester.toggleCommandPalette(); expect(find.byType(CommandPaletteModal), findsOneWidget); final searchFieldFinder = find.descendant( of: find.byType(SearchField), matching: find.byType(FlowyTextField), ); await tester.enterText(searchFieldFinder, secondDocument); await tester.pumpAndSettle(const Duration(milliseconds: 200)); // Expect two search results "ViewOna" and "ViewOne" (Distance 1 to ViewOna) expect(find.byType(SearchResultTile), findsNWidgets(2)); // The score should be higher for "ViewOna" thus it should be shown first final secondDocumentWidget = tester .widget(find.byType(SearchResultTile).first) as SearchResultTile; expect(secondDocumentWidget.result.data, secondDocument); // Change search to "ViewOne" await tester.enterText(searchFieldFinder, firstDocument); await tester.pumpAndSettle(const Duration(seconds: 1)); // The score should be higher for "ViewOne" thus it should be shown first final firstDocumentWidget = tester .widget(find.byType(SearchResultTile).first) as SearchResultTile; expect(firstDocumentWidget.result.data, firstDocument); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/command_palette/recent_history_test.dart
import 'package:appflowy/workspace/presentation/command_palette/command_palette.dart'; import 'package:appflowy/workspace/presentation/command_palette/widgets/recent_view_tile.dart'; import 'package:appflowy/workspace/presentation/command_palette/widgets/recent_views_list.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Recent History', () { testWidgets('Search for views', (tester) async { const firstDocument = "First"; const secondDocument = "Second"; await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(name: firstDocument); await tester.createNewPageWithNameUnderParent(name: secondDocument); await tester.toggleCommandPalette(); expect(find.byType(CommandPaletteModal), findsOneWidget); // Expect history list expect(find.byType(RecentViewsList), findsOneWidget); // Expect three recent history items expect(find.byType(RecentViewTile), findsNWidgets(3)); // Expect the first item to be the last viewed document final firstDocumentWidget = tester.widget(find.byType(RecentViewTile).first) as RecentViewTile; expect(firstDocumentWidget.view.name, secondDocument); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/command_palette/command_palette_test.dart
import 'package:appflowy/workspace/presentation/command_palette/command_palette.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Command Palette', () { testWidgets('Toggle command palette', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.toggleCommandPalette(); expect(find.byType(CommandPaletteModal), findsOneWidget); await tester.toggleCommandPalette(); expect(find.byType(CommandPaletteModal), findsNothing); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/command_palette/command_palette_test_runner.dart
import 'package:integration_test/integration_test.dart'; import 'command_palette_test.dart' as command_palette_test; import 'folder_search_test.dart' as folder_search_test; import 'recent_history_test.dart' as recent_history_test; void startTesting() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // Command Palette integration tests command_palette_test.main(); folder_search_test.main(); recent_history_test.main(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/reminder/document_reminder_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart'; import 'package:appflowy/user/application/user_settings_service.dart'; import 'package:appflowy/workspace/application/settings/date_time/date_format_ext.dart'; import 'package:appflowy/workspace/presentation/notifications/widgets/notification_item.dart'; import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart'; import 'package:appflowy_backend/protobuf/flowy-user/date_time.pbenum.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:calendar_view/calendar_view.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/style_widget/text_field.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/base.dart'; import '../../shared/common_operations.dart'; import '../../shared/editor_test_operations.dart'; import '../../shared/expectation.dart'; import '../../shared/keyboard.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Reminder in Document', () { testWidgets('Add reminder for tomorrow, and include time', (tester) async { const time = "23:59"; await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final dateTimeSettings = await UserSettingsBackendService().getDateTimeSettings(); await tester.editor.tapLineOfEditorAt(0); await tester.editor.getCurrentEditorState().insertNewLine(); await tester.pumpAndSettle(); // Trigger inline action menu and type 'remind tomorrow' final tomorrow = await _insertReminderTomorrow(tester); Node node = tester.editor.getCurrentEditorState().getNodeAtPath([1])!; Map<String, dynamic> mentionAttr = node.delta!.first.attributes![MentionBlockKeys.mention]; expect(node.type, 'paragraph'); expect(mentionAttr['type'], MentionType.date.name); expect(mentionAttr['date'], tomorrow.toIso8601String()); await tester.tap( find.text(dateTimeSettings.dateFormat.formatDate(tomorrow, false)), ); await tester.pumpAndSettle(); await tester.tap(find.byType(Toggle)); await tester.pumpAndSettle(); await tester.enterText(find.byType(FlowyTextField), time); // Leave text field to submit await tester.tap(find.text(LocaleKeys.grid_field_includeTime.tr())); await tester.pumpAndSettle(); node = tester.editor.getCurrentEditorState().getNodeAtPath([1])!; mentionAttr = node.delta!.first.attributes![MentionBlockKeys.mention]; final tomorrowWithTime = _dateWithTime(dateTimeSettings.timeFormat, tomorrow, time); expect(node.type, 'paragraph'); expect(mentionAttr['type'], MentionType.date.name); expect(mentionAttr['date'], tomorrowWithTime.toIso8601String()); }); testWidgets('Add reminder for tomorrow, and navigate to it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.editor.tapLineOfEditorAt(0); await tester.editor.getCurrentEditorState().insertNewLine(); await tester.pumpAndSettle(); // Trigger inline action menu and type 'remind tomorrow' final tomorrow = await _insertReminderTomorrow(tester); final Node node = tester.editor.getCurrentEditorState().getNodeAtPath([1])!; final Map<String, dynamic> mentionAttr = node.delta!.first.attributes![MentionBlockKeys.mention]; expect(node.type, 'paragraph'); expect(mentionAttr['type'], MentionType.date.name); expect(mentionAttr['date'], tomorrow.toIso8601String()); // Create and Navigate to a new document await tester.createNewPageWithNameUnderParent(); await tester.pumpAndSettle(); // Open "Upcoming" in Notification hub await tester.openNotificationHub(tabIndex: 1); // Expect 1 notification tester.expectNotificationItems(1); // Tap on the notification await tester.tap(find.byType(NotificationItem)); await tester.pumpAndSettle(); // Expect node at path 1 to be the date/reminder expect( tester.editor .getCurrentEditorState() .getNodeAtPath([1]) ?.delta ?.first .attributes?[MentionBlockKeys.mention]['type'], MentionType.date.name, ); }); }); } Future<DateTime> _insertReminderTomorrow(WidgetTester tester) async { await tester.editor.showAtMenu(); await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.keyR, LogicalKeyboardKey.keyE, LogicalKeyboardKey.keyM, LogicalKeyboardKey.keyI, LogicalKeyboardKey.keyN, LogicalKeyboardKey.keyD, LogicalKeyboardKey.space, LogicalKeyboardKey.keyT, LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyM, LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyR, LogicalKeyboardKey.keyR, LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyW, ], tester: tester, ); await FlowyTestKeyboard.simulateKeyDownEvent( [LogicalKeyboardKey.enter], tester: tester, ); return DateTime.now().add(const Duration(days: 1)).withoutTime; } DateTime _dateWithTime(UserTimeFormatPB format, DateTime date, String time) { final t = format == UserTimeFormatPB.TwelveHour ? DateFormat.jm().parse(time) : DateFormat.Hm().parse(time); return DateTime.parse( '${date.year}${_padZeroLeft(date.month)}${_padZeroLeft(date.day)} ${_padZeroLeft(t.hour)}:${_padZeroLeft(t.minute)}', ); } String _padZeroLeft(int a) => a.toString().padLeft(2, '0');
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/grid/grid_calculations_test.dart
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pbenum.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Grid Calculations', () { testWidgets('add calculation and update cell', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Change one Field to Number await tester.changeFieldTypeOfFieldWithName('Type', FieldType.Number); expect(find.text('Calculate'), findsOneWidget); await tester.changeCalculateAtIndex(1, CalculationType.Sum); // Enter values in cells await tester.editCell( rowIndex: 0, fieldType: FieldType.Number, input: '100', ); await tester.editCell( rowIndex: 1, fieldType: FieldType.Number, input: '100', ); // Dismiss edit cell await tester.sendKeyDownEvent(LogicalKeyboardKey.enter); await tester.pumpAndSettle(const Duration(seconds: 1)); expect(find.text('200'), findsOneWidget); }); testWidgets('add calculations and remove row', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid); // Change two Fields to Number await tester.changeFieldTypeOfFieldWithName('Type', FieldType.Number); await tester.changeFieldTypeOfFieldWithName('Done', FieldType.Number); expect(find.text('Calculate'), findsNWidgets(2)); await tester.changeCalculateAtIndex(1, CalculationType.Sum); await tester.changeCalculateAtIndex(2, CalculationType.Min); // Enter values in cells await tester.editCell( rowIndex: 0, fieldType: FieldType.Number, input: '100', ); await tester.editCell( rowIndex: 1, fieldType: FieldType.Number, input: '150', ); await tester.editCell( rowIndex: 0, fieldType: FieldType.Number, input: '50', cellIndex: 1, ); await tester.editCell( rowIndex: 1, fieldType: FieldType.Number, input: '100', cellIndex: 1, ); await tester.pumpAndSettle(); // Dismiss edit cell await tester.sendKeyDownEvent(LogicalKeyboardKey.enter); await tester.pumpAndSettle(); expect(find.text('250'), findsOneWidget); expect(find.text('50'), findsNWidgets(2)); // Delete 1st row await tester.hoverOnFirstRowOfGrid(); await tester.tapRowMenuButtonInGrid(); await tester.tapDeleteOnRowMenu(); await tester.pumpAndSettle(const Duration(seconds: 1)); expect(find.text('150'), findsNWidgets(2)); expect(find.text('100'), findsNWidgets(2)); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_inline_page_reference_test.dart
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart'; import 'package:appflowy/plugins/inline_actions/widgets/inline_actions_handler.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; import 'package:flowy_infra/uuid.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/keyboard.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('insert inline document reference', () { testWidgets('insert by slash menu', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final name = await createDocumentToReference(tester); await tester.editor.tapLineOfEditorAt(0); await tester.pumpAndSettle(); await triggerReferenceDocumentBySlashMenu(tester); // Search for prefix of document await enterDocumentText(tester); // Select result final optionFinder = find.descendant( of: find.byType(InlineActionsHandler), matching: find.text(name), ); await tester.tap(optionFinder); await tester.pumpAndSettle(); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); }); testWidgets('insert by `[[` character shortcut', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final name = await createDocumentToReference(tester); await tester.editor.tapLineOfEditorAt(0); await tester.pumpAndSettle(); await tester.ime.insertText('[['); await tester.pumpAndSettle(); // Select result await tester.editor.tapAtMenuItemWithName(name); await tester.pumpAndSettle(); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); }); testWidgets('insert by `+` character shortcut', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final name = await createDocumentToReference(tester); await tester.editor.tapLineOfEditorAt(0); await tester.pumpAndSettle(); await tester.ime.insertText('+'); await tester.pumpAndSettle(); // Select result await tester.editor.tapAtMenuItemWithName(name); await tester.pumpAndSettle(); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); }); }); } Future<String> createDocumentToReference(WidgetTester tester) async { final name = 'document_${uuid()}'; await tester.createNewPageWithNameUnderParent( name: name, openAfterCreated: false, ); // This is a workaround since the openAfterCreated // option does not work in createNewPageWithName method await tester.tap(find.byType(SingleInnerViewItem).first); await tester.pumpAndSettle(); return name; } Future<void> triggerReferenceDocumentBySlashMenu(WidgetTester tester) async { await tester.editor.showSlashMenu(); await tester.pumpAndSettle(); // Search for referenced document action await enterDocumentText(tester); // Select item await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.enter, ], tester: tester, ); await tester.pumpAndSettle(); } Future<void> enterDocumentText(WidgetTester tester) async { await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.keyD, LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyC, LogicalKeyboardKey.keyU, LogicalKeyboardKey.keyM, LogicalKeyboardKey.keyE, LogicalKeyboardKey.keyN, LogicalKeyboardKey.keyT, ], tester: tester, ); await tester.pumpAndSettle(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_inline_page_test.dart
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_page_block.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart'; import 'package:flowy_infra/uuid.dart'; import 'package:flowy_infra_ui/widget/error_page.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('inline page view in document', () { testWidgets('insert a inline page - grid', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertInlinePage(tester, ViewLayoutPB.Grid); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); await tester.tapButton(mentionBlock); }); testWidgets('insert a inline page - board', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertInlinePage(tester, ViewLayoutPB.Board); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); await tester.tapButton(mentionBlock); }); testWidgets('insert a inline page - calendar', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertInlinePage(tester, ViewLayoutPB.Calendar); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); await tester.tapButton(mentionBlock); }); testWidgets('insert a inline page - document', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertInlinePage(tester, ViewLayoutPB.Document); final mentionBlock = find.byType(MentionPageBlock); expect(mentionBlock, findsOneWidget); await tester.tapButton(mentionBlock); }); testWidgets('insert a inline page and rename it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final pageName = await insertInlinePage(tester, ViewLayoutPB.Document); // rename const newName = 'RenameToNewPageName'; await tester.hoverOnPageName( pageName, onHover: () async => tester.renamePage(newName), ); final finder = find.descendant( of: find.byType(MentionPageBlock), matching: find.findTextInFlowyText(newName), ); expect(finder, findsOneWidget); }); testWidgets('insert a inline page and delete it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final pageName = await insertInlinePage(tester, ViewLayoutPB.Grid); // rename await tester.hoverOnPageName( pageName, layout: ViewLayoutPB.Grid, onHover: () async => tester.tapDeletePageButton(), ); final finder = find.descendant( of: find.byType(MentionPageBlock), matching: find.findTextInFlowyText(pageName), ); expect(finder, findsOneWidget); await tester.tapButton(finder); expect(find.byType(FlowyErrorPage), findsOneWidget); }); }); } /// Insert a referenced database of [layout] into the document Future<String> insertInlinePage( WidgetTester tester, ViewLayoutPB layout, ) async { // create a new grid final id = uuid(); final name = '${layout.name}_$id'; await tester.createNewPageWithNameUnderParent( name: name, layout: layout, openAfterCreated: false, ); // create a new document await tester.createNewPageWithNameUnderParent( name: 'insert_a_inline_page_${layout.name}', ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a inline page await tester.editor.showAtMenu(); await tester.editor.tapAtMenuItemWithName(name); return name; }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/edit_document_test.dart
import 'dart:io'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('edit document', () { testWidgets('redo & undo', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document called Sample const pageName = 'Sample'; await tester.createNewPageWithNameUnderParent(name: pageName); // focus on the editor await tester.editor.tapLineOfEditorAt(0); // insert 1. to trigger it to be a numbered list await tester.ime.insertText('1. '); expect(find.text('1.', findRichText: true), findsOneWidget); expect( tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type, NumberedListBlockKeys.type, ); // undo // numbered list will be reverted to paragraph await tester.simulateKeyEvent( LogicalKeyboardKey.keyZ, isControlPressed: Platform.isWindows || Platform.isLinux, isMetaPressed: Platform.isMacOS, ); expect( tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type, ParagraphBlockKeys.type, ); // redo await tester.simulateKeyEvent( LogicalKeyboardKey.keyZ, isControlPressed: Platform.isWindows || Platform.isLinux, isMetaPressed: Platform.isMacOS, isShiftPressed: true, ); expect( tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type, NumberedListBlockKeys.type, ); // switch to other page and switch back await tester.openPage(gettingStarted); await tester.openPage(pageName); // the numbered list should be kept expect( tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type, NumberedListBlockKeys.type, ); }); testWidgets('write a readme document', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document called Sample const pageName = 'Sample'; await tester.createNewPageWithNameUnderParent(name: pageName); // focus on the editor await tester.editor.tapLineOfEditorAt(0); // mock inputting the sample final lines = _sample.split('\n'); for (final line in lines) { await tester.ime.insertText(line); await tester.ime.insertCharacter('\n'); } // switch to other page and switch back await tester.openPage(gettingStarted); await tester.openPage(pageName); // this screenshots are different on different platform, so comment it out temporarily. // check the document // await expectLater( // find.byType(AppFlowyEditor), // matchesGoldenFile('document/edit_document_test.png'), // ); }); }); } const _sample = ''' # Heading 1 ## Heading 2 ### Heading 3 --- [] Highlight any text, and use the editing menu to _style_ **your** writing `however` you ~~like.~~ [] Type followed by bullet or num to create a list. [x] Click `New Page` button at the bottom of your sidebar to add a new page. [] Click the plus sign next to any page title in the sidebar to quickly add a new subpage, `Document`, `Grid`, or `Kanban Board`. --- * bulleted list 1 * bulleted list 2 * bulleted list 3 bulleted list 4 --- 1. numbered list 1 2. numbered list 2 3. numbered list 3 numbered list 4 --- " quote''';
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_outline_block_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/outline/outline_block_component.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart'; import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; const String heading1 = "Heading 1"; const String heading2 = "Heading 2"; const String heading3 = "Heading 3"; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('outline block test', () { testWidgets('insert an outline block', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( name: 'outline_test', ); await tester.editor.tapLineOfEditorAt(0); await insertOutlineInDocument(tester); // validate the outline is inserted expect(find.byType(OutlineBlockWidget), findsOneWidget); }); testWidgets('insert an outline block and check if headings are visible', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( name: 'outline_test', ); await insertHeadingComponent(tester); /* Results in: * # Heading 1 * ## Heading 2 * ### Heading 3 */ await tester.editor.tapLineOfEditorAt(3); await insertOutlineInDocument(tester); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading1), ), findsOneWidget, ); // Heading 2 is prefixed with a bullet expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading2), ), findsOneWidget, ); // Heading 3 is prefixed with a dash expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading3), ), findsOneWidget, ); // update the Heading 1 to Heading 1Hello world await tester.editor.tapLineOfEditorAt(0); await tester.ime.insertText('Hello world'); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text('${heading1}Hello world'), ), findsOneWidget, ); }); testWidgets("control the depth of outline block", (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent( name: 'outline_test', ); await insertHeadingComponent(tester); /* Results in: * # Heading 1 * ## Heading 2 * ### Heading 3 */ await tester.editor.tapLineOfEditorAt(3); await insertOutlineInDocument(tester); // expect to find only the `heading1` widget under the [OutlineBlockWidget] await hoverAndClickDepthOptionAction(tester, [3], 1); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading2), ), findsNothing, ); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading3), ), findsNothing, ); ////// /// expect to find only the 'heading1' and 'heading2' under the [OutlineBlockWidget] await hoverAndClickDepthOptionAction(tester, [3], 2); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading3), ), findsNothing, ); ////// // expect to find all the headings under the [OutlineBlockWidget] await hoverAndClickDepthOptionAction(tester, [3], 3); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading1), ), findsOneWidget, ); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading2), ), findsOneWidget, ); expect( find.descendant( of: find.byType(OutlineBlockWidget), matching: find.text(heading3), ), findsOneWidget, ); ////// }); }); } /// Inserts an outline block in the document Future<void> insertOutlineInDocument(WidgetTester tester) async { // open the actions menu and insert the outline block await tester.editor.showSlashMenu(); await tester.editor.tapSlashMenuItemWithName( LocaleKeys.document_selectionMenu_outline.tr(), ); await tester.pumpAndSettle(); } Future<void> hoverAndClickDepthOptionAction( WidgetTester tester, List<int> path, int level, ) async { await tester.editor.hoverAndClickOptionMenuButton([3]); await tester.tap(find.byType(AppFlowyPopover).hitTestable().last); await tester.pumpAndSettle(); // Find a total of 4 HoverButtons under the [BlockOptionButton], // in addition to 3 HoverButtons under the [DepthOptionAction] - (child of BlockOptionButton) await tester.tap(find.byType(HoverButton).hitTestable().at(3 + level)); await tester.pumpAndSettle(); } Future<void> insertHeadingComponent(WidgetTester tester) async { await tester.editor.tapLineOfEditorAt(0); await tester.ime.insertText('# $heading1\n'); await tester.ime.insertText('## $heading2\n'); await tester.ime.insertText('### $heading3\n'); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_cover_image_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_emoji_mart/flutter_emoji_mart.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/emoji.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('cover image', () { testWidgets('document cover tests', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); tester.expectToSeeNoDocumentCover(); // Hover over cover toolbar to show 'Add Cover' and 'Add Icon' buttons await tester.editor.hoverOnCoverToolbar(); // Insert a document cover await tester.editor.tapOnAddCover(); tester.expectToSeeDocumentCover(CoverType.asset); // Hover over the cover to show the 'Change Cover' and delete buttons await tester.editor.hoverOnCover(); tester.expectChangeCoverAndDeleteButton(); // Change cover to a solid color background await tester.editor.tapOnChangeCover(); await tester.editor.switchSolidColorBackground(); await tester.editor.dismissCoverPicker(); tester.expectToSeeDocumentCover(CoverType.color); // Change cover to a network image const imageUrl = "https://raw.githubusercontent.com/AppFlowy-IO/AppFlowy/main/frontend/appflowy_flutter/assets/images/appflowy_launch_splash.jpg"; await tester.editor.hoverOnCover(); await tester.editor.tapOnChangeCover(); await tester.editor.addNetworkImageCover(imageUrl); tester.expectToSeeDocumentCover(CoverType.file); // Remove the cover await tester.editor.hoverOnCover(); await tester.editor.tapOnRemoveCover(); tester.expectToSeeNoDocumentCover(); }); testWidgets('document icon tests', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); tester.expectToSeeDocumentIcon('⭐️'); // Insert a document icon await tester.editor.tapGettingStartedIcon(); await tester.tapEmoji('😀'); tester.expectToSeeDocumentIcon('😀'); // Remove the document icon from the cover toolbar await tester.editor.hoverOnCoverToolbar(); await tester.editor.tapRemoveIconButton(); tester.expectToSeeDocumentIcon(null); // Add the icon back for further testing await tester.editor.hoverOnCoverToolbar(); await tester.editor.tapAddIconButton(); await tester.tapEmoji('😀'); tester.expectToSeeDocumentIcon('😀'); // Change the document icon await tester.editor.tapOnIconWidget(); await tester.tapEmoji('😅'); tester.expectToSeeDocumentIcon('😅'); // Remove the document icon from the icon picker await tester.editor.tapOnIconWidget(); await tester.editor.tapRemoveIconButton(isInPicker: true); tester.expectToSeeDocumentIcon(null); }); testWidgets('icon and cover at the same time', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); tester.expectToSeeDocumentIcon('⭐️'); tester.expectToSeeNoDocumentCover(); // Insert a document icon await tester.editor.tapGettingStartedIcon(); await tester.tapEmoji('😀'); // Insert a document cover await tester.editor.hoverOnCoverToolbar(); await tester.editor.tapOnAddCover(); // Expect to see the icon and cover at the same time tester.expectToSeeDocumentIcon('😀'); tester.expectToSeeDocumentCover(CoverType.asset); // Hover over the cover toolbar and see that neither icons are shown await tester.editor.hoverOnCoverToolbar(); tester.expectToSeeEmptyDocumentHeaderToolbar(); }); testWidgets('shuffle icon', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.editor.tapGettingStartedIcon(); // click the shuffle button await tester.tapButton( find.byTooltip(LocaleKeys.emoji_random.tr()), ); tester.expectDocumentIconNotNull(); }); testWidgets('change skin tone', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.editor.tapGettingStartedIcon(); final searchEmojiTextField = find.byWidgetPredicate( (widget) => widget is TextField && widget.decoration!.hintText == LocaleKeys.emoji_search.tr(), ); await tester.enterText( searchEmojiTextField, 'hand', ); // change skin tone await tester.editor.changeEmojiSkinTone(EmojiSkinTone.dark); // select an icon with skin tone const hand = '👋🏿'; await tester.tapEmoji(hand); tester.expectToSeeDocumentIcon(hand); tester.expectViewHasIcon( gettingStarted, ViewLayoutPB.Document, hand, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_image_block_test.dart
import 'dart:io'; import 'package:appflowy/core/config/kv.dart'; import 'package:appflowy/core/config/kv_keys.dart'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/image/custom_image_block_component.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/image/embed_image_url_widget.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/image/image_placeholder.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/image/resizeable_image.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/image/unsplash_image_widget.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/image/upload_image_menu.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy_editor/appflowy_editor.dart' hide UploadImageMenu, ResizableImage; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:path/path.dart' as p; import 'package:path_provider/path_provider.dart'; import 'package:run_with_network_images/run_with_network_images.dart'; import '../../shared/mock/mock_file_picker.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized(); group('image block in document', () { testWidgets('insert an image from local file', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent( name: LocaleKeys.document_plugins_image_addAnImage.tr(), ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); await tester.editor.showSlashMenu(); await tester.editor.tapSlashMenuItemWithName('Image'); expect(find.byType(CustomImageBlockComponent), findsOneWidget); expect(find.byType(ImagePlaceholder), findsOneWidget); expect( find.descendant( of: find.byType(ImagePlaceholder), matching: find.byType(AppFlowyPopover), ), findsOneWidget, ); expect(find.byType(UploadImageMenu), findsOneWidget); final image = await rootBundle.load('assets/test/images/sample.jpeg'); final tempDirectory = await getTemporaryDirectory(); final imagePath = p.join(tempDirectory.path, 'sample.jpeg'); final file = File(imagePath) ..writeAsBytesSync(image.buffer.asUint8List()); mockPickFilePaths( paths: [imagePath], ); await getIt<KeyValueStorage>().set(KVKeys.kCloudType, '0'); await tester.tapButtonWithName( LocaleKeys.document_imageBlock_upload_placeholder.tr(), ); await tester.pumpAndSettle(); expect(find.byType(ResizableImage), findsOneWidget); final node = tester.editor.getCurrentEditorState().getNodeAtPath([0])!; expect(node.type, ImageBlockKeys.type); expect(node.attributes[ImageBlockKeys.url], isNotEmpty); // remove the temp file file.deleteSync(); }); testWidgets('insert an image from network', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent( name: LocaleKeys.document_plugins_image_addAnImage.tr(), ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); await tester.editor.showSlashMenu(); await tester.editor.tapSlashMenuItemWithName('Image'); expect(find.byType(CustomImageBlockComponent), findsOneWidget); expect(find.byType(ImagePlaceholder), findsOneWidget); expect( find.descendant( of: find.byType(ImagePlaceholder), matching: find.byType(AppFlowyPopover), ), findsOneWidget, ); expect(find.byType(UploadImageMenu), findsOneWidget); await tester.tapButtonWithName( LocaleKeys.document_imageBlock_embedLink_label.tr(), ); const url = 'https://images.unsplash.com/photo-1469474968028-56623f02e42e?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb&dl=david-marcu-78A265wPiO4-unsplash.jpg&w=640'; await tester.enterText( find.descendant( of: find.byType(EmbedImageUrlWidget), matching: find.byType(TextField), ), url, ); await tester.tapButton( find.descendant( of: find.byType(EmbedImageUrlWidget), matching: find.text( LocaleKeys.document_imageBlock_embedLink_label.tr(), findRichText: true, ), ), ); await tester.pumpAndSettle(); expect(find.byType(ResizableImage), findsOneWidget); final node = tester.editor.getCurrentEditorState().getNodeAtPath([0])!; expect(node.type, ImageBlockKeys.type); expect(node.attributes[ImageBlockKeys.url], url); }); testWidgets('insert an image from unsplash', (tester) async { await runWithNetworkImages(() async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent( name: LocaleKeys.document_plugins_image_addAnImage.tr(), ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); await tester.editor.showSlashMenu(); await tester.editor.tapSlashMenuItemWithName('Image'); expect(find.byType(CustomImageBlockComponent), findsOneWidget); expect(find.byType(ImagePlaceholder), findsOneWidget); expect( find.descendant( of: find.byType(ImagePlaceholder), matching: find.byType(AppFlowyPopover), ), findsOneWidget, ); expect(find.byType(UploadImageMenu), findsOneWidget); await tester.tapButtonWithName( 'Unsplash', ); expect(find.byType(UnsplashImageWidget), findsOneWidget); }); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_alignment_test.dart
import 'package:appflowy/generated/flowy_svgs.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/keyboard.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('document alignment', () { testWidgets('edit alignment in toolbar', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final selection = Selection.single( path: [0], startOffset: 0, endOffset: 1, ); // click the first line of the readme await tester.editor.tapLineOfEditorAt(0); await tester.editor.updateSelection(selection); await tester.pumpAndSettle(); // click the align center await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_left_s); await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_center_s); // expect to see the align center final editorState = tester.editor.getCurrentEditorState(); final first = editorState.getNodeAtPath([0])!; expect(first.attributes[blockComponentAlign], 'center'); // click the align right await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_center_s); await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_right_s); expect(first.attributes[blockComponentAlign], 'right'); // click the align left await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_right_s); await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_left_s); expect(first.attributes[blockComponentAlign], 'left'); }); testWidgets('edit alignment using shortcut', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // click the first line of the readme await tester.editor.tapLineOfEditorAt(0); await tester.pumpAndSettle(); final editorState = tester.editor.getCurrentEditorState(); final first = editorState.getNodeAtPath([0])!; // expect to see text aligned to the right await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.control, LogicalKeyboardKey.shift, LogicalKeyboardKey.keyR, ], tester: tester, ); expect(first.attributes[blockComponentAlign], rightAlignmentKey); // expect to see text aligned to the center await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.control, LogicalKeyboardKey.shift, LogicalKeyboardKey.keyE, ], tester: tester, ); expect(first.attributes[blockComponentAlign], centerAlignmentKey); // expect to see text aligned to the left await FlowyTestKeyboard.simulateKeyDownEvent( [ LogicalKeyboardKey.control, LogicalKeyboardKey.shift, LogicalKeyboardKey.keyL, ], tester: tester, ); expect(first.attributes[blockComponentAlign], leftAlignmentKey); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart
import 'dart:io'; import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('copy and paste in document', () { testWidgets('paste multiple lines at the first line', (tester) async { // mock the clipboard const lines = 3; await tester.pasteContent( plainText: List.generate(lines, (index) => 'line $index').join('\n'), (editorState) { expect(editorState.document.root.children.length, 3); for (var i = 0; i < lines; i++) { expect( editorState.getNodeAtPath([i])!.delta!.toPlainText(), 'line $i', ); } }, ); }); // ## **User Installation** // - [Windows/Mac/Linux](https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/mac-windows-linux-packages) // - [Docker](https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/installing-with-docker) // - [Source](https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/from-source) testWidgets('paste content from html, sample 1', (tester) async { await tester.pasteContent( html: '''<meta charset='utf-8'><h2><strong>User Installation</strong></h2> <ul> <li><a href="https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/mac-windows-linux-packages">Windows/Mac/Linux</a></li> <li><a href="https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/installing-with-docker">Docker</a></li> <li><a href="https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/from-source">Source</a></li> </ul>''', (editorState) { expect(editorState.document.root.children.length, 4); final node1 = editorState.getNodeAtPath([0])!; final node2 = editorState.getNodeAtPath([1])!; final node3 = editorState.getNodeAtPath([2])!; final node4 = editorState.getNodeAtPath([3])!; expect(node1.delta!.toJson(), [ { "insert": "User Installation", "attributes": {"bold": true}, } ]); expect(node2.delta!.toJson(), [ { "insert": "Windows/Mac/Linux", "attributes": { "href": "https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/mac-windows-linux-packages", }, } ]); expect( node3.delta!.toJson(), [ { "insert": "Docker", "attributes": { "href": "https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/installing-with-docker", }, } ], ); expect( node4.delta!.toJson(), [ { "insert": "Source", "attributes": { "href": "https://appflowy.gitbook.io/docs/essential-documentation/install-appflowy/installation-methods/from-source", }, } ], ); }, ); }); testWidgets('paste code from VSCode', (tester) async { await tester.pasteContent( html: '''<meta charset='utf-8'><div style="color: #bbbbbb;background-color: #262335;font-family: Consolas, 'JetBrains Mono', monospace, 'cascadia code', Menlo, Monaco, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 21px;white-space: pre;"><div><span style="color: #fede5d;">void</span><span style="color: #ff7edb;"> </span><span style="color: #36f9f6;">main</span><span style="color: #ff7edb;">() {</span></div><div><span style="color: #ff7edb;"> </span><span style="color: #36f9f6;">runApp</span><span style="color: #ff7edb;">(</span><span style="color: #fede5d;">const</span><span style="color: #ff7edb;"> </span><span style="color: #fe4450;">MyApp</span><span style="color: #ff7edb;">());</span></div><div><span style="color: #ff7edb;">}</span></div></div>''', (editorState) { expect(editorState.document.root.children.length, 3); final node1 = editorState.getNodeAtPath([0])!; final node2 = editorState.getNodeAtPath([1])!; final node3 = editorState.getNodeAtPath([2])!; expect(node1.type, ParagraphBlockKeys.type); expect(node2.type, ParagraphBlockKeys.type); expect(node3.type, ParagraphBlockKeys.type); expect(node1.delta!.toJson(), [ { "insert": "void", "attributes": {"font_color": "0xfffede5d"}, }, { "insert": " ", "attributes": {"font_color": "0xffff7edb"}, }, { "insert": "main", "attributes": {"font_color": "0xff36f9f6"}, }, { "insert": "() {", "attributes": {"font_color": "0xffff7edb"}, } ]); expect(node2.delta!.toJson(), [ { "insert": " ", "attributes": {"font_color": "0xffff7edb"}, }, { "insert": "runApp", "attributes": {"font_color": "0xff36f9f6"}, }, { "insert": "(", "attributes": {"font_color": "0xffff7edb"}, }, { "insert": "const", "attributes": {"font_color": "0xfffede5d"}, }, { "insert": " ", "attributes": {"font_color": "0xffff7edb"}, }, { "insert": "MyApp", "attributes": {"font_color": "0xfffe4450"}, }, { "insert": "());", "attributes": {"font_color": "0xffff7edb"}, } ]); expect(node3.delta!.toJson(), [ { "insert": "}", "attributes": {"font_color": "0xffff7edb"}, } ]); }); }); }); testWidgets('paste image(png) from memory', (tester) async { final image = await rootBundle.load('assets/test/images/sample.png'); final bytes = image.buffer.asUint8List(); await tester.pasteContent(image: ('png', bytes), (editorState) { expect(editorState.document.root.children.length, 2); final node = editorState.getNodeAtPath([0])!; expect(node.type, ImageBlockKeys.type); expect(node.attributes[ImageBlockKeys.url], isNotNull); }); }); testWidgets('paste image(jpeg) from memory', (tester) async { final image = await rootBundle.load('assets/test/images/sample.jpeg'); final bytes = image.buffer.asUint8List(); await tester.pasteContent(image: ('jpeg', bytes), (editorState) { expect(editorState.document.root.children.length, 2); final node = editorState.getNodeAtPath([0])!; expect(node.type, ImageBlockKeys.type); expect(node.attributes[ImageBlockKeys.url], isNotNull); }); }); testWidgets('paste image(gif) from memory', (tester) async { // It's not supported yet. // final image = await rootBundle.load('assets/test/images/sample.gif'); // final bytes = image.buffer.asUint8List(); // await tester.pasteContent(image: ('gif', bytes), (editorState) { // expect(editorState.document.root.children.length, 2); // final node = editorState.getNodeAtPath([0])!; // expect(node.type, ImageBlockKeys.type); // expect(node.attributes[ImageBlockKeys.url], isNotNull); // }); }); testWidgets( 'format the selected text to href when pasting url if available', (tester) async { const text = 'appflowy'; const url = 'https://appflowy.io'; await tester.pasteContent( plainText: url, beforeTest: (editorState) async { await tester.ime.insertText(text); await tester.editor.updateSelection( Selection.single( path: [0], startOffset: 0, endOffset: text.length, ), ); }, (editorState) { final node = editorState.getNodeAtPath([0])!; expect(node.type, ParagraphBlockKeys.type); expect(node.delta!.toJson(), [ { 'insert': text, 'attributes': {'href': url}, } ]); }, ); }, ); // https://github.com/AppFlowy-IO/AppFlowy/issues/3263 testWidgets( 'paste the image from clipboard when html and image are both available', (tester) async { const html = '''<meta charset='utf-8'><img src="https://user-images.githubusercontent.com/9403740/262918875-603f4adb-58dd-49b5-8201-341d354935fd.png" alt="image"/>'''; final image = await rootBundle.load('assets/test/images/sample.png'); final bytes = image.buffer.asUint8List(); await tester.pasteContent( html: html, image: ('png', bytes), (editorState) { expect(editorState.document.root.children.length, 2); final node = editorState.getNodeAtPath([0])!; expect(node.type, ImageBlockKeys.type); expect( node.attributes[ImageBlockKeys.url], 'https://user-images.githubusercontent.com/9403740/262918875-603f4adb-58dd-49b5-8201-341d354935fd.png', ); }, ); }, ); testWidgets('paste the html content contains section', (tester) async { const html = '''<meta charset='utf-8'><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgb(0, 160, 113);"><strong style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important;">AppFlowy</strong></span></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgb(0, 160, 113);"><strong style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important;">Hello World</strong></span></section>'''; await tester.pasteContent( html: html, (editorState) { expect(editorState.document.root.children.length, 2); final node1 = editorState.getNodeAtPath([0])!; final node2 = editorState.getNodeAtPath([1])!; expect(node1.type, ParagraphBlockKeys.type); expect(node2.type, ParagraphBlockKeys.type); }, ); }); testWidgets('paste the html from google translation', (tester) async { const html = '''<meta charset='utf-8'><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgb(0, 160, 113);"><strong style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">new force</font></font></strong></span></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgb(0, 160, 113);"><strong style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">Assessment focus: potential motivations, empathy</font></font></strong></span></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><br style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;"></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">➢Personality characteristics and potential motivations:</font></font></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">-Reflection of self-worth</font></font></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">-Need to be respected</font></font></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">-Have a unique definition of success</font></font></section><section style="margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word !important; color: rgba(255, 255, 255, 0.6); font-family: system-ui, -apple-system, &quot;system-ui&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: 0.544px; orphans: 2; text-align: justify; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 25, 25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;"><font style="margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: inherit;">-Be true to your own lifestyle</font></font></section>'''; await tester.pasteContent( html: html, (editorState) { expect(editorState.document.root.children.length, 8); }, ); }); testWidgets( 'auto convert url to link preview block', (widgetTester) async { const url = 'https://appflowy.io'; await widgetTester.pasteContent( plainText: url, (editorState) { expect(editorState.document.root.children.length, 2); final node = editorState.getNodeAtPath([0])!; expect(node.type, LinkPreviewBlockKeys.type); expect(node.attributes[LinkPreviewBlockKeys.url], url); }, ); }, ); } extension on WidgetTester { Future<void> pasteContent( void Function(EditorState editorState) test, { Future<void> Function(EditorState editorState)? beforeTest, String? plainText, String? html, (String, Uint8List?)? image, }) async { await initializeAppFlowy(); await tapAnonymousSignInButton(); // create a new document await createNewPageWithNameUnderParent(); await beforeTest?.call(editor.getCurrentEditorState()); // mock the clipboard await getIt<ClipboardService>().setData( ClipboardServiceData( plainText: plainText, html: html, image: image, ), ); // paste the text await simulateKeyEvent( LogicalKeyboardKey.keyV, isControlPressed: Platform.isLinux || Platform.isWindows, isMetaPressed: Platform.isMacOS, ); await pumpAndSettle(); test(editor.getCurrentEditorState()); } }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner.dart
import 'package:integration_test/integration_test.dart'; import 'document_alignment_test.dart' as document_alignment_test; import 'document_codeblock_paste_test.dart' as document_codeblock_paste_test; import 'document_copy_and_paste_test.dart' as document_copy_and_paste_test; import 'document_create_and_delete_test.dart' as document_create_and_delete_test; import 'document_option_action_test.dart' as document_option_action_test; import 'document_text_direction_test.dart' as document_text_direction_test; import 'document_with_cover_image_test.dart' as document_with_cover_image_test; import 'document_with_database_test.dart' as document_with_database_test; import 'document_with_image_block_test.dart' as document_with_image_block_test; import 'document_with_inline_math_equation_test.dart' as document_with_inline_math_equation_test; import 'document_with_inline_page_test.dart' as document_with_inline_page_test; import 'document_with_outline_block_test.dart' as document_with_outline_block; import 'document_with_toggle_list_test.dart' as document_with_toggle_list_test; import 'edit_document_test.dart' as document_edit_test; import 'document_inline_page_reference_test.dart' as document_inline_page_reference_test; void startTesting() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // Document integration tests document_create_and_delete_test.main(); document_edit_test.main(); document_with_database_test.main(); document_with_inline_page_test.main(); document_with_inline_math_equation_test.main(); document_with_cover_image_test.main(); document_with_outline_block.main(); document_with_toggle_list_test.main(); document_copy_and_paste_test.main(); document_codeblock_paste_test.main(); document_alignment_test.main(); document_text_direction_test.main(); document_option_action_test.main(); document_with_image_block_test.main(); document_inline_page_reference_test.main(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_toggle_list_test.dart
import 'dart:io'; import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized(); group('toggle list in document', () { Finder findToggleListIcon({ required bool isExpanded, }) { final turns = isExpanded ? 0.25 : 0.0; return find.byWidgetPredicate( (widget) => widget is AnimatedRotation && widget.turns == turns, ); } void expectToggleListOpened() { expect(findToggleListIcon(isExpanded: true), findsOneWidget); expect(findToggleListIcon(isExpanded: false), findsNothing); } void expectToggleListClosed() { expect(findToggleListIcon(isExpanded: false), findsOneWidget); expect(findToggleListIcon(isExpanded: true), findsNothing); } testWidgets('convert > to toggle list, and click the icon to close it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a toggle list const text = 'This is a toggle list sample'; await tester.ime.insertText('> $text'); final editorState = tester.editor.getCurrentEditorState(); final toggleList = editorState.document.nodeAtPath([0])!; expect( toggleList.type, ToggleListBlockKeys.type, ); expect( toggleList.attributes[ToggleListBlockKeys.collapsed], false, ); expect( toggleList.delta!.toPlainText(), text, ); // Simulate pressing enter key to move the cursor to the next line await tester.ime.insertCharacter('\n'); const text2 = 'This is a child node'; await tester.ime.insertText(text2); expect(find.text(text2, findRichText: true), findsOneWidget); // Click the toggle list icon to close it final toggleListIcon = find.byIcon(Icons.arrow_right); await tester.tapButton(toggleListIcon); // expect the toggle list to be closed expect(find.text(text2, findRichText: true), findsNothing); }); testWidgets('press enter key when the toggle list is closed', (tester) async { // if the toggle list is closed, press enter key will insert a new toggle list after it await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a toggle list const text = 'Hello AppFlowy'; await tester.ime.insertText('> $text'); // Click the toggle list icon to close it final toggleListIcon = find.byIcon(Icons.arrow_right); await tester.tapButton(toggleListIcon); // Press the enter key await tester.editor.updateSelection( Selection.collapsed( Position(path: [0], offset: 'Hello '.length), ), ); await tester.ime.insertCharacter('\n'); final editorState = tester.editor.getCurrentEditorState(); final node0 = editorState.getNodeAtPath([0])!; final node1 = editorState.getNodeAtPath([1])!; expect(node0.type, ToggleListBlockKeys.type); expect(node0.attributes[ToggleListBlockKeys.collapsed], true); expect(node0.delta!.toPlainText(), 'Hello '); expect(node1.type, ToggleListBlockKeys.type); expect(node1.delta!.toPlainText(), 'AppFlowy'); }); testWidgets('press enter key when the toggle list is open', (tester) async { // if the toggle list is open, press enter key will insert a new paragraph inside it await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a toggle list const text = 'Hello AppFlowy'; await tester.ime.insertText('> $text'); // Press the enter key await tester.editor.updateSelection( Selection.collapsed( Position(path: [0], offset: 'Hello '.length), ), ); await tester.ime.insertCharacter('\n'); final editorState = tester.editor.getCurrentEditorState(); final node0 = editorState.getNodeAtPath([0])!; final node00 = editorState.getNodeAtPath([0, 0])!; final node1 = editorState.getNodeAtPath([1]); expect(node0.type, ToggleListBlockKeys.type); expect(node0.attributes[ToggleListBlockKeys.collapsed], false); expect(node0.delta!.toPlainText(), 'Hello '); expect(node00.type, ParagraphBlockKeys.type); expect(node00.delta!.toPlainText(), 'AppFlowy'); expect(node1, isNull); }); testWidgets('clear the format if toggle list if empty', (tester) async { // if the toggle list is open, press enter key will insert a new paragraph inside it await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a toggle list await tester.ime.insertText('> '); // Press the enter key // Click the toggle list icon to close it final toggleListIcon = find.byIcon(Icons.arrow_right); await tester.tapButton(toggleListIcon); await tester.editor .updateSelection(Selection.collapsed(Position(path: [0]))); await tester.ime.insertCharacter('\n'); final editorState = tester.editor.getCurrentEditorState(); final node0 = editorState.getNodeAtPath([0])!; expect(node0.type, ParagraphBlockKeys.type); }); testWidgets('use cmd/ctrl + enter to open/close the toggle list', (tester) async { // if the toggle list is open, press enter key will insert a new paragraph inside it await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a toggle list await tester.ime.insertText('> Hello'); expectToggleListOpened(); await tester.editor.updateSelection( Selection.collapsed( Position(path: [0]), ), ); await tester.simulateKeyEvent( LogicalKeyboardKey.enter, isMetaPressed: Platform.isMacOS, isControlPressed: Platform.isLinux || Platform.isWindows, ); expectToggleListClosed(); await tester.simulateKeyEvent( LogicalKeyboardKey.enter, isMetaPressed: Platform.isMacOS, isControlPressed: Platform.isLinux || Platform.isWindows, ); expectToggleListOpened(); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_codeblock_paste_test.dart
import 'dart:io'; import 'package:flutter/services.dart'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('paste in codeblock', () { testWidgets('paste multiple lines in codeblock', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // mock the clipboard const lines = 3; final text = List.generate(lines, (index) => 'line $index').join('\n'); AppFlowyClipboard.mockSetData(AppFlowyClipboardData(text: text)); await insertCodeBlockInDocument(tester); // paste the text await tester.simulateKeyEvent( LogicalKeyboardKey.keyV, isControlPressed: Platform.isLinux || Platform.isWindows, isMetaPressed: Platform.isMacOS, ); await tester.pumpAndSettle(); final editorState = tester.editor.getCurrentEditorState(); expect(editorState.document.root.children.length, 1); expect( editorState.getNodeAtPath([0])!.delta!.toPlainText(), text, ); }); }); } /// Inserts an codeBlock in the document Future<void> insertCodeBlockInDocument(WidgetTester tester) async { // open the actions menu and insert the codeBlock await tester.editor.showSlashMenu(); await tester.editor.tapSlashMenuItemWithName( LocaleKeys.document_selectionMenu_codeBlock.tr(), ); await tester.pumpAndSettle(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_create_and_delete_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('create and delete the document', () { testWidgets('create a new document when launching app in first time', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // expect to see a new document tester.expectToSeePageName( LocaleKeys.menuAppHeader_defaultNewPageName.tr(), ); // and with one paragraph block expect(find.byType(ParagraphBlockComponentWidget), findsOneWidget); }); testWidgets('delete the readme page and restore it', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // delete the readme page await tester.hoverOnPageName( gettingStarted, onHover: () async => tester.tapDeletePageButton(), ); // the banner should show up and the readme page should be gone tester.expectToSeeDocumentBanner(); tester.expectNotToSeePageName(gettingStarted); // restore the readme page await tester.tapRestoreButton(); // the banner should be gone and the readme page should be back tester.expectNotToSeeDocumentBanner(); tester.expectToSeePageName(gettingStarted); }); testWidgets('delete the readme page and delete it permanently', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // delete the readme page await tester.hoverOnPageName( gettingStarted, onHover: () async => tester.tapDeletePageButton(), ); // the banner should show up and the readme page should be gone tester.expectToSeeDocumentBanner(); tester.expectNotToSeePageName(gettingStarted); // delete the page permanently await tester.tapDeletePermanentlyButton(); // the banner should be gone and the readme page should be gone tester.expectNotToSeeDocumentBanner(); tester.expectNotToSeePageName(gettingStarted); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_text_direction_test.dart
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('text direction', () { testWidgets( '''no text direction items will be displayed in the default/LTR mode, and three text direction items will be displayed when toggle is enabled.''', (tester) async { // combine the two tests into one to avoid the time-consuming process of initializing the app await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); final selection = Selection.single( path: [0], startOffset: 0, endOffset: 1, ); // click the first line of the readme await tester.editor.tapLineOfEditorAt(0); await tester.editor.updateSelection(selection); await tester.pumpAndSettle(); // because this icons are defined in the appflowy_editor package, we can't fetch the icons by SVG data. [textDirectionItems] final textDirectionIconNames = [ 'toolbar/text_direction_auto', 'toolbar/text_direction_ltr', 'toolbar/text_direction_rtl', ]; // no text direction items by default var button = find.byWidgetPredicate( (widget) => widget is SVGIconItemWidget && textDirectionIconNames.contains(widget.iconName), ); expect(button, findsNothing); // switch to the RTL mode await tester.toggleEnableRTLToolbarItems(); await tester.editor.tapLineOfEditorAt(0); await tester.editor.updateSelection(selection); await tester.pumpAndSettle(); button = find.byWidgetPredicate( (widget) => widget is SVGIconItemWidget && textDirectionIconNames.contains(widget.iconName), ); expect(button, findsNWidgets(3)); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_option_action_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // +, ... button beside the block component. group('document with option action button', () { testWidgets( 'click + to add a block after current selection, and click + and option key to add a block before current selection', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); var editorState = tester.editor.getCurrentEditorState(); expect(editorState.getNodeAtPath([1])?.delta?.toPlainText(), isNotEmpty); // add a new block after the current selection await tester.editor.hoverAndClickOptionAddButton([0], false); // await tester.pumpAndSettle(); expect(editorState.getNodeAtPath([1])?.delta?.toPlainText(), isEmpty); // cancel the selection menu await tester.tapAt(Offset.zero); await tester.editor.hoverAndClickOptionAddButton([0], true); await tester.pumpAndSettle(); expect(editorState.getNodeAtPath([0])?.delta?.toPlainText(), isEmpty); // cancel the selection menu await tester.tapAt(Offset.zero); await tester.tapAt(Offset.zero); await tester.createNewPageWithNameUnderParent(name: 'test'); await tester.openPage(gettingStarted); // check the status again editorState = tester.editor.getCurrentEditorState(); expect(editorState.getNodeAtPath([0])?.delta?.toPlainText(), isEmpty); expect(editorState.getNodeAtPath([2])?.delta?.toPlainText(), isEmpty); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_inline_math_equation_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized(); group('inline math equation in document', () { testWidgets('insert an inline math equation', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent( name: 'math equation', ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a inline page const formula = 'E = MC ^ 2'; await tester.ime.insertText(formula); await tester.editor.updateSelection( Selection.single(path: [0], startOffset: 0, endOffset: formula.length), ); // tap the inline math equation button final inlineMathEquationButton = find.byTooltip( LocaleKeys.document_plugins_createInlineMathEquation.tr(), ); await tester.tapButton(inlineMathEquationButton); // expect to see the math equation block final inlineMathEquation = find.byType(InlineMathEquation); expect(inlineMathEquation, findsOneWidget); // tap it and update the content await tester.tapButton(inlineMathEquation); final textFormField = find.descendant( of: find.byType(MathInputTextField), matching: find.byType(TextFormField), ); const newFormula = 'E = MC ^ 3'; await tester.enterText(textFormField, newFormula); await tester.tapButton( find.descendant( of: find.byType(MathInputTextField), matching: find.byType(FlowyButton), ), ); await tester.pumpAndSettle(); }); testWidgets('remove the inline math equation format', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent( name: 'math equation', ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a inline page const formula = 'E = MC ^ 2'; await tester.ime.insertText(formula); await tester.editor.updateSelection( Selection.single(path: [0], startOffset: 0, endOffset: formula.length), ); // tap the inline math equation button var inlineMathEquationButton = find.byTooltip( LocaleKeys.document_plugins_createInlineMathEquation.tr(), ); await tester.tapButton(inlineMathEquationButton); // expect to see the math equation block var inlineMathEquation = find.byType(InlineMathEquation); expect(inlineMathEquation, findsOneWidget); // highlight the math equation block await tester.editor.updateSelection( Selection.single(path: [0], startOffset: 0, endOffset: 1), ); // expect to the see the inline math equation button is highlighted inlineMathEquationButton = find.byWidgetPredicate( (widget) => widget is SVGIconItemWidget && widget.tooltip == LocaleKeys.document_plugins_createInlineMathEquation.tr(), ); expect( tester.widget<SVGIconItemWidget>(inlineMathEquationButton).isHighlight, isTrue, ); // cancel the format await tester.tapButton(inlineMathEquationButton); // expect to see the math equation block is removed inlineMathEquation = find.byType(InlineMathEquation); expect(inlineMathEquation, findsNothing); tester.expectToSeeText(formula); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_database_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/database/board/presentation/board_page.dart'; import 'package:appflowy/plugins/database/calendar/presentation/calendar_page.dart'; import 'package:appflowy/plugins/database/grid/presentation/grid_page.dart'; import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/text.dart'; import 'package:appflowy/plugins/inline_actions/widgets/inline_actions_handler.dart'; import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/uuid.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('database view in document', () { testWidgets('insert a referenced grid', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertReferenceDatabase(tester, ViewLayoutPB.Grid); // validate the referenced grid is inserted expect( find.descendant( of: find.byType(AppFlowyEditor), matching: find.byType(GridPage), ), findsOneWidget, ); // https://github.com/AppFlowy-IO/AppFlowy/issues/3533 // test: the selection of editor should be clear when editing the grid await tester.editor.updateSelection( Selection.collapsed( Position(path: [1]), ), ); final gridTextCell = find.byType(EditableTextCell).first; await tester.tapButton(gridTextCell); expect(tester.editor.getCurrentEditorState().selection, isNull); }); testWidgets('insert a referenced board', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertReferenceDatabase(tester, ViewLayoutPB.Board); // validate the referenced board is inserted expect( find.descendant( of: find.byType(AppFlowyEditor), matching: find.byType(BoardPage), ), findsOneWidget, ); }); testWidgets('insert a referenced calendar', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await insertReferenceDatabase(tester, ViewLayoutPB.Calendar); // validate the referenced grid is inserted expect( find.descendant( of: find.byType(AppFlowyEditor), matching: find.byType(CalendarPage), ), findsOneWidget, ); }); testWidgets('create a grid inside a document', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await createInlineDatabase(tester, ViewLayoutPB.Grid); // validate the inline grid is created expect( find.descendant( of: find.byType(AppFlowyEditor), matching: find.byType(GridPage), ), findsOneWidget, ); }); testWidgets('create a board inside a document', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await createInlineDatabase(tester, ViewLayoutPB.Board); // validate the inline board is created expect( find.descendant( of: find.byType(AppFlowyEditor), matching: find.byType(BoardPage), ), findsOneWidget, ); }); testWidgets('create a calendar inside a document', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await createInlineDatabase(tester, ViewLayoutPB.Calendar); // validate the inline calendar is created expect( find.descendant( of: find.byType(AppFlowyEditor), matching: find.byType(CalendarPage), ), findsOneWidget, ); }); }); } /// Insert a referenced database of [layout] into the document Future<void> insertReferenceDatabase( WidgetTester tester, ViewLayoutPB layout, ) async { // create a new grid final id = uuid(); final name = '${layout.name}_$id'; await tester.createNewPageWithNameUnderParent( name: name, layout: layout, openAfterCreated: false, ); // create a new document await tester.createNewPageWithNameUnderParent( name: 'insert_a_reference_${layout.name}', ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a referenced view await tester.editor.showSlashMenu(); await tester.editor.tapSlashMenuItemWithName( layout.referencedMenuName, ); final linkToPageMenu = find.byType(InlineActionsHandler); expect(linkToPageMenu, findsOneWidget); final referencedDatabase = find.descendant( of: linkToPageMenu, matching: find.findTextInFlowyText(name), ); expect(referencedDatabase, findsOneWidget); await tester.tapButton(referencedDatabase); } Future<void> createInlineDatabase( WidgetTester tester, ViewLayoutPB layout, ) async { // create a new document final documentName = 'insert_a_inline_${layout.name}'; await tester.createNewPageWithNameUnderParent( name: documentName, ); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a referenced view await tester.editor.showSlashMenu(); final name = switch (layout) { ViewLayoutPB.Grid => LocaleKeys.document_slashMenu_grid_createANewGrid.tr(), ViewLayoutPB.Board => LocaleKeys.document_slashMenu_board_createANewBoard.tr(), ViewLayoutPB.Calendar => LocaleKeys.document_slashMenu_calendar_createANewCalendar.tr(), _ => '', }; await tester.editor.tapSlashMenuItemWithName( name, ); await tester.pumpAndSettle(); final childViews = tester .widget<SingleInnerViewItem>(tester.findPageName(documentName)) .view .childViews; expect(childViews.length, 1); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/document/document_with_link_test.dart
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('test editing link in document', () { late MockUrlLauncher mock; setUp(() { mock = MockUrlLauncher(); UrlLauncherPlatform.instance = mock; }); testWidgets('insert/edit/open link', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); // create a new document await tester.createNewPageWithNameUnderParent(); // tap the first line of the document await tester.editor.tapLineOfEditorAt(0); // insert a inline page const link = 'AppFlowy'; await tester.ime.insertText(link); await tester.editor.updateSelection( Selection.single(path: [0], startOffset: 0, endOffset: link.length), ); // tap the link button final linkButton = find.byTooltip( 'Link', ); await tester.tapButton(linkButton); expect(find.text('Add your link', findRichText: true), findsOneWidget); // input the link const url = 'https://appflowy.io'; final textField = find.byWidgetPredicate( (widget) => widget is TextField && widget.decoration!.hintText == 'URL', ); await tester.enterText(textField, url); await tester.testTextInput.receiveAction(TextInputAction.done); await tester.pumpAndSettle(); // single-click the link menu to show the menu await tester.tapButton(find.text(link, findRichText: true)); expect(find.text('Open link', findRichText: true), findsOneWidget); expect(find.text('Copy link', findRichText: true), findsOneWidget); expect(find.text('Remove link', findRichText: true), findsOneWidget); // double-click the link menu to open the link mock ..setLaunchExpectations( url: url, useSafariVC: false, useWebView: false, universalLinksOnly: false, enableJavaScript: true, enableDomStorage: true, headers: <String, String>{}, webOnlyWindowName: null, launchMode: PreferredLaunchMode.platformDefault, ) ..setResponse(true); await tester.simulateKeyEvent(LogicalKeyboardKey.escape); await tester.doubleTapAt( tester.getTopLeft(find.text(link, findRichText: true)).translate(5, 5), ); expect(mock.canLaunchCalled, isTrue); expect(mock.launchCalled, isTrue); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/settings/settings_runner.dart
import 'package:integration_test/integration_test.dart'; import 'notifications_settings_test.dart' as notifications_settings_test; import 'user_language_test.dart' as user_language_test; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); notifications_settings_test.main(); user_language_test.main(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/settings/notifications_settings_test.dart
import 'package:appflowy/workspace/application/settings/settings_dialog_bloc.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('board add row test', () { testWidgets('Add card from header', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.openSettings(); await tester.openSettingsPage(SettingsPage.notifications); await tester.pumpAndSettle(); final switchFinder = find.byType(Switch); // Defaults to enabled Switch switchWidget = tester.widget(switchFinder); expect(switchWidget.value, true); // Disable await tester.tap(switchFinder); await tester.pumpAndSettle(); switchWidget = tester.widget(switchFinder); expect(switchWidget.value, false); // Enable again await tester.tap(switchFinder); await tester.pumpAndSettle(); switchWidget = tester.widget(switchFinder); expect(switchWidget.value, true); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/settings/user_language_test.dart
import 'dart:ui'; import 'package:appflowy/workspace/application/settings/prelude.dart'; import 'package:appflowy/workspace/presentation/settings/widgets/settings_language_view.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Settings: user language tests', () { testWidgets('select language, language changed', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.expectToSeeHomePageWithGetStartedPage(); await tester.openSettings(); await tester.openSettingsPage(SettingsPage.language); final userLanguageFinder = find.descendant( of: find.byType(SettingsLanguageView), matching: find.byType(LanguageSelector), ); // Grab current locale LanguageSelector userLanguage = tester.widget<LanguageSelector>(userLanguageFinder); Locale currentLocale = userLanguage.currentLocale; // Open language selector await tester.tap(userLanguageFinder); await tester.pumpAndSettle(); // Select first option that isn't default await tester.tap(find.byType(LanguageItem).at(1)); await tester.pumpAndSettle(); // Make sure the new locale is not the same as previous one userLanguage = tester.widget<LanguageSelector>(userLanguageFinder); expect( userLanguage.currentLocale, isNot(equals(currentLocale)), reason: "new language shouldn't equal the previous selected language", ); // Update the current locale to a new one currentLocale = userLanguage.currentLocale; // Tried the same flow for the second time // Open language selector await tester.tap(userLanguageFinder); await tester.pumpAndSettle(); // Select second option that isn't default await tester.tap(find.byType(LanguageItem).at(2)); await tester.pumpAndSettle(); // Make sure the new locale is not the same as previous one userLanguage = tester.widget<LanguageSelector>(userLanguageFinder); expect( userLanguage.currentLocale, isNot(equals(currentLocale)), reason: "new language shouldn't equal the previous selected language", ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/board/board_test_runner.dart
import 'package:integration_test/integration_test.dart'; import 'board_row_test.dart' as board_row_test; import 'board_add_row_test.dart' as board_add_row_test; import 'board_group_test.dart' as board_group_test; void startTesting() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); // Board integration tests board_row_test.main(); board_add_row_test.main(); board_group_test.main(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/board/board_hide_groups_test.dart
import 'package:appflowy/generated/flowy_svgs.g.dart'; import 'package:appflowy/plugins/database/board/presentation/widgets/board_column_header.dart'; import 'package:appflowy/plugins/database/board/presentation/widgets/board_hidden_groups.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('board group options:', () { testWidgets('expand/collapse hidden groups', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); final collapseFinder = find.byFlowySvg(FlowySvgs.pull_left_outlined_s); final expandFinder = find.byFlowySvg(FlowySvgs.hamburger_s_s); // Is expanded by default expect(collapseFinder, findsOneWidget); expect(expandFinder, findsNothing); // Collapse hidden groups await tester.tap(collapseFinder); await tester.pumpAndSettle(); // Is collapsed expect(collapseFinder, findsNothing); expect(expandFinder, findsOneWidget); // Expand hidden groups await tester.tap(expandFinder); await tester.pumpAndSettle(); // Is expanded expect(collapseFinder, findsOneWidget); expect(expandFinder, findsNothing); }); testWidgets('hide first group, and show it again', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); // Tap the options of the first group final optionsFinder = find .descendant( of: find.byType(BoardColumnHeader), matching: find.byFlowySvg(FlowySvgs.details_horizontal_s), ) .first; await tester.tap(optionsFinder); await tester.pumpAndSettle(); // Tap the hide option await tester.tap(find.byFlowySvg(FlowySvgs.hide_s)); await tester.pumpAndSettle(); int shownGroups = tester.widgetList(find.byType(BoardColumnHeader)).length; // We still show Doing, Done, No Status expect(shownGroups, 3); final hiddenCardFinder = find.byType(HiddenGroupCard); await tester.hoverOnWidget(hiddenCardFinder); await tester.tap(find.byFlowySvg(FlowySvgs.show_m)); await tester.pumpAndSettle(); shownGroups = tester.widgetList(find.byType(BoardColumnHeader)).length; expect(shownGroups, 4); }); }); testWidgets('delete a group', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); expect(tester.widgetList(find.byType(BoardColumnHeader)).length, 4); // tap group option button for the first group. Delete shouldn't show up await tester.tapButton( find .descendant( of: find.byType(BoardColumnHeader), matching: find.byFlowySvg(FlowySvgs.details_horizontal_s), ) .first, ); expect(find.byFlowySvg(FlowySvgs.delete_s), findsNothing); // dismiss the popup await tester.sendKeyEvent(LogicalKeyboardKey.escape); await tester.pumpAndSettle(); // tap group option button for the first group. Delete should show up await tester.tapButton( find .descendant( of: find.byType(BoardColumnHeader), matching: find.byFlowySvg(FlowySvgs.details_horizontal_s), ) .at(1), ); expect(find.byFlowySvg(FlowySvgs.delete_s), findsOneWidget); // Tap the delete button and confirm await tester.tapButton(find.byFlowySvg(FlowySvgs.delete_s)); await tester.tapDialogOkButton(); // Expect number of groups to decrease by one expect(tester.widgetList(find.byType(BoardColumnHeader)).length, 3); }); } extension FlowySvgFinder on CommonFinders { Finder byFlowySvg(FlowySvgData svg) => _FlowySvgFinder(svg); } class _FlowySvgFinder extends MatchFinder { _FlowySvgFinder(this.svg); final FlowySvgData svg; @override String get description => 'flowy_svg "$svg"'; @override bool matches(Element candidate) { final Widget widget = candidate.widget; return widget is FlowySvg && widget.svg == svg; } }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/board/board_row_test.dart
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/database/widgets/card/card.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_board/appflowy_board.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/database_test_op.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('board row test', () { testWidgets('delete item in ToDo card', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); const name = 'Card 1'; final card1 = find.text(name); await tester.hoverOnWidget( card1, onHover: () async { final moreOption = find.byType(MoreCardOptionsAccessory); await tester.tapButton(moreOption); }, ); await tester.tapButtonWithName(LocaleKeys.button_delete.tr()); expect(find.text(name), findsNothing); }); testWidgets('duplicate item in ToDo card', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); const name = 'Card 1'; final card1 = find.text(name); await tester.hoverOnWidget( card1, onHover: () async { final moreOption = find.byType(MoreCardOptionsAccessory); await tester.tapButton(moreOption); }, ); await tester.tapButtonWithName(LocaleKeys.button_duplicate.tr()); expect(find.textContaining(name, findRichText: true), findsNWidgets(2)); }); testWidgets('add new group', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); // assert number of groups tester.assertNumberOfGroups(4); // scroll the board horizontally to ensure add new group button appears await tester.scrollBoardToEnd(); // assert and click on add new group button tester.assertNewGroupTextField(false); await tester.tapNewGroupButton(); tester.assertNewGroupTextField(true); // enter new group name and submit await tester.enterNewGroupName('needs design', submit: true); // assert number of groups has increased tester.assertNumberOfGroups(5); // assert text field has disappeared await tester.scrollBoardToEnd(); tester.assertNewGroupTextField(false); // click on add new group button await tester.tapNewGroupButton(); tester.assertNewGroupTextField(true); // type some things await tester.enterNewGroupName('needs planning', submit: false); // click on clear button and assert empty contents await tester.clearNewGroupTextField(); // press escape to cancel await tester.sendKeyEvent(LogicalKeyboardKey.escape); await tester.pumpAndSettle(); tester.assertNewGroupTextField(false); // click on add new group button await tester.tapNewGroupButton(); tester.assertNewGroupTextField(true); // press elsewhere to cancel await tester.tap(find.byType(AppFlowyBoard)); await tester.pumpAndSettle(); tester.assertNewGroupTextField(false); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/board/board_add_row_test.dart
import 'package:appflowy/generated/flowy_svgs.g.dart'; import 'package:appflowy/plugins/database/board/presentation/widgets/board_column_header.dart'; import 'package:appflowy/plugins/database/widgets/card/container/card_container.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_board/appflowy_board.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import '../../shared/util.dart'; const defaultFirstCardName = 'Card 1'; const defaultLastCardName = 'Card 3'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('board add row test:', () { testWidgets('from header', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); final findFirstCard = find.descendant( of: find.byType(AppFlowyGroupCard), matching: find.byType(Text), ); Text firstCardText = tester.firstWidget(findFirstCard); expect(firstCardText.data, defaultFirstCardName); await tester.tap( find .descendant( of: find.byType(BoardColumnHeader), matching: find.byWidgetPredicate( (widget) => widget is FlowySvg && widget.svg == FlowySvgs.add_s, ), ) .at(1), ); await tester.pumpAndSettle(); const newCardName = 'Card 4'; await tester.enterText( find.descendant( of: find.byType(RowCardContainer), matching: find.byType(TextField), ), newCardName, ); await tester.pumpAndSettle(const Duration(milliseconds: 500)); await tester.tap(find.byType(AppFlowyBoard)); await tester.pumpAndSettle(); firstCardText = tester.firstWidget(findFirstCard); expect(firstCardText.data, newCardName); }); testWidgets('from footer', (tester) async { await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); final findLastCard = find.descendant( of: find.byType(AppFlowyGroupCard), matching: find.byType(Text), ); Text? lastCardText = tester.widgetList(findLastCard).last as Text; expect(lastCardText.data, defaultLastCardName); await tester.tap( find .descendant( of: find.byType(AppFlowyGroupFooter), matching: find.byType(FlowySvg), ) .at(1), ); await tester.pumpAndSettle(); const newCardName = 'Card 4'; await tester.enterText( find.descendant( of: find.byType(RowCardContainer), matching: find.byType(TextField), ), newCardName, ); await tester.pumpAndSettle(const Duration(milliseconds: 500)); await tester.tap(find.byType(AppFlowyBoard)); await tester.pumpAndSettle(); lastCardText = tester.widgetList(findLastCard).last as Text; expect(lastCardText.data, newCardName); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/integration_test/desktop/board/board_group_test.dart
import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart'; import 'package:appflowy/plugins/database/widgets/row/row_property.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:appflowy_board/appflowy_board.dart'; import '../../shared/util.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('board group test', () { testWidgets('move row to another group', (tester) async { const card1Name = 'Card 1'; await tester.initializeAppFlowy(); await tester.tapAnonymousSignInButton(); await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board); final card1 = find.ancestor( of: find.text(card1Name), matching: find.byType(AppFlowyGroupCard), ); final doingGroup = find.text('Doing'); final doingGroupCenter = tester.getCenter(doingGroup); final card1Center = tester.getCenter(card1); await tester.timedDrag( card1, doingGroupCenter.translate(-card1Center.dx, -card1Center.dy), const Duration(seconds: 1), ); await tester.pumpAndSettle(); await tester.tap(card1); await tester.pumpAndSettle(); final card1StatusFinder = find.descendant( of: find.byType(RowPropertyList), matching: find.descendant( of: find.byType(SelectOptionTag), matching: find.byType(Text), ), ); expect(card1StatusFinder, findsNWidgets(1)); final card1StatusText = tester.widget<Text>(card1StatusFinder).data; expect(card1StatusText, 'Doing'); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/util.dart
import 'package:appflowy/startup/launch_configuration.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy/user/application/auth/auth_service.dart'; import 'package:appflowy/user/application/user_service.dart'; import 'package:appflowy/workspace/application/workspace/workspace_service.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/workspace.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'; import 'package:flowy_infra/uuid.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; class AppFlowyUnitTest { late UserProfilePB userProfile; late UserBackendService userService; late WorkspaceService workspaceService; late WorkspacePB workspace; static Future<AppFlowyUnitTest> ensureInitialized() async { TestWidgetsFlutterBinding.ensureInitialized(); SharedPreferences.setMockInitialValues({}); _pathProviderInitialized(); await FlowyRunner.run( AppFlowyApplicationUniTest(), IntegrationMode.unitTest, ); final test = AppFlowyUnitTest(); await test._signIn(); await test._loadWorkspace(); await test._initialServices(); return test; } Future<void> _signIn() async { final authService = getIt<AuthService>(); const password = "AppFlowy123@"; final uid = uuid(); final userEmail = "[email protected]"; final result = await authService.signUp( name: "TestUser", password: password, email: userEmail, ); result.fold( (user) { userProfile = user; userService = UserBackendService(userId: userProfile.id); }, (error) { assert(false, 'Error: $error'); }, ); } WorkspacePB get currentWorkspace => workspace; Future<void> _loadWorkspace() async { final result = await userService.getCurrentWorkspace(); result.fold( (value) => workspace = value, (error) { throw Exception(error); }, ); } Future<void> _initialServices() async { workspaceService = WorkspaceService(workspaceId: currentWorkspace.id); } Future<ViewPB> createWorkspace() async { final result = await workspaceService.createView( name: "Test App", viewSection: ViewSectionPB.Public, ); return result.fold( (app) => app, (error) => throw Exception(error), ); } Future<List<ViewPB>> loadApps() async { final result = await workspaceService.getPublicViews(); return result.fold( (apps) => apps, (error) => throw Exception(error), ); } } void _pathProviderInitialized() { const MethodChannel channel = MethodChannel('plugins.flutter.io/path_provider'); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(channel, (MethodCall methodCall) async { return '.'; }); } class AppFlowyApplicationUniTest implements EntryPoint { @override Widget create(LaunchConfiguration config) { return const SizedBox.shrink(); } } Future<void> blocResponseFuture({int millisecond = 200}) { return Future.delayed(Duration(milliseconds: millisecond)); } Duration blocResponseDuration({int milliseconds = 200}) { return Duration(milliseconds: milliseconds); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/theme_font_family_setting_test.dart
import 'package:flutter/material.dart'; import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart'; import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart'; import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart'; import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance/font_family_setting.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; class MockAppearanceSettingsCubit extends Mock implements AppearanceSettingsCubit {} class MockDocumentAppearanceCubit extends Mock implements DocumentAppearanceCubit {} class MockAppearanceSettingsState extends Mock implements AppearanceSettingsState {} class MockDocumentAppearance extends Mock implements DocumentAppearance {} void main() { late MockAppearanceSettingsCubit appearanceSettingsCubit; late MockDocumentAppearanceCubit documentAppearanceCubit; setUp(() { appearanceSettingsCubit = MockAppearanceSettingsCubit(); when(() => appearanceSettingsCubit.stream).thenAnswer( (_) => Stream.fromIterable([MockAppearanceSettingsState()]), ); documentAppearanceCubit = MockDocumentAppearanceCubit(); when(() => documentAppearanceCubit.stream).thenAnswer( (_) => Stream.fromIterable([MockDocumentAppearance()]), ); }); testWidgets('ThemeFontFamilySetting updates font family on selection', (WidgetTester tester) async { await tester.pumpWidget( MultiBlocProvider( providers: [ BlocProvider<AppearanceSettingsCubit>.value( value: appearanceSettingsCubit, ), BlocProvider<DocumentAppearanceCubit>.value( value: documentAppearanceCubit, ), ], child: MaterialApp( home: MultiBlocProvider( providers: [ BlocProvider<AppearanceSettingsCubit>.value( value: appearanceSettingsCubit, ), BlocProvider<DocumentAppearanceCubit>.value( value: documentAppearanceCubit, ), ], child: const Scaffold( body: ThemeFontFamilySetting( currentFontFamily: builtInFontFamily, ), ), ), ), ), ); final popover = find.byType(AppFlowyPopover); await tester.tap(popover); await tester.pumpAndSettle(); // Verify the initial font family expect(find.text(builtInFontFamily), findsAtLeastNWidgets(1)); when(() => appearanceSettingsCubit.setFontFamily(any<String>())) .thenAnswer((_) async {}); verifyNever(() => appearanceSettingsCubit.setFontFamily(any<String>())); when(() => documentAppearanceCubit.syncFontFamily(any<String>())) .thenAnswer((_) async {}); verifyNever(() => documentAppearanceCubit.syncFontFamily(any<String>())); // Tap on a different font family final abel = find.textContaining('Abel'); await tester.tap(abel); await tester.pumpAndSettle(); // Verify that the font family is updated verify(() => appearanceSettingsCubit.setFontFamily(any<String>())) .called(1); verify(() => documentAppearanceCubit.syncFontFamily(any<String>())) .called(1); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/select_option_text_field_test.dart
import 'dart:collection'; import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_text_field.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import '../bloc_test/grid_test/util.dart'; void main() { setUpAll(() { AppFlowyGridTest.ensureInitialized(); }); group('text_field.dart', () { String submit = ''; String remainder = ''; List<String> select = []; final textController = TextEditingController(); final textField = SelectOptionTextField( options: const [], selectedOptionMap: LinkedHashMap<String, SelectOptionPB>(), distanceToText: 0.0, onSubmitted: () => submit = textController.text, onPaste: (options, remaining) { remainder = remaining; select = options; }, onRemove: (_) {}, newText: (text) => remainder = text, textSeparators: const [','], textController: textController, focusNode: FocusNode(), ); testWidgets('SelectOptionTextField callback outputs', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: Material( child: textField, ), ), ); // test that the input field exists expect(find.byType(TextField), findsOneWidget); // simulate normal input await tester.enterText(find.byType(TextField), 'abcd'); expect(remainder, 'abcd'); await tester.enterText(find.byType(TextField), ' '); expect(remainder, ''); // test submit functionality (aka pressing enter) await tester.enterText(find.byType(TextField), 'an option'); await tester.testTextInput.receiveAction(TextInputAction.done); expect(submit, 'an option'); // test inputs containing commas await tester.enterText(find.byType(TextField), 'a a, bbbb , c'); expect(remainder, 'c'); expect(select, ['a a', 'bbbb']); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace/settings/shortcuts_error_view_test.dart
import 'package:appflowy/workspace/presentation/settings/widgets/settings_customize_shortcuts_view.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { group("ShortcutsErrorView", () { testWidgets("displays correctly", (widgetTester) async { await widgetTester.pumpWidget( const MaterialApp( home: ShortcutsErrorView( errorMessage: 'Error occured', ), ), ); expect(find.byType(FlowyText), findsOneWidget); expect(find.byType(FlowyIconButton), findsOneWidget); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace/settings/shortcuts_list_view_test.dart
import 'package:appflowy/workspace/presentation/settings/widgets/settings_customize_shortcuts_view.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { KeyEventResult dummyHandler(EditorState e) => KeyEventResult.handled; final dummyShortcuts = [ CommandShortcutEvent( key: 'Copy', getDescription: () => 'Copy', command: 'ctrl+c', handler: dummyHandler, ), CommandShortcutEvent( key: 'Paste', getDescription: () => 'Paste', command: 'ctrl+v', handler: dummyHandler, ), CommandShortcutEvent( key: 'Undo', getDescription: () => 'Undo', command: 'ctrl+z', handler: dummyHandler, ), CommandShortcutEvent( key: 'Redo', getDescription: () => 'Redo', command: 'ctrl+y', handler: dummyHandler, ), ]; group("ShortcutsListView", () { group("should be displayed correctly", () { testWidgets("with empty shortcut list", (widgetTester) async { await widgetTester.pumpWidget( const MaterialApp( home: ShortcutsListView(shortcuts: []), ), ); expect(find.byType(FlowyText), findsNWidgets(3)); //we expect three text widgets which are keybinding, command, and reset expect(find.byType(ListView), findsOneWidget); expect(find.byType(ShortcutsListTile), findsNothing); }); testWidgets("with 1 item in shortcut list", (widgetTester) async { await widgetTester.pumpWidget( MaterialApp( home: ShortcutsListView(shortcuts: [dummyShortcuts[0]]), ), ); await widgetTester.pumpAndSettle(); expect(find.byType(FlowyText), findsAtLeastNWidgets(3)); expect(find.byType(ListView), findsOneWidget); expect(find.byType(ShortcutsListTile), findsOneWidget); }); testWidgets("with populated shortcut list", (widgetTester) async { await widgetTester.pumpWidget( MaterialApp( home: ShortcutsListView(shortcuts: dummyShortcuts), ), ); expect(find.byType(FlowyText), findsAtLeastNWidgets(3)); expect(find.byType(ListView), findsOneWidget); expect( find.byType(ShortcutsListTile), findsNWidgets(dummyShortcuts.length), ); }); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace/settings/shortcuts_list_tile_test.dart
import 'package:appflowy/workspace/presentation/settings/widgets/settings_customize_shortcuts_view.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { KeyEventResult dummyHandler(EditorState e) => KeyEventResult.handled; final shortcut = CommandShortcutEvent( key: 'Copy', getDescription: () => 'Copy', command: 'ctrl+c', handler: dummyHandler, ); group("ShortcutsListTile", () { group( "should be displayed correctly", () { testWidgets('with key and command', (widgetTester) async { final sKey = Key(shortcut.key); await widgetTester.pumpWidget( MaterialApp( home: ShortcutsListTile(shortcutEvent: shortcut), ), ); final commandTextFinder = find.byKey(sKey); final foundCommand = widgetTester.widget<FlowyText>(commandTextFinder).text; expect(commandTextFinder, findsOneWidget); expect(foundCommand, shortcut.key); final btnFinder = find.byType(FlowyTextButton); final foundBtnText = widgetTester.widget<FlowyTextButton>(btnFinder).text; expect(btnFinder, findsOneWidget); expect(foundBtnText, shortcut.command); }); }, ); group( "taps the button", () { testWidgets("opens AlertDialog correctly", (widgetTester) async { await widgetTester.pumpWidget( MaterialApp( home: ShortcutsListTile(shortcutEvent: shortcut), ), ); final btnFinder = find.byType(FlowyTextButton); final foundBtnText = widgetTester.widget<FlowyTextButton>(btnFinder).text; expect(btnFinder, findsOneWidget); expect(foundBtnText, shortcut.command); await widgetTester.tap(btnFinder); await widgetTester.pumpAndSettle(); expect(find.byType(AlertDialog), findsOneWidget); expect(find.byType(KeyboardListener), findsOneWidget); }); testWidgets("updates the text with new key event", (widgetTester) async { await widgetTester.pumpWidget( MaterialApp( home: ShortcutsListTile(shortcutEvent: shortcut), ), ); final btnFinder = find.byType(FlowyTextButton); await widgetTester.tap(btnFinder); await widgetTester.pumpAndSettle(); expect(find.byType(AlertDialog), findsOneWidget); expect(find.byType(KeyboardListener), findsOneWidget); await widgetTester.sendKeyEvent(LogicalKeyboardKey.keyC); expect(find.text('c'), findsOneWidget); }); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/widget_test/workspace/settings/settings_customize_shortcuts_view_test.dart
import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart'; import 'package:appflowy/workspace/presentation/settings/widgets/settings_customize_shortcuts_view.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; // ignore: depend_on_referenced_packages import 'package:mocktail/mocktail.dart'; class MockShortcutsCubit extends MockCubit<ShortcutsState> implements ShortcutsCubit {} void main() { group( "CustomizeShortcutsView", () { group( "should be displayed in ViewState", () { late ShortcutsCubit mockShortcutsCubit; setUp(() { mockShortcutsCubit = MockShortcutsCubit(); }); testWidgets('Initial when cubit emits [ShortcutsStatus.Initial]', (widgetTester) async { when(() => mockShortcutsCubit.state) .thenReturn(const ShortcutsState()); await widgetTester.pumpWidget( BlocProvider.value( value: mockShortcutsCubit, child: const MaterialApp(home: SettingsCustomizeShortcutsView()), ), ); expect(find.byType(CircularProgressIndicator), findsOneWidget); }); testWidgets( 'Updating when cubit emits [ShortcutsStatus.updating]', (widgetTester) async { when(() => mockShortcutsCubit.state).thenReturn( const ShortcutsState(status: ShortcutsStatus.updating), ); await widgetTester.pumpWidget( BlocProvider.value( value: mockShortcutsCubit, child: const MaterialApp(home: SettingsCustomizeShortcutsView()), ), ); expect(find.byType(CircularProgressIndicator), findsOneWidget); }, ); testWidgets( 'Shows ShortcutsList when cubit emits [ShortcutsStatus.success]', (widgetTester) async { KeyEventResult dummyHandler(EditorState e) => KeyEventResult.handled; final dummyShortcuts = <CommandShortcutEvent>[ CommandShortcutEvent( key: 'Copy', getDescription: () => 'Copy', command: 'ctrl+c', handler: dummyHandler, ), CommandShortcutEvent( key: 'Paste', getDescription: () => 'Paste', command: 'ctrl+v', handler: dummyHandler, ), CommandShortcutEvent( key: 'Undo', getDescription: () => 'Undo', command: 'ctrl+z', handler: dummyHandler, ), CommandShortcutEvent( key: 'Redo', getDescription: () => 'Redo', command: 'ctrl+y', handler: dummyHandler, ), ]; when(() => mockShortcutsCubit.state).thenReturn( ShortcutsState( status: ShortcutsStatus.success, commandShortcutEvents: dummyShortcuts, ), ); await widgetTester.pumpWidget( BlocProvider.value( value: mockShortcutsCubit, child: const MaterialApp(home: SettingsCustomizeShortcutsView()), ), ); await widgetTester.pump(); final listViewFinder = find.byType(ShortcutsListView); final foundShortcuts = widgetTester .widget<ShortcutsListView>(listViewFinder) .shortcuts; expect(listViewFinder, findsOneWidget); expect(foundShortcuts, dummyShortcuts); }, ); testWidgets('Shows Error when cubit emits [ShortcutsStatus.failure]', (tester) async { when(() => mockShortcutsCubit.state).thenReturn( const ShortcutsState( status: ShortcutsStatus.failure, ), ); await tester.pumpWidget( BlocProvider.value( value: mockShortcutsCubit, child: const MaterialApp(home: SettingsCustomizeShortcutsView()), ), ); expect(find.byType(ShortcutsErrorView), findsOneWidget); }); }, ); }, ); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/select_option_split_text_input.dart
import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_text_field.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { const textSeparators = [',']; group('split input unit test', () { test('empty input', () { var (submitted, remainder) = splitInput(' ', textSeparators); expect(submitted, []); expect(remainder, ''); (submitted, remainder) = splitInput(', , , ', textSeparators); expect(submitted, []); expect(remainder, ''); }); test('simple input', () { var (submitted, remainder) = splitInput('exampleTag', textSeparators); expect(submitted, []); expect(remainder, 'exampleTag'); (submitted, remainder) = splitInput('tag with longer name', textSeparators); expect(submitted, []); expect(remainder, 'tag with longer name'); (submitted, remainder) = splitInput('trailing space ', textSeparators); expect(submitted, []); expect(remainder, 'trailing space '); }); test('input with commas', () { var (submitted, remainder) = splitInput('a, b, c', textSeparators); expect(submitted, ['a', 'b']); expect(remainder, 'c'); (submitted, remainder) = splitInput('a, b, c, ', textSeparators); expect(submitted, ['a', 'b', 'c']); expect(remainder, ''); (submitted, remainder) = splitInput(',tag 1 ,2nd tag, third tag ', textSeparators); expect(submitted, ['tag 1', '2nd tag']); expect(remainder, 'third tag '); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/editor/share_markdown_test.dart
import 'dart:convert'; import 'package:appflowy/plugins/document/presentation/editor_plugins/parsers/document_markdown_parsers.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { group('share markdown', () { test('math equation', () { const text = ''' { "document":{ "type":"page", "children":[ { "type":"math_equation", "data":{ "math_equation":"E = MC^2" } } ] } } '''; final document = Document.fromJson( Map<String, Object>.from(json.decode(text)), ); final result = documentToMarkdown( document, customParsers: [ const MathEquationNodeParser(), ], ); expect(result, r'$$E = MC^2$$'); }); test('code block', () { const text = ''' { "document":{ "type":"page", "children":[ { "type":"code", "data":{ "delta": [ { "insert": "Some Code" } ] } } ] } } '''; final document = Document.fromJson( Map<String, Object>.from(json.decode(text)), ); final result = documentToMarkdown( document, customParsers: [ const CodeBlockNodeParser(), ], ); expect(result, '```\nSome Code\n```'); }); test('divider', () { const text = ''' { "document":{ "type":"page", "children":[ { "type":"divider" } ] } } '''; final document = Document.fromJson( Map<String, Object>.from(json.decode(text)), ); final result = documentToMarkdown( document, customParsers: [ const DividerNodeParser(), ], ); expect(result, '---\n'); }); test('callout', () { const text = ''' { "document":{ "type":"page", "children":[ { "type":"callout", "data":{ "icon": "😁", "delta": [ { "insert": "Callout" } ] } } ] } } '''; final document = Document.fromJson( Map<String, Object>.from(json.decode(text)), ); final result = documentToMarkdown( document, customParsers: [ const CalloutNodeParser(), ], ); expect(result, '''> 😁 > Callout '''); }); test('toggle list', () { const text = ''' { "document":{ "type":"page", "children":[ { "type":"toggle_list", "data":{ "delta": [ { "insert": "Toggle list" } ] } } ] } } '''; final document = Document.fromJson( Map<String, Object>.from(json.decode(text)), ); final result = documentToMarkdown( document, customParsers: [ const ToggleListNodeParser(), ], ); expect(result, '- Toggle list\n'); }); test('custom image', () { const image = 'https://images.unsplash.com/photo-1694984121999-36d30b67f391?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwzfHx8ZW58MHx8fHx8&auto=format&fit=crop&w=800&q=60'; const text = ''' { "document":{ "type":"page", "children":[ { "type":"image", "data":{ "url": "$image" } } ] } } '''; final document = Document.fromJson( Map<String, Object>.from(json.decode(text)), ); final result = documentToMarkdown( document, customParsers: [ const CustomImageNodeParser(), ], ); expect( result, '![]($image)\n', ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/editor/transaction_adapter_test.dart
import 'package:appflowy/plugins/document/application/editor_transaction_adapter.dart'; import 'package:appflowy_backend/protobuf/flowy-document/protobuf.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { group('TransactionAdapter', () { test('toBlockAction insert node with children operation', () { final editorState = EditorState.blank(); final transaction = editorState.transaction; transaction.insertNode( [0], paragraphNode( children: [ paragraphNode(text: '1', children: [paragraphNode(text: '1.1')]), paragraphNode(text: '2'), paragraphNode(text: '3', children: [paragraphNode(text: '3.1')]), paragraphNode(text: '4'), ], ), ); expect(transaction.operations.length, 1); expect(transaction.operations[0] is InsertOperation, true); final actions = transaction.operations[0].toBlockAction(editorState, ''); expect(actions.length, 7); for (final action in actions) { expect(action.blockActionPB.action, BlockActionTypePB.Insert); } expect( actions[0].blockActionPB.payload.parentId, editorState.document.root.id, reason: '0 - parent id', ); expect( actions[0].blockActionPB.payload.prevId, '', reason: '0 - prev id', ); expect( actions[1].blockActionPB.payload.parentId, actions[0].blockActionPB.payload.block.id, reason: '1 - parent id', ); expect( actions[1].blockActionPB.payload.prevId, '', reason: '1 - prev id', ); expect( actions[2].blockActionPB.payload.parentId, actions[1].blockActionPB.payload.block.id, reason: '2 - parent id', ); expect( actions[2].blockActionPB.payload.prevId, '', reason: '2 - prev id', ); expect( actions[3].blockActionPB.payload.parentId, actions[0].blockActionPB.payload.block.id, reason: '3 - parent id', ); expect( actions[3].blockActionPB.payload.prevId, actions[1].blockActionPB.payload.block.id, reason: '3 - prev id', ); expect( actions[4].blockActionPB.payload.parentId, actions[0].blockActionPB.payload.block.id, reason: '4 - parent id', ); expect( actions[4].blockActionPB.payload.prevId, actions[3].blockActionPB.payload.block.id, reason: '4 - prev id', ); expect( actions[5].blockActionPB.payload.parentId, actions[4].blockActionPB.payload.block.id, reason: '5 - parent id', ); expect( actions[5].blockActionPB.payload.prevId, '', reason: '5 - prev id', ); expect( actions[6].blockActionPB.payload.parentId, actions[0].blockActionPB.payload.block.id, reason: '6 - parent id', ); expect( actions[6].blockActionPB.payload.prevId, actions[4].blockActionPB.payload.block.id, reason: '6 - prev id', ); }); test('toBlockAction insert node before all children nodes', () { final document = Document( root: Node( type: 'page', children: [ paragraphNode(children: [paragraphNode(text: '1')]), ], ), ); final editorState = EditorState(document: document); final transaction = editorState.transaction; transaction.insertNodes([0, 0], [paragraphNode(), paragraphNode()]); expect(transaction.operations.length, 1); expect(transaction.operations[0] is InsertOperation, true); final actions = transaction.operations[0].toBlockAction(editorState, ''); expect(actions.length, 2); for (final action in actions) { expect(action.blockActionPB.action, BlockActionTypePB.Insert); } expect( actions[0].blockActionPB.payload.parentId, editorState.document.root.children.first.id, reason: '0 - parent id', ); expect( actions[0].blockActionPB.payload.prevId, '', reason: '0 - prev id', ); expect( actions[1].blockActionPB.payload.parentId, editorState.document.root.children.first.id, reason: '1 - parent id', ); expect( actions[1].blockActionPB.payload.prevId, actions[0].blockActionPB.payload.block.id, reason: '1 - prev id', ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/editor/editor_migration_test.dart
import 'dart:convert'; import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('editor migration, from v0.1.x to 0.2', () { test('migrate readme', () async { final readme = await rootBundle.loadString('assets/template/readme.json'); final oldDocument = DocumentV0.fromJson(json.decode(readme)); final document = EditorMigration.migrateDocument(readme); expect(document.root.type, 'page'); expect(oldDocument.root.children.length, document.root.children.length); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/editor/editor_style_test.dart
import 'package:flutter/material.dart'; import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart'; import 'package:appflowy/plugins/document/presentation/editor_style.dart'; import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:mocktail/mocktail.dart'; class MockDocumentAppearanceCubit extends Mock implements DocumentAppearanceCubit {} class MockBuildContext extends Mock implements BuildContext {} void main() { WidgetsFlutterBinding.ensureInitialized(); group('EditorStyleCustomizer', () { late EditorStyleCustomizer editorStyleCustomizer; late MockBuildContext mockBuildContext; setUp(() { mockBuildContext = MockBuildContext(); editorStyleCustomizer = EditorStyleCustomizer( context: mockBuildContext, padding: EdgeInsets.zero, ); }); test('baseTextStyle should return the expected TextStyle', () { const fontFamily = 'Roboto'; final result = editorStyleCustomizer.baseTextStyle(fontFamily); expect(result, isA<TextStyle>()); expect(result.fontFamily, 'Roboto_regular'); }); test( 'baseTextStyle should return the default TextStyle when an exception occurs', () { const garbage = 'Garbage'; final result = editorStyleCustomizer.baseTextStyle(garbage); expect(result, isA<TextStyle>()); expect( result.fontFamily, GoogleFonts.getFont(builtInFontFamily).fontFamily, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/algorithm/levenshtein_test.dart
import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance/levenshtein.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { test('Levenshtein distance between identical strings', () { final distance = levenshtein('abc', 'abc'); expect(distance, 0); }); test('Levenshtein distance between strings of different lengths', () { final distance = levenshtein('kitten', 'sitting'); expect(distance, 3); }); test('Levenshtein distance between case-insensitive strings', () { final distance = levenshtein('Hello', 'hello', caseSensitive: false); expect(distance, 0); }); test('Levenshtein distance between strings with substitutions', () { final distance = levenshtein('kitten', 'smtten'); expect(distance, 2); }); test('Levenshtein distance between strings with deletions', () { final distance = levenshtein('kitten', 'kiten'); expect(distance, 1); }); test('Levenshtein distance between strings with insertions', () { final distance = levenshtein('kitten', 'kitxten'); expect(distance, 1); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/theme/theme_test.dart
import 'package:flowy_infra/colorscheme/colorscheme.dart'; import 'package:flowy_infra/plugins/service/location_service.dart'; import 'package:flowy_infra/plugins/service/models/flowy_dynamic_plugin.dart'; import 'package:flowy_infra/plugins/service/plugin_service.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; class MockPluginService implements FlowyPluginService { @override Future<void> addPlugin(FlowyDynamicPlugin plugin) => throw UnimplementedError(); @override Future<FlowyDynamicPlugin?> lookup({required String name}) => throw UnimplementedError(); @override Future<DynamicPluginLibrary> get plugins async => const Iterable.empty(); @override void setLocation(PluginLocationService locationService) => throw UnimplementedError(); } void main() { WidgetsFlutterBinding.ensureInitialized(); group('AppTheme', () { test('fallback theme', () { const theme = AppTheme.fallback; expect(theme.builtIn, true); expect(theme.themeName, BuiltInTheme.defaultTheme); expect(theme.lightTheme, isA<FlowyColorScheme>()); expect(theme.darkTheme, isA<FlowyColorScheme>()); }); test('built-in themes', () { final themes = AppTheme.builtins; expect(themes, isNotEmpty); for (final theme in themes) { expect(theme.builtIn, true); expect( theme.themeName, anyOf([ BuiltInTheme.defaultTheme, BuiltInTheme.dandelion, BuiltInTheme.lavender, BuiltInTheme.lemonade, ]), ); expect(theme.lightTheme, isA<FlowyColorScheme>()); expect(theme.darkTheme, isA<FlowyColorScheme>()); } }); test('fromName returns existing theme', () async { final theme = await AppTheme.fromName( BuiltInTheme.defaultTheme, pluginService: MockPluginService(), ); expect(theme, isNotNull); expect(theme.builtIn, true); expect(theme.themeName, BuiltInTheme.defaultTheme); expect(theme.lightTheme, isA<FlowyColorScheme>()); expect(theme.darkTheme, isA<FlowyColorScheme>()); }); test('fromName throws error for non-existent theme', () async { expect( () async => AppTheme.fromName( 'bogus', pluginService: MockPluginService(), ), throwsArgumentError, ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/settings
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/unit_test/settings/shortcuts/settings_shortcut_service_test.dart
import 'dart:convert'; import 'dart:io' show File; import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_service.dart'; import 'package:appflowy/workspace/application/settings/shortcuts/shortcuts_model.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; // ignore: depend_on_referenced_packages import 'package:file/memory.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { late SettingsShortcutService service; late File mockFile; String shortcutsJson = ''; setUp(() async { final MemoryFileSystem fileSystem = MemoryFileSystem.test(); mockFile = await fileSystem.file("shortcuts.json").create(recursive: true); service = SettingsShortcutService(file: mockFile); shortcutsJson = """{ "commandShortcuts":[ { "key":"move the cursor upward", "command":"alt+arrow up" }, { "key":"move the cursor backward one character", "command":"alt+arrow left" }, { "key":"move the cursor downward", "command":"alt+arrow down" } ] }"""; }); group("Settings Shortcut Service", () { test( "returns default standard shortcuts if file is empty", () async { expect(await service.getCustomizeShortcuts(), []); }, ); test('returns updated shortcut event list from json', () { final commandShortcuts = service.getShortcutsFromJson(shortcutsJson); final cursorUpShortcut = commandShortcuts .firstWhere((el) => el.key == "move the cursor upward"); final cursorDownShortcut = commandShortcuts .firstWhere((el) => el.key == "move the cursor downward"); expect( commandShortcuts.length, 3, ); expect(cursorUpShortcut.command, "alt+arrow up"); expect(cursorDownShortcut.command, "alt+arrow down"); }); test( "saveAllShortcuts saves shortcuts", () async { //updating one of standard command shortcut events. final currentCommandShortcuts = standardCommandShortcutEvents; const kKey = "scroll one page down"; const oldCommand = "page down"; const newCommand = "alt+page down"; final commandShortcutEvent = currentCommandShortcuts .firstWhere((element) => element.key == kKey); expect(commandShortcutEvent.command, oldCommand); //updating the command. commandShortcutEvent.updateCommand( command: newCommand, ); //saving the updated shortcuts await service.saveAllShortcuts(currentCommandShortcuts); //reading from the mock file the saved shortcut list. final savedDataInFile = await mockFile.readAsString(); //Check if the lists where properly converted to JSON and saved. final shortcuts = EditorShortcuts( commandShortcuts: currentCommandShortcuts.toCommandShortcutModelList(), ); expect(jsonEncode(shortcuts.toJson()), savedDataInFile); //now checking if the modified command of "move the cursor upward" is "arrow up" final newCommandShortcuts = service.getShortcutsFromJson(savedDataInFile); final updatedCommandEvent = newCommandShortcuts.firstWhere((el) => el.key == kKey); expect(updatedCommandEvent.command, newCommand); }, ); test('load shortcuts from file', () async { //updating one of standard command shortcut event. const kKey = "scroll one page up"; const oldCommand = "page up"; const newCommand = "alt+page up"; final currentCommandShortcuts = standardCommandShortcutEvents; final commandShortcutEvent = currentCommandShortcuts.firstWhere((element) => element.key == kKey); expect(commandShortcutEvent.command, oldCommand); //updating the command. commandShortcutEvent.updateCommand(command: newCommand); //saving the updated shortcuts await service.saveAllShortcuts(currentCommandShortcuts); //now directly fetching the shortcuts from loadShortcuts final commandShortcuts = await service.getCustomizeShortcuts(); expect( commandShortcuts, currentCommandShortcuts.toCommandShortcutModelList(), ); final updatedCommandEvent = commandShortcuts.firstWhere((el) => el.key == kKey); expect(updatedCommandEvent.command, newCommand); }); test('updateCommandShortcuts works properly', () async { //updating one of standard command shortcut event. const kKey = "move the cursor backward one character"; const oldCommand = "arrow left"; const newCommand = "alt+arrow left"; final currentCommandShortcuts = standardCommandShortcutEvents; //check if the current shortcut event's key is set to old command. final currentCommandEvent = currentCommandShortcuts.firstWhere((el) => el.key == kKey); expect(currentCommandEvent.command, oldCommand); final commandShortcutModelList = EditorShortcuts.fromJson(jsonDecode(shortcutsJson)).commandShortcuts; //now calling the updateCommandShortcuts method await service.updateCommandShortcuts( currentCommandShortcuts, commandShortcutModelList, ); //check if the shortcut event's key is updated. final updatedCommandEvent = currentCommandShortcuts.firstWhere((el) => el.key == kKey); expect(updatedCommandEvent.command, newCommand); }); }); } extension on List<CommandShortcutEvent> { List<CommandShortcutModel> toCommandShortcutModelList() => map((e) => CommandShortcutModel.fromCommandEvent(e)).toList(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/app_setting_test/appearance_test.dart
import 'package:appflowy/user/application/user_settings_service.dart'; import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart'; import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart'; import 'package:appflowy_backend/protobuf/flowy-user/user_setting.pb.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../util.dart'; void main() { // ignore: unused_local_variable late AppFlowyUnitTest context; setUpAll(() async { context = await AppFlowyUnitTest.ensureInitialized(); }); group('$AppearanceSettingsCubit', () { late AppearanceSettingsPB appearanceSetting; late DateTimeSettingsPB dateTimeSettings; setUp(() async { appearanceSetting = await UserSettingsBackendService().getAppearanceSetting(); dateTimeSettings = await UserSettingsBackendService().getDateTimeSettings(); await blocResponseFuture(); }); blocTest<AppearanceSettingsCubit, AppearanceSettingsState>( 'default theme', build: () => AppearanceSettingsCubit( appearanceSetting, dateTimeSettings, AppTheme.fallback, ), verify: (bloc) { expect(bloc.state.font, builtInFontFamily); expect(bloc.state.monospaceFont, 'SF Mono'); expect(bloc.state.themeMode, ThemeMode.system); }, ); blocTest<AppearanceSettingsCubit, AppearanceSettingsState>( 'save key/value', build: () => AppearanceSettingsCubit( appearanceSetting, dateTimeSettings, AppTheme.fallback, ), act: (bloc) { bloc.setKeyValue("123", "456"); }, verify: (bloc) { expect(bloc.getValue("123"), "456"); }, ); blocTest<AppearanceSettingsCubit, AppearanceSettingsState>( 'remove key/value', build: () => AppearanceSettingsCubit( appearanceSetting, dateTimeSettings, AppTheme.fallback, ), act: (bloc) { bloc.setKeyValue("123", null); }, verify: (bloc) { expect(bloc.getValue("123"), null); }, ); blocTest<AppearanceSettingsCubit, AppearanceSettingsState>( 'initial state uses fallback theme', build: () => AppearanceSettingsCubit( appearanceSetting, dateTimeSettings, AppTheme.fallback, ), verify: (bloc) { expect(bloc.state.appTheme.themeName, AppTheme.fallback.themeName); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/app_setting_test/document_appearance_test.dart
import 'package:flutter/widgets.dart'; import 'package:appflowy/core/config/kv_keys.dart'; import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart'; import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); group('DocumentAppearanceCubit', () { late SharedPreferences preferences; late DocumentAppearanceCubit cubit; setUpAll(() async { SharedPreferences.setMockInitialValues({}); }); setUp(() async { preferences = await SharedPreferences.getInstance(); cubit = DocumentAppearanceCubit(); }); tearDown(() async { await preferences.clear(); await cubit.close(); }); test('Initial state', () { expect(cubit.state.fontSize, 16.0); expect(cubit.state.fontFamily, builtInFontFamily); }); test('Fetch document appearance from SharedPreferences', () async { await preferences.setDouble(KVKeys.kDocumentAppearanceFontSize, 18.0); await preferences.setString( KVKeys.kDocumentAppearanceFontFamily, 'Arial', ); await cubit.fetch(); expect(cubit.state.fontSize, 18.0); expect(cubit.state.fontFamily, 'Arial'); }); test('Sync font size to SharedPreferences', () async { await cubit.syncFontSize(20.0); final fontSize = preferences.getDouble(KVKeys.kDocumentAppearanceFontSize); expect(fontSize, 20.0); expect(cubit.state.fontSize, 20.0); }); test('Sync font family to SharedPreferences', () async { await cubit.syncFontFamily('Helvetica'); final fontFamily = preferences.getString(KVKeys.kDocumentAppearanceFontFamily); expect(fontFamily, 'Helvetica'); expect(cubit.state.fontFamily, 'Helvetica'); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/home_test/sidebar_section_bloc_test.dart
import 'package:appflowy/workspace/application/menu/sidebar_sections_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../util.dart'; void main() { late AppFlowyUnitTest testContext; setUpAll(() async { testContext = await AppFlowyUnitTest.ensureInitialized(); }); test('assert initial apps is the build-in app', () async { final menuBloc = SidebarSectionsBloc() ..add( SidebarSectionsEvent.initial( testContext.userProfile, testContext.currentWorkspace.id, ), ); await blocResponseFuture(); assert(menuBloc.state.section.publicViews.length == 1); assert(menuBloc.state.section.privateViews.isEmpty); }); test('create views', () async { final menuBloc = SidebarSectionsBloc() ..add( SidebarSectionsEvent.initial( testContext.userProfile, testContext.currentWorkspace.id, ), ); await blocResponseFuture(); final names = ['View 1', 'View 2', 'View 3']; for (final name in names) { menuBloc.add( SidebarSectionsEvent.createRootViewInSection( name: name, index: 0, viewSection: ViewSectionPB.Public, ), ); await blocResponseFuture(); } final reversedNames = names.reversed.toList(); for (var i = 0; i < names.length; i++) { assert( menuBloc.state.section.publicViews[i].name == reversedNames[i], ); } }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/home_test/view_bloc_test.dart
import 'package:appflowy/plugins/document/application/document_bloc.dart'; import 'package:appflowy/workspace/application/view/view_bloc.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../util.dart'; void main() { const name = 'Hello world'; late AppFlowyUnitTest testContext; setUpAll(() async { testContext = await AppFlowyUnitTest.ensureInitialized(); }); Future<ViewBloc> createTestViewBloc() async { final view = await testContext.createWorkspace(); final viewBloc = ViewBloc(view: view) ..add( const ViewEvent.initial(), ); await blocResponseFuture(); return viewBloc; } test('rename view test', () async { final viewBloc = await createTestViewBloc(); viewBloc.add(const ViewEvent.rename(name)); await blocResponseFuture(); expect(viewBloc.state.view.name, name); }); test('duplicate view test', () async { final viewBloc = await createTestViewBloc(); // create a nested view viewBloc.add( const ViewEvent.createView( name, ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); expect(viewBloc.state.view.childViews.length, 1); final childViewBloc = ViewBloc(view: viewBloc.state.view.childViews.first) ..add( const ViewEvent.initial(), ); childViewBloc.add(const ViewEvent.duplicate()); await blocResponseFuture(); expect(viewBloc.state.view.childViews.length, 2); }); test('delete view test', () async { final viewBloc = await createTestViewBloc(); viewBloc.add( const ViewEvent.createView( name, ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); expect(viewBloc.state.view.childViews.length, 1); final childViewBloc = ViewBloc(view: viewBloc.state.view.childViews.first) ..add( const ViewEvent.initial(), ); await blocResponseFuture(); childViewBloc.add(const ViewEvent.delete()); await blocResponseFuture(); assert(viewBloc.state.view.childViews.isEmpty); }); test('create nested view test', () async { final viewBloc = await createTestViewBloc(); viewBloc.add( const ViewEvent.createView( 'Document 1', ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); final document1Bloc = ViewBloc(view: viewBloc.state.view.childViews.first) ..add( const ViewEvent.initial(), ); await blocResponseFuture(); const name = 'Document 1 - 1'; document1Bloc.add( const ViewEvent.createView( 'Document 1 - 1', ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); expect(document1Bloc.state.view.childViews.length, 1); expect(document1Bloc.state.view.childViews.first.name, name); }); test('create documents in order', () async { final viewBloc = await createTestViewBloc(); final names = ['1', '2', '3']; for (final name in names) { viewBloc.add( ViewEvent.createView( name, ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); } expect(viewBloc.state.view.childViews.length, 3); for (var i = 0; i < names.length; i++) { expect(viewBloc.state.view.childViews[i].name, names[i]); } }); test('open latest view test', () async { final viewBloc = await createTestViewBloc(); expect(viewBloc.state.lastCreatedView, isNull); viewBloc.add( const ViewEvent.createView( '1', ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); expect( viewBloc.state.lastCreatedView!.id, viewBloc.state.view.childViews.last.id, ); expect( viewBloc.state.lastCreatedView!.name, '1', ); viewBloc.add( const ViewEvent.createView( '2', ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); expect( viewBloc.state.lastCreatedView!.name, '2', ); }); test('open latest document test', () async { const name1 = 'document'; final viewBloc = await createTestViewBloc(); viewBloc.add( const ViewEvent.createView( name1, ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); final document = viewBloc.state.lastCreatedView!; assert(document.name == name1); const gird = 'grid'; viewBloc.add( const ViewEvent.createView( gird, ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); assert(viewBloc.state.lastCreatedView!.name == gird); var workspaceSetting = await FolderEventGetCurrentWorkspaceSetting().send().then( (result) => result.fold( (l) => l, (r) => throw Exception(), ), ); workspaceSetting.latestView.id == viewBloc.state.lastCreatedView!.id; // ignore: unused_local_variable final documentBloc = DocumentBloc(view: document) ..add( const DocumentEvent.initial(), ); await blocResponseFuture(); workspaceSetting = await FolderEventGetCurrentWorkspaceSetting().send().then( (result) => result.fold( (l) => l, (r) => throw Exception(), ), ); workspaceSetting.latestView.id == document.id; }); test('create views', () async { final viewBloc = await createTestViewBloc(); const layouts = ViewLayoutPB.values; for (var i = 0; i < layouts.length; i++) { final layout = layouts[i]; viewBloc.add( ViewEvent.createView( 'Test $layout', layout, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); expect(viewBloc.state.view.childViews.length, i + 1); expect(viewBloc.state.view.childViews.last.name, 'Test $layout'); expect(viewBloc.state.view.childViews.last.layout, layout); } }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart
import 'package:appflowy/plugins/trash/application/trash_bloc.dart'; import 'package:appflowy/workspace/application/view/view_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../util.dart'; class TrashTestContext { TrashTestContext(this.unitTest); late ViewPB view; late ViewBloc viewBloc; late List<ViewPB> allViews; final AppFlowyUnitTest unitTest; Future<void> initialize() async { view = await unitTest.createWorkspace(); viewBloc = ViewBloc(view: view)..add(const ViewEvent.initial()); await blocResponseFuture(); viewBloc.add( const ViewEvent.createView( "Document 1", ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); viewBloc.add( const ViewEvent.createView( "Document 2", ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); viewBloc.add( const ViewEvent.createView( "Document 3", ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); allViews = [...viewBloc.state.view.childViews]; assert(allViews.length == 3, 'but receive ${allViews.length}'); } } void main() { late AppFlowyUnitTest unitTest; setUpAll(() async { unitTest = await AppFlowyUnitTest.ensureInitialized(); }); // 1. Create three views // 2. Delete a view and check the state // 3. Delete all views and check the state // 4. Put back a view // 5. Put back all views group('trash test: ', () { test('delete a view', () async { final context = TrashTestContext(unitTest); await context.initialize(); final trashBloc = TrashBloc()..add(const TrashEvent.initial()); await blocResponseFuture(); // delete a view final deletedView = context.viewBloc.state.view.childViews[0]; final deleteViewBloc = ViewBloc(view: deletedView) ..add(const ViewEvent.initial()); await blocResponseFuture(); deleteViewBloc.add(const ViewEvent.delete()); await blocResponseFuture(); assert(context.viewBloc.state.view.childViews.length == 2); assert(trashBloc.state.objects.length == 1); assert(trashBloc.state.objects.first.id == deletedView.id); // put back trashBloc.add(TrashEvent.putback(deletedView.id)); await blocResponseFuture(); assert(context.viewBloc.state.view.childViews.length == 3); assert(trashBloc.state.objects.isEmpty); // delete all views for (final view in context.allViews) { final deleteViewBloc = ViewBloc(view: view) ..add(const ViewEvent.initial()); await blocResponseFuture(); deleteViewBloc.add(const ViewEvent.delete()); await blocResponseFuture(); await blocResponseFuture(); } expect(trashBloc.state.objects[0].id, context.allViews[0].id); expect(trashBloc.state.objects[1].id, context.allViews[1].id); expect(trashBloc.state.objects[2].id, context.allViews[2].id); // delete a view permanently trashBloc.add(TrashEvent.delete(trashBloc.state.objects[0])); await blocResponseFuture(); expect(trashBloc.state.objects.length, 2); // delete all view permanently trashBloc.add(const TrashEvent.deleteAll()); await blocResponseFuture(); assert( trashBloc.state.objects.isEmpty, "but receive ${trashBloc.state.objects.length}", ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/home_test/home_bloc_test.dart
import 'package:appflowy/plugins/document/application/document_bloc.dart'; import 'package:appflowy/workspace/application/home/home_bloc.dart'; import 'package:appflowy/workspace/application/view/view_bloc.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../util.dart'; void main() { late AppFlowyUnitTest testContext; setUpAll(() async { testContext = await AppFlowyUnitTest.ensureInitialized(); }); test('init home screen', () async { final workspaceSetting = await FolderEventGetCurrentWorkspaceSetting() .send() .then((result) => result.fold((l) => l, (r) => throw Exception())); await blocResponseFuture(); final homeBloc = HomeBloc(workspaceSetting)..add(const HomeEvent.initial()); await blocResponseFuture(); assert(homeBloc.state.workspaceSetting.hasLatestView()); }); test('open the document', () async { final workspaceSetting = await FolderEventGetCurrentWorkspaceSetting() .send() .then((result) => result.fold((l) => l, (r) => throw Exception())); await blocResponseFuture(); final homeBloc = HomeBloc(workspaceSetting)..add(const HomeEvent.initial()); await blocResponseFuture(); final app = await testContext.createWorkspace(); final appBloc = ViewBloc(view: app)..add(const ViewEvent.initial()); assert(appBloc.state.lastCreatedView == null); appBloc.add( const ViewEvent.createView( "New document", ViewLayoutPB.Document, section: ViewSectionPB.Public, ), ); await blocResponseFuture(); assert(appBloc.state.lastCreatedView != null); final latestView = appBloc.state.lastCreatedView!; final _ = DocumentBloc(view: latestView) ..add(const DocumentEvent.initial()); await FolderEventSetLatestView(ViewIdPB(value: latestView.id)).send(); await blocResponseFuture(); final actual = homeBloc.state.workspaceSetting.latestView.id; assert(actual == latestView.id); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/shortcuts_test/shortcuts_cubit_test.dart
import 'dart:ffi'; import 'package:appflowy/plugins/document/presentation/editor_page.dart'; import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart'; import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_service.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; // ignore: depend_on_referenced_packages import 'package:mocktail/mocktail.dart'; class MockSettingsShortcutService extends Mock implements SettingsShortcutService {} void main() { group("ShortcutsCubit", () { late SettingsShortcutService service; late ShortcutsCubit shortcutsCubit; setUp(() async { service = MockSettingsShortcutService(); when( () => service.saveAllShortcuts(any()), ).thenAnswer((_) async => true); when( () => service.getCustomizeShortcuts(), ).thenAnswer((_) async => []); when( () => service.updateCommandShortcuts(any(), any()), ).thenAnswer((_) async => Void); shortcutsCubit = ShortcutsCubit(service); }); test('initial state is correct', () { final shortcutsCubit = ShortcutsCubit(service); expect(shortcutsCubit.state, const ShortcutsState()); }); group('fetchShortcuts', () { blocTest<ShortcutsCubit, ShortcutsState>( 'calls getCustomizeShortcuts() once', build: () => shortcutsCubit, act: (cubit) => cubit.fetchShortcuts(), verify: (_) { verify(() => service.getCustomizeShortcuts()).called(1); }, ); blocTest<ShortcutsCubit, ShortcutsState>( 'emits [updating, failure] when getCustomizeShortcuts() throws', setUp: () { when( () => service.getCustomizeShortcuts(), ).thenThrow(Exception('oops')); }, build: () => shortcutsCubit, act: (cubit) => cubit.fetchShortcuts(), expect: () => <dynamic>[ const ShortcutsState(status: ShortcutsStatus.updating), isA<ShortcutsState>() .having((w) => w.status, 'status', ShortcutsStatus.failure), ], ); blocTest<ShortcutsCubit, ShortcutsState>( 'emits [updating, success] when getCustomizeShortcuts() returns shortcuts', build: () => shortcutsCubit, act: (cubit) => cubit.fetchShortcuts(), expect: () => <dynamic>[ const ShortcutsState(status: ShortcutsStatus.updating), isA<ShortcutsState>() .having((w) => w.status, 'status', ShortcutsStatus.success) .having( (w) => w.commandShortcutEvents, 'shortcuts', commandShortcutEvents, ), ], ); }); group('updateShortcut', () { blocTest<ShortcutsCubit, ShortcutsState>( 'calls saveAllShortcuts() once', build: () => shortcutsCubit, act: (cubit) => cubit.updateAllShortcuts(), verify: (_) { verify(() => service.saveAllShortcuts(any())).called(1); }, ); blocTest<ShortcutsCubit, ShortcutsState>( 'emits [updating, failure] when saveAllShortcuts() throws', setUp: () { when( () => service.saveAllShortcuts(any()), ).thenThrow(Exception('oops')); }, build: () => shortcutsCubit, act: (cubit) => cubit.updateAllShortcuts(), expect: () => <dynamic>[ const ShortcutsState(status: ShortcutsStatus.updating), isA<ShortcutsState>() .having((w) => w.status, 'status', ShortcutsStatus.failure), ], ); blocTest<ShortcutsCubit, ShortcutsState>( 'emits [updating, success] when saveAllShortcuts() is successful', build: () => shortcutsCubit, act: (cubit) => cubit.updateAllShortcuts(), expect: () => <dynamic>[ const ShortcutsState(status: ShortcutsStatus.updating), isA<ShortcutsState>() .having((w) => w.status, 'status', ShortcutsStatus.success), ], ); }); group('resetToDefault', () { blocTest<ShortcutsCubit, ShortcutsState>( 'calls saveAllShortcuts() once', build: () => shortcutsCubit, act: (cubit) => cubit.resetToDefault(), verify: (_) { verify(() => service.saveAllShortcuts(any())).called(1); verify(() => service.getCustomizeShortcuts()).called(1); }, ); blocTest<ShortcutsCubit, ShortcutsState>( 'emits [updating, failure] when saveAllShortcuts() throws', setUp: () { when( () => service.saveAllShortcuts(any()), ).thenThrow(Exception('oops')); }, build: () => shortcutsCubit, act: (cubit) => cubit.resetToDefault(), expect: () => <dynamic>[ const ShortcutsState(status: ShortcutsStatus.updating), isA<ShortcutsState>() .having((w) => w.status, 'status', ShortcutsStatus.failure), ], ); blocTest<ShortcutsCubit, ShortcutsState>( 'emits [updating, success] when getCustomizeShortcuts() returns shortcuts', build: () => shortcutsCubit, act: (cubit) => cubit.resetToDefault(), expect: () => <dynamic>[ const ShortcutsState(status: ShortcutsStatus.updating), isA<ShortcutsState>() .having((w) => w.status, 'status', ShortcutsStatus.success) .having( (w) => w.commandShortcutEvents, 'shortcuts', commandShortcutEvents, ), ], ); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/grid_bloc_test.dart
import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/grid/application/grid_bloc.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'util.dart'; void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); group('Edit Grid:', () { late GridTestContext context; setUp(() async { context = await gridTest.createTestGrid(); }); // The initial number of rows is 3 for each grid // We create one row so we expect 4 rows blocTest<GridBloc, GridState>( "create a row", build: () => GridBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const GridEvent.initial()), act: (bloc) => bloc.add(const GridEvent.createRow()), wait: const Duration(milliseconds: 300), verify: (bloc) { assert(bloc.state.rowInfos.length == 4); }, ); blocTest<GridBloc, GridState>( "delete the last row", build: () => GridBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const GridEvent.initial()), act: (bloc) async { await gridResponseFuture(); bloc.add(GridEvent.deleteRow(bloc.state.rowInfos.last)); }, wait: const Duration(milliseconds: 300), verify: (bloc) { assert( bloc.state.rowInfos.length == 2, "Expected 2, but receive ${bloc.state.rowInfos.length}", ); }, ); String? firstId; String? secondId; String? thirdId; blocTest( 'reorder rows', build: () => GridBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const GridEvent.initial()), act: (bloc) async { await gridResponseFuture(); firstId = bloc.state.rowInfos[0].rowId; secondId = bloc.state.rowInfos[1].rowId; thirdId = bloc.state.rowInfos[2].rowId; bloc.add(const GridEvent.moveRow(0, 2)); }, verify: (bloc) { expect(secondId, bloc.state.rowInfos[0].rowId); expect(thirdId, bloc.state.rowInfos[1].rowId); expect(firstId, bloc.state.rowInfos[2].rowId); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart'; import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart'; import 'package:appflowy/plugins/database/application/field/field_controller.dart'; import 'package:appflowy/plugins/database/application/field/field_editor_bloc.dart'; import 'package:appflowy/plugins/database/application/field/field_info.dart'; import 'package:appflowy/plugins/database/domain/field_service.dart'; import 'package:appflowy/plugins/database/application/row/row_cache.dart'; import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/application/row/row_service.dart'; import 'package:appflowy/workspace/application/view/view_service.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import '../../util.dart'; class GridTestContext { GridTestContext(this.gridView, this.gridController); final ViewPB gridView; final DatabaseController gridController; List<RowInfo> get rowInfos { return gridController.rowCache.rowInfos; } List<FieldInfo> get fieldInfos => fieldController.fieldInfos; FieldController get fieldController { return gridController.fieldController; } Future<FieldEditorBloc> createField(FieldType fieldType) async { final editorBloc = await createFieldEditor(databaseController: gridController); await gridResponseFuture(); editorBloc.add(FieldEditorEvent.switchFieldType(fieldType)); await gridResponseFuture(); return Future(() => editorBloc); } FieldInfo singleSelectFieldContext() { final fieldInfo = fieldInfos .firstWhere((element) => element.fieldType == FieldType.SingleSelect); return fieldInfo; } FieldInfo textFieldContext() { final fieldInfo = fieldInfos .firstWhere((element) => element.fieldType == FieldType.RichText); return fieldInfo; } FieldInfo checkboxFieldContext() { final fieldInfo = fieldInfos .firstWhere((element) => element.fieldType == FieldType.Checkbox); return fieldInfo; } SelectOptionCellController makeSelectOptionCellController( FieldType fieldType, int rowIndex, ) { assert( fieldType == FieldType.SingleSelect || fieldType == FieldType.MultiSelect, ); final field = fieldInfos.firstWhere((fieldInfo) => fieldInfo.fieldType == fieldType); return makeCellController( gridController, CellContext(fieldId: field.id, rowId: rowInfos[rowIndex].rowId), ).as(); } TextCellController makeTextCellController(int rowIndex) { final field = fieldInfos .firstWhere((element) => element.fieldType == FieldType.RichText); return makeCellController( gridController, CellContext(fieldId: field.id, rowId: rowInfos[rowIndex].rowId), ).as(); } CheckboxCellController makeCheckboxCellController(int rowIndex) { final field = fieldInfos .firstWhere((element) => element.fieldType == FieldType.Checkbox); return makeCellController( gridController, CellContext(fieldId: field.id, rowId: rowInfos[rowIndex].rowId), ).as(); } } Future<FieldEditorBloc> createFieldEditor({ required DatabaseController databaseController, }) async { final result = await FieldBackendService.createField( viewId: databaseController.viewId, ); await gridResponseFuture(); return result.fold( (field) { return FieldEditorBloc( viewId: databaseController.viewId, fieldController: databaseController.fieldController, field: field, ); }, (err) => throw Exception(err), ); } /// Create a empty Grid for test class AppFlowyGridTest { AppFlowyGridTest({required this.unitTest}); final AppFlowyUnitTest unitTest; static Future<AppFlowyGridTest> ensureInitialized() async { final inner = await AppFlowyUnitTest.ensureInitialized(); return AppFlowyGridTest(unitTest: inner); } Future<GridTestContext> createTestGrid() async { final app = await unitTest.createWorkspace(); final context = await ViewBackendService.createView( parentViewId: app.id, name: "Test Grid", layoutType: ViewLayoutPB.Grid, openAfterCreate: true, ).then((result) { return result.fold( (view) async { final context = GridTestContext( view, DatabaseController(view: view), ); final result = await context.gridController.open(); result.fold((l) => null, (r) => throw Exception(r)); return context; }, (error) { throw Exception(); }, ); }); return context; } } /// Create a new Grid for cell test class AppFlowyGridCellTest { AppFlowyGridCellTest({required this.gridTest}); late GridTestContext context; final AppFlowyGridTest gridTest; static Future<AppFlowyGridCellTest> ensureInitialized() async { final gridTest = await AppFlowyGridTest.ensureInitialized(); return AppFlowyGridCellTest(gridTest: gridTest); } Future<void> createTestGrid() async { context = await gridTest.createTestGrid(); } Future<void> createTestRow() async { await RowBackendService.createRow(viewId: context.gridView.id); } SelectOptionCellController makeSelectOptionCellController( FieldType fieldType, int rowIndex, ) => context.makeSelectOptionCellController(fieldType, rowIndex); } Future<void> gridResponseFuture({int milliseconds = 200}) { return Future.delayed(gridResponseDuration(milliseconds: milliseconds)); } Duration gridResponseDuration({int milliseconds = 200}) { return Duration(milliseconds: milliseconds); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/cell/select_option_cell_test.dart
import 'package:appflowy/plugins/database/application/cell/bloc/select_option_cell_editor_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/select_option_entities.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; void main() { late AppFlowyGridCellTest cellTest; setUpAll(() async { cellTest = await AppFlowyGridCellTest.ensureInitialized(); }); group('SingleSelectOptionBloc', () { test('create options', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); expect(bloc.state.options.length, 1); expect(bloc.state.options[0].name, "A"); }); test('update options', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); final SelectOptionPB optionUpdate = bloc.state.options[0] ..color = SelectOptionColorPB.Aqua ..name = "B"; bloc.add(SelectOptionCellEditorEvent.updateOption(optionUpdate)); expect(bloc.state.options.length, 1); expect(bloc.state.options[0].name, "B"); expect(bloc.state.options[0].color, SelectOptionColorPB.Aqua); }); test('delete options', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); assert( bloc.state.options.length == 1, "Expect 1 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}", ); bloc.add(const SelectOptionCellEditorEvent.filterOption("B")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); assert( bloc.state.options.length == 2, "Expect 2 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}", ); bloc.add(const SelectOptionCellEditorEvent.filterOption("C")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); assert( bloc.state.options.length == 3, "Expect 3 but receive ${bloc.state.options.length}. Options: ${bloc.state.options}", ); bloc.add(SelectOptionCellEditorEvent.deleteOption(bloc.state.options[0])); await gridResponseFuture(); assert( bloc.state.options.length == 2, "Expect 2 but receive ${bloc.state.options.length}. Options: ${bloc.state.options}", ); bloc.add(const SelectOptionCellEditorEvent.deleteAllOptions()); await gridResponseFuture(); assert( bloc.state.options.isEmpty, "Expect empty but receive ${bloc.state.options.length}. Options: ${bloc.state.options}", ); }); test('select/unselect option', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); final optionId = bloc.state.options[0].id; bloc.add(SelectOptionCellEditorEvent.unSelectOption(optionId)); await gridResponseFuture(); assert(bloc.state.selectedOptions.isEmpty); bloc.add(SelectOptionCellEditorEvent.selectOption(optionId)); await gridResponseFuture(); assert(bloc.state.selectedOptions.length == 1); expect(bloc.state.selectedOptions[0].name, "A"); }); test('select an option or create one', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("B")); bloc.add(const SelectOptionCellEditorEvent.submitTextField()); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.submitTextField()); await gridResponseFuture(); expect(bloc.state.selectedOptions.length, 1); expect(bloc.state.options.length, 1); expect(bloc.state.selectedOptions[0].name, "A"); }); test('select multiple options', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("B")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); bloc.add( const SelectOptionCellEditorEvent.selectMultipleOptions( ["A", "B", "C"], "x", ), ); await gridResponseFuture(); assert(bloc.state.selectedOptions.length == 1); expect(bloc.state.selectedOptions[0].name, "A"); expect(bloc.filter, "x"); }); test('filter options', () async { await cellTest.createTestGrid(); await cellTest.createTestRow(); final cellController = cellTest.makeSelectOptionCellController( FieldType.SingleSelect, 0, ); final bloc = SelectOptionCellEditorBloc(cellController: cellController); await gridResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("abcd")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); expect( bloc.state.options.length, 1, reason: "Options: ${bloc.state.options}", ); bloc.add(const SelectOptionCellEditorEvent.filterOption("aaaa")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); expect( bloc.state.options.length, 2, reason: "Options: ${bloc.state.options}", ); bloc.add(const SelectOptionCellEditorEvent.filterOption("defg")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await gridResponseFuture(); expect( bloc.state.options.length, 3, reason: "Options: ${bloc.state.options}", ); bloc.add(const SelectOptionCellEditorEvent.filterOption("a")); await gridResponseFuture(); expect( bloc.state.options.length, 2, reason: "Options: ${bloc.state.options}", ); expect( bloc.allOptions.length, 3, reason: "Options: ${bloc.state.options}", ); expect(bloc.state.createSelectOptionSuggestion!.name, "a"); expect(bloc.filter, "a"); }); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/field/edit_field_test.dart
import 'package:appflowy/plugins/database/application/field/field_editor_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; Future<FieldEditorBloc> createEditorBloc(AppFlowyGridTest gridTest) async { final context = await gridTest.createTestGrid(); final fieldInfo = context.singleSelectFieldContext(); return FieldEditorBloc( viewId: context.gridView.id, fieldController: context.fieldController, field: fieldInfo.field, ); } void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); test('rename field', () async { final editorBloc = await createEditorBloc(gridTest); editorBloc.add(const FieldEditorEvent.renameField('Hello world')); await gridResponseFuture(); expect(editorBloc.state.field.name, equals("Hello world")); }); test('switch to text field', () async { final editorBloc = await createEditorBloc(gridTest); editorBloc.add(const FieldEditorEvent.switchFieldType(FieldType.RichText)); await gridResponseFuture(); // The default length of the fields is 3. The length of the fields // should not change after switching to other field type expect(editorBloc.state.field.fieldType, equals(FieldType.RichText)); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/field/field_cell_bloc_test.dart
import 'package:appflowy/plugins/database/application/field/field_cell_bloc.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); group('$FieldCellBloc', () { late GridTestContext context; late double width; setUp(() async { context = await gridTest.createTestGrid(); }); blocTest( 'update field width', build: () => FieldCellBloc( fieldInfo: context.fieldInfos[0], viewId: context.gridView.id, ), act: (bloc) { width = bloc.state.width; bloc.add(const FieldCellEvent.onResizeStart()); bloc.add(const FieldCellEvent.startUpdateWidth(100)); bloc.add(const FieldCellEvent.endUpdateWidth()); }, verify: (bloc) { expect(bloc.state.width, width + 100); }, ); blocTest( 'field width should not be lesser than 50px', build: () => FieldCellBloc( viewId: context.gridView.id, fieldInfo: context.fieldInfos[0], ), act: (bloc) { bloc.add(const FieldCellEvent.onResizeStart()); bloc.add(const FieldCellEvent.startUpdateWidth(-110)); bloc.add(const FieldCellEvent.endUpdateWidth()); }, verify: (bloc) { expect(bloc.state.width, 50); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_util.dart
import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/workspace/application/view/view_service.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pbenum.dart'; import '../util.dart'; Future<GridTestContext> createTestFilterGrid(AppFlowyGridTest gridTest) async { final app = await gridTest.unitTest.createWorkspace(); final context = await ViewBackendService.createView( parentViewId: app.id, name: "Filter Grid", layoutType: ViewLayoutPB.Grid, openAfterCreate: true, ).then((result) { return result.fold( (view) async { final context = GridTestContext( view, DatabaseController(view: view), ); final result = await context.gridController.open(); await editCells(context); result.fold((l) => null, (r) => throw Exception(r)); return context; }, (error) => throw Exception(), ); }); return context; } Future<void> editCells(GridTestContext context) async { final controller0 = context.makeTextCellController(0); final controller1 = context.makeTextCellController(1); await controller0.saveCellData('A'); await gridResponseFuture(); await controller1.saveCellData('B'); await gridResponseFuture(); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_menu_test.dart
import 'package:appflowy/plugins/database/domain/filter_service.dart'; import 'package:appflowy/plugins/database/grid/application/filter/filter_menu_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/text_filter.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); test('test filter menu after create a text filter)', () async { final context = await gridTest.createTestGrid(); final menuBloc = DatabaseFilterMenuBloc( viewId: context.gridView.id, fieldController: context.fieldController, )..add(const DatabaseFilterMenuEvent.initial()); await gridResponseFuture(); assert(menuBloc.state.creatableFields.length == 3); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); assert(menuBloc.state.creatableFields.length == 3); }); test('test filter menu after update existing text filter)', () async { final context = await gridTest.createTestGrid(); final menuBloc = DatabaseFilterMenuBloc( viewId: context.gridView.id, fieldController: context.fieldController, )..add(const DatabaseFilterMenuEvent.initial()); await gridResponseFuture(); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); // Create filter await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); final textFilter = context.fieldController.filterInfos.first; // Update the existing filter await service.insertTextFilter( fieldId: textField.id, filterId: textFilter.filter.id, condition: TextFilterConditionPB.TextIs, content: "ABC", ); await gridResponseFuture(); assert( menuBloc.state.filters.first.textFilter()!.condition == TextFilterConditionPB.TextIs, ); assert(menuBloc.state.filters.first.textFilter()!.content == "ABC"); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/create_filter_test.dart
import 'package:appflowy/plugins/database/domain/filter_service.dart'; import 'package:appflowy/plugins/database/grid/application/grid_bloc.dart'; import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/checkbox_filter.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/text_filter.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); test('create a text filter)', () async { final context = await gridTest.createTestGrid(); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); assert(context.fieldController.filterInfos.length == 1); }); test('delete a text filter)', () async { final context = await gridTest.createTestGrid(); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); final filterInfo = context.fieldController.filterInfos.first; await service.deleteFilter( fieldId: textField.id, filterId: filterInfo.filter.id, ); await gridResponseFuture(); expect(context.fieldController.filterInfos.length, 0); }); test('filter rows with condition: text is empty', () async { final context = await gridTest.createTestGrid(); final service = FilterBackendService(viewId: context.gridView.id); final gridController = DatabaseController( view: context.gridView, ); final gridBloc = GridBloc( view: context.gridView, databaseController: gridController, )..add(const GridEvent.initial()); await gridResponseFuture(); final textField = context.textFieldContext(); await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); expect(gridBloc.state.rowInfos.length, 3); }); test('filter rows with condition: text is empty(After edit the row)', () async { final context = await gridTest.createTestGrid(); final service = FilterBackendService(viewId: context.gridView.id); final gridController = DatabaseController( view: context.gridView, ); final gridBloc = GridBloc( view: context.gridView, databaseController: gridController, )..add(const GridEvent.initial()); await gridResponseFuture(); final textField = context.textFieldContext(); await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); final controller = context.makeTextCellController(0); await controller.saveCellData("edit text cell content"); await gridResponseFuture(); assert(gridBloc.state.rowInfos.length == 2); await controller.saveCellData(""); await gridResponseFuture(); assert(gridBloc.state.rowInfos.length == 3); }); test('filter rows with condition: text is not empty', () async { final context = await gridTest.createTestGrid(); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); await gridResponseFuture(); await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsNotEmpty, content: "", ); await gridResponseFuture(); assert(context.rowInfos.isEmpty); }); test('filter rows with condition: checkbox uncheck', () async { final context = await gridTest.createTestGrid(); final checkboxField = context.checkboxFieldContext(); final service = FilterBackendService(viewId: context.gridView.id); final gridController = DatabaseController( view: context.gridView, ); final gridBloc = GridBloc( view: context.gridView, databaseController: gridController, )..add(const GridEvent.initial()); await gridResponseFuture(); await service.insertCheckboxFilter( fieldId: checkboxField.id, condition: CheckboxFilterConditionPB.IsUnChecked, ); await gridResponseFuture(); assert(gridBloc.state.rowInfos.length == 3); }); test('filter rows with condition: checkbox check', () async { final context = await gridTest.createTestGrid(); final checkboxField = context.checkboxFieldContext(); final service = FilterBackendService(viewId: context.gridView.id); final gridController = DatabaseController( view: context.gridView, ); final gridBloc = GridBloc( view: context.gridView, databaseController: gridController, )..add(const GridEvent.initial()); await gridResponseFuture(); await service.insertCheckboxFilter( fieldId: checkboxField.id, condition: CheckboxFilterConditionPB.IsChecked, ); await gridResponseFuture(); assert(gridBloc.state.rowInfos.isEmpty); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_checkbox_test.dart
import 'package:appflowy/plugins/database/domain/filter_service.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/checkbox_filter.pbenum.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; import 'filter_util.dart'; void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); test('filter rows by checkbox is check condition)', () async { final context = await createTestFilterGrid(gridTest); final service = FilterBackendService(viewId: context.gridView.id); final controller = context.makeCheckboxCellController(0); await controller.saveCellData("Yes"); await gridResponseFuture(); // create a new filter final checkboxField = context.checkboxFieldContext(); await service.insertCheckboxFilter( fieldId: checkboxField.id, condition: CheckboxFilterConditionPB.IsChecked, ); await gridResponseFuture(); assert( context.rowInfos.length == 1, "expect 1 but receive ${context.rowInfos.length}", ); }); test('filter rows by checkbox is uncheck condition)', () async { final context = await createTestFilterGrid(gridTest); final service = FilterBackendService(viewId: context.gridView.id); final controller = context.makeCheckboxCellController(0); await controller.saveCellData("Yes"); await gridResponseFuture(); // create a new filter final checkboxField = context.checkboxFieldContext(); await service.insertCheckboxFilter( fieldId: checkboxField.id, condition: CheckboxFilterConditionPB.IsUnChecked, ); await gridResponseFuture(); assert( context.rowInfos.length == 2, "expect 2 but receive ${context.rowInfos.length}", ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_rows_by_text_test.dart
import 'package:appflowy/plugins/database/domain/filter_service.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/text_filter.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import '../util.dart'; import 'filter_util.dart'; void main() { late AppFlowyGridTest gridTest; setUpAll(() async { gridTest = await AppFlowyGridTest.ensureInitialized(); }); test('filter rows by text is empty condition)', () async { final context = await createTestFilterGrid(gridTest); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); assert( context.fieldController.filterInfos.length == 1, "expect 1 but receive ${context.fieldController.filterInfos.length}", ); assert( context.rowInfos.length == 1, "expect 1 but receive ${context.rowInfos.length}", ); // delete the filter final textFilter = context.fieldController.filterInfos.first; await service.deleteFilter( fieldId: textField.id, filterId: textFilter.filter.id, ); await gridResponseFuture(); assert(context.rowInfos.length == 3); }); test('filter rows by text is not empty condition)', () async { final context = await createTestFilterGrid(gridTest); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsNotEmpty, content: "", ); await gridResponseFuture(); assert( context.rowInfos.length == 2, "expect 2 but receive ${context.rowInfos.length}", ); // delete the filter final textFilter = context.fieldController.filterInfos.first; await service.deleteFilter( fieldId: textField.id, filterId: textFilter.filter.id, ); await gridResponseFuture(); assert(context.rowInfos.length == 3); }); test('filter rows by text is empty or is not empty condition)', () async { final context = await createTestFilterGrid(gridTest); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIsEmpty, content: "", ); await gridResponseFuture(); assert( context.fieldController.filterInfos.length == 1, "expect 1 but receive ${context.fieldController.filterInfos.length}", ); assert( context.rowInfos.length == 1, "expect 1 but receive ${context.rowInfos.length}", ); // Update the existing filter final textFilter = context.fieldController.filterInfos.first; await service.insertTextFilter( fieldId: textField.id, filterId: textFilter.filter.id, condition: TextFilterConditionPB.TextIsNotEmpty, content: "", ); await gridResponseFuture(); assert(context.rowInfos.length == 2); // delete the filter await service.deleteFilter( fieldId: textField.id, filterId: textFilter.filter.id, ); await gridResponseFuture(); assert(context.rowInfos.length == 3); }); test('filter rows by text is condition)', () async { final context = await createTestFilterGrid(gridTest); final service = FilterBackendService(viewId: context.gridView.id); final textField = context.textFieldContext(); // create a new filter await service.insertTextFilter( fieldId: textField.id, condition: TextFilterConditionPB.TextIs, content: "A", ); await gridResponseFuture(); assert( context.rowInfos.length == 1, "expect 1 but receive ${context.rowInfos.length}", ); // Update the existing filter's content from 'A' to 'B' final textFilter = context.fieldController.filterInfos.first; await service.insertTextFilter( fieldId: textField.id, filterId: textFilter.filter.id, condition: TextFilterConditionPB.TextIs, content: "B", ); await gridResponseFuture(); assert(context.rowInfos.length == 1); // Update the existing filter's content from 'B' to 'b' await service.insertTextFilter( fieldId: textField.id, filterId: textFilter.filter.id, condition: TextFilterConditionPB.TextIs, content: "b", ); await gridResponseFuture(); assert(context.rowInfos.length == 1); // Update the existing filter with content 'C' await service.insertTextFilter( fieldId: textField.id, filterId: textFilter.filter.id, condition: TextFilterConditionPB.TextIs, content: "C", ); await gridResponseFuture(); assert(context.rowInfos.isEmpty); // delete the filter await service.deleteFilter( fieldId: textField.id, filterId: textFilter.filter.id, ); await gridResponseFuture(); assert(context.rowInfos.length == 3); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_checkbox_field_test.dart
import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/application/setting/group_bloc.dart'; import 'package:appflowy/plugins/database/board/application/board_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'util.dart'; void main() { late AppFlowyBoardTest boardTest; setUpAll(() async { boardTest = await AppFlowyBoardTest.ensureInitialized(); }); // Group by checkbox field test('group by checkbox field test', () async { final context = await boardTest.createTestBoard(); final boardBloc = BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const BoardEvent.initial()); await boardResponseFuture(); // assert the initial values assert(boardBloc.groupControllers.values.length == 4); assert(context.fieldContexts.length == 2); // create checkbox field await context.createField(FieldType.Checkbox); await boardResponseFuture(); assert(context.fieldContexts.length == 3); // set group by checkbox final checkboxField = context.fieldContexts.last.field; final gridGroupBloc = DatabaseGroupBloc( viewId: context.gridView.id, databaseController: context.databaseController, )..add(const DatabaseGroupEvent.initial()); gridGroupBloc.add( DatabaseGroupEvent.setGroupByField( checkboxField.id, checkboxField.fieldType, ), ); await boardResponseFuture(); assert(boardBloc.groupControllers.values.length == 2); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_unsupport_field_test.dart
import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/application/field/field_editor_bloc.dart'; import 'package:appflowy/plugins/database/board/application/board_bloc.dart'; import 'package:bloc_test/bloc_test.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'util.dart'; void main() { late AppFlowyBoardTest boardTest; late FieldEditorBloc editorBloc; late BoardTestContext context; setUpAll(() async { boardTest = await AppFlowyBoardTest.ensureInitialized(); context = await boardTest.createTestBoard(); final fieldInfo = context.singleSelectFieldContext(); editorBloc = context.makeFieldEditor( fieldInfo: fieldInfo, ); await boardResponseFuture(); }); group('Group with not support grouping field', () { blocTest<FieldEditorBloc, FieldEditorState>( "switch to text field", build: () => editorBloc, wait: boardResponseDuration(), act: (bloc) async { bloc.add(const FieldEditorEvent.switchFieldType(FieldType.RichText)); }, verify: (bloc) { assert(bloc.state.field.fieldType == FieldType.RichText); }, ); blocTest<BoardBloc, BoardState>( 'assert the number of groups is 1', build: () => BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add( const BoardEvent.initial(), ), wait: boardResponseDuration(), verify: (bloc) { assert( bloc.groupControllers.values.length == 1, "Expected 1, but receive ${bloc.groupControllers.values.length}", ); }, ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/board_test/util.dart
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart'; import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart'; import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/application/field/field_controller.dart'; import 'package:appflowy/plugins/database/application/field/field_editor_bloc.dart'; import 'package:appflowy/plugins/database/application/field/field_info.dart'; import 'package:appflowy/plugins/database/application/row/row_cache.dart'; import 'package:appflowy/plugins/database/board/board.dart'; import 'package:appflowy/workspace/application/view/view_service.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import '../../util.dart'; import '../grid_test/util.dart'; class AppFlowyBoardTest { AppFlowyBoardTest({required this.unitTest}); final AppFlowyUnitTest unitTest; static Future<AppFlowyBoardTest> ensureInitialized() async { final inner = await AppFlowyUnitTest.ensureInitialized(); return AppFlowyBoardTest(unitTest: inner); } Future<BoardTestContext> createTestBoard() async { final app = await unitTest.createWorkspace(); final builder = BoardPluginBuilder(); return ViewBackendService.createView( parentViewId: app.id, name: "Test Board", layoutType: builder.layoutType!, openAfterCreate: true, ).then((result) { return result.fold( (view) async { final context = BoardTestContext( view, DatabaseController(view: view), ); final result = await context._boardDataController.open(); result.fold((l) => null, (r) => throw Exception(r)); return context; }, (error) { throw Exception(); }, ); }); } } Future<void> boardResponseFuture() { return Future.delayed(boardResponseDuration()); } Duration boardResponseDuration({int milliseconds = 200}) { return Duration(milliseconds: milliseconds); } class BoardTestContext { BoardTestContext(this.gridView, this._boardDataController); final ViewPB gridView; final DatabaseController _boardDataController; List<RowInfo> get rowInfos { return _boardDataController.rowCache.rowInfos; } List<FieldInfo> get fieldContexts => fieldController.fieldInfos; FieldController get fieldController { return _boardDataController.fieldController; } DatabaseController get databaseController => _boardDataController; FieldEditorBloc makeFieldEditor({ required FieldInfo fieldInfo, }) { final editorBloc = FieldEditorBloc( viewId: databaseController.viewId, fieldController: fieldController, field: fieldInfo.field, ); return editorBloc; } CellController makeCellControllerFromFieldId(String fieldId) { return makeCellController( _boardDataController, CellContext(fieldId: fieldId, rowId: rowInfos.last.rowId), ); } Future<FieldEditorBloc> createField(FieldType fieldType) async { final editorBloc = await createFieldEditor(databaseController: _boardDataController); await gridResponseFuture(); editorBloc.add(FieldEditorEvent.switchFieldType(fieldType)); await gridResponseFuture(); return Future(() => editorBloc); } FieldInfo singleSelectFieldContext() { final fieldInfo = fieldContexts .firstWhere((element) => element.fieldType == FieldType.SingleSelect); return fieldInfo; } FieldInfo textFieldContext() { final fieldInfo = fieldContexts .firstWhere((element) => element.fieldType == FieldType.RichText); return fieldInfo; } FieldInfo checkboxFieldContext() { final fieldInfo = fieldContexts .firstWhere((element) => element.fieldType == FieldType.Checkbox); return fieldInfo; } }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/board_test/create_card_test.dart
import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/board/application/board_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'util.dart'; void main() { late AppFlowyBoardTest boardTest; setUpAll(() async { boardTest = await AppFlowyBoardTest.ensureInitialized(); }); test('create kanban baord card', () async { final context = await boardTest.createTestBoard(); final databaseController = DatabaseController(view: context.gridView); final boardBloc = BoardBloc( view: context.gridView, databaseController: databaseController, )..add(const BoardEvent.initial()); await boardResponseFuture(); final groupId = boardBloc.state.groupIds.last; // the group at index 3 is the 'No status' group; assert(boardBloc.groupControllers[groupId]!.group.rows.isEmpty); assert( boardBloc.state.groupIds.length == 4, 'but receive ${boardBloc.state.groupIds.length}', ); boardBloc.add(BoardEvent.createBottomRow(boardBloc.state.groupIds[3])); await boardResponseFuture(); assert( boardBloc.groupControllers[groupId]!.group.rows.length == 1, 'but receive ${boardBloc.groupControllers[groupId]!.group.rows.length}', ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/board_test/group_by_multi_select_field_test.dart
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart'; import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/application/setting/group_bloc.dart'; import 'package:appflowy/plugins/database/board/application/board_bloc.dart'; import 'package:appflowy/plugins/database/application/cell/bloc/select_option_cell_editor_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'util.dart'; void main() { late AppFlowyBoardTest boardTest; setUpAll(() async { boardTest = await AppFlowyBoardTest.ensureInitialized(); }); test('no status group name test', () async { final context = await boardTest.createTestBoard(); // create multi-select field await context.createField(FieldType.MultiSelect); await boardResponseFuture(); assert(context.fieldContexts.length == 3); final multiSelectField = context.fieldContexts.last.field; // set grouped by the new multi-select field" final gridGroupBloc = DatabaseGroupBloc( viewId: context.gridView.id, databaseController: context.databaseController, )..add(const DatabaseGroupEvent.initial()); await boardResponseFuture(); gridGroupBloc.add( DatabaseGroupEvent.setGroupByField( multiSelectField.id, multiSelectField.fieldType, ), ); await boardResponseFuture(); // assert only have the 'No status' group final boardBloc = BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const BoardEvent.initial()); await boardResponseFuture(); assert( boardBloc.groupControllers.values.length == 1, "Expected 1, but receive ${boardBloc.groupControllers.values.length}", ); }); test('group by multi select with no options test', () async { final context = await boardTest.createTestBoard(); // create multi-select field await context.createField(FieldType.MultiSelect); await boardResponseFuture(); assert(context.fieldContexts.length == 3); final multiSelectField = context.fieldContexts.last.field; // Create options final cellController = context.makeCellControllerFromFieldId(multiSelectField.id) as SelectOptionCellController; final bloc = SelectOptionCellEditorBloc(cellController: cellController); await boardResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("A")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await boardResponseFuture(); bloc.add(const SelectOptionCellEditorEvent.filterOption("B")); bloc.add(const SelectOptionCellEditorEvent.createOption()); await boardResponseFuture(); // set grouped by the new multi-select field" final gridGroupBloc = DatabaseGroupBloc( viewId: context.gridView.id, databaseController: context.databaseController, )..add(const DatabaseGroupEvent.initial()); await boardResponseFuture(); gridGroupBloc.add( DatabaseGroupEvent.setGroupByField( multiSelectField.id, multiSelectField.fieldType, ), ); await boardResponseFuture(); // assert there are only three group final boardBloc = BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const BoardEvent.initial()); await boardResponseFuture(); assert( boardBloc.groupControllers.values.length == 3, "Expected 3, but receive ${boardBloc.groupControllers.values.length}", ); }); }
0
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test
mirrored_repositories/AppFlowy/frontend/appflowy_flutter/test/bloc_test/board_test/create_or_edit_field_test.dart
import 'package:appflowy/plugins/database/application/database_controller.dart'; import 'package:appflowy/plugins/database/application/field/field_editor_bloc.dart'; import 'package:appflowy/plugins/database/board/application/board_bloc.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'util.dart'; void main() { late AppFlowyBoardTest boardTest; setUpAll(() async { boardTest = await AppFlowyBoardTest.ensureInitialized(); }); test('create build-in kanban board test', () async { final context = await boardTest.createTestBoard(); final boardBloc = BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const BoardEvent.initial()); await boardResponseFuture(); assert(boardBloc.groupControllers.values.length == 4); assert(context.fieldContexts.length == 2); }); test('edit kanban board field name test', () async { final context = await boardTest.createTestBoard(); final boardBloc = BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const BoardEvent.initial()); await boardResponseFuture(); final fieldInfo = context.singleSelectFieldContext(); final editorBloc = FieldEditorBloc( viewId: context.gridView.id, field: fieldInfo.field, fieldController: context.fieldController, ); await boardResponseFuture(); editorBloc.add(const FieldEditorEvent.renameField('Hello world')); await boardResponseFuture(); // assert the groups were not changed assert( boardBloc.groupControllers.values.length == 4, "Expected 4, but receive ${boardBloc.groupControllers.values.length}", ); assert( context.fieldContexts.length == 2, "Expected 2, but receive ${context.fieldContexts.length}", ); }); test('create a new field in kanban board test', () async { final context = await boardTest.createTestBoard(); final boardBloc = BoardBloc( view: context.gridView, databaseController: DatabaseController(view: context.gridView), )..add(const BoardEvent.initial()); await boardResponseFuture(); await context.createField(FieldType.Checkbox); await boardResponseFuture(); final checkboxField = context.fieldContexts.last.field; assert(checkboxField.fieldType == FieldType.Checkbox); assert( boardBloc.groupControllers.values.length == 4, "Expected 4, but receive ${boardBloc.groupControllers.values.length}", ); assert( context.fieldContexts.length == 3, "Expected 3, but receive ${context.fieldContexts.length}", ); }); }
0