Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/AppFlowy-IO/AppFlowy into f…
Browse files Browse the repository at this point in the history
…eat-panes-2312
  • Loading branch information
squidrye committed Sep 14, 2023
2 parents d1f6870 + f6f80b4 commit 44d7aac
Show file tree
Hide file tree
Showing 136 changed files with 2,015 additions and 1,244 deletions.
2 changes: 1 addition & 1 deletion frontend/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
LIB_NAME = "dart_ffi"
CURRENT_APP_VERSION = "0.3.1"
CURRENT_APP_VERSION = "0.3.2"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite"
PRODUCT_NAME = "AppFlowy"
# CRATE_TYPE: https://doc.rust-lang.org/reference/linkage.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'util/util.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('calendar database view', () {
group('calendar', () {
testWidgets('update calendar layout', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();
Expand Down Expand Up @@ -116,6 +116,7 @@ void main() {
tester.assertRowDetailPageOpened();

// Duplicate the event
await tester.tapRowDetailPageRowActionButton();
await tester.tapRowDetailPageDuplicateRowButton();
await tester.dismissRowDetailPage();

Expand All @@ -125,6 +126,7 @@ void main() {

// Delete an event
await tester.openCalendarEvent(index: 1);
await tester.tapRowDetailPageRowActionButton();
await tester.tapRowDetailPageDeleteRowButton();

// Check that there is 1 event
Expand Down Expand Up @@ -155,6 +157,7 @@ void main() {

// Delete the event
await tester.openCalendarEvent(index: 0, date: sameDayNextWeek);
await tester.tapRowDetailPageRowActionButton();
await tester.tapRowDetailPageDeleteRowButton();

// Create a new event in today's calendar cell
Expand Down
112 changes: 112 additions & 0 deletions frontend/appflowy_flutter/integration_test/database_cell_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,116 @@ void main() {
await tester.pumpAndSettle();
});
});

testWidgets('edit checklist cell', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();

await tester.createNewPageWithName(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);

// assert that new task editor is shown
tester.assertNewCheckListTaskEditorVisible(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();
tester.assertNewCheckListTaskEditorVisible(visible: false);

// 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, click on new task button
await tester.tapChecklistCellInGrid(rowIndex: 0);
tester.assertNewCheckListTaskEditorVisible(visible: false);
await tester.tapChecklistNewTaskButton();
tester.assertNewCheckListTaskEditorVisible(visible: true);

// 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);

// assert that the new task editor is shown
tester.assertNewCheckListTaskEditorVisible(visible: true);

// dismiss the cell editor
await tester.dismissCellEditor();

// check that the progress bar is not viisble
tester.assertChecklistCellInGrid(rowIndex: 0, percent: null);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,40 @@ void main() {
}
});

testWidgets('check document is exist in row detail page', (tester) async {
testWidgets('change order of fields and cells', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();

// Create a new grid
await tester.createNewPageWithName(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 tyoe
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('check document exists in row detail page', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();

Expand All @@ -149,7 +182,7 @@ void main() {
await tester.assertDocumentExistInRowDetailPage();
});

testWidgets('update the content of the document and re-open it',
testWidgets('update the contents of the document and re-open it',
(tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();
Expand Down Expand Up @@ -239,6 +272,7 @@ void main() {
// Hover first row and then open the row page
await tester.openFirstRowDetailPage();

await tester.tapRowDetailPageRowActionButton();
await tester.tapRowDetailPageDeleteRowButton();
await tester.tapEscButton();

Expand All @@ -255,6 +289,7 @@ void main() {
// Hover first row and then open the row page
await tester.openFirstRowDetailPage();

await tester.tapRowDetailPageRowActionButton();
await tester.tapRowDetailPageDuplicateRowButton();
await tester.tapEscButton();

Expand Down
20 changes: 10 additions & 10 deletions frontend/appflowy_flutter/integration_test/database_share_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ void main() {
}

// check the checklist cell
final List<double> checklistCells = [
0.6,
0.3,
final List<double?> checklistCells = [
0.67,
0.33,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
null,
null,
null,
null,
null,
null,
null,
];
for (final (index, percent) in checklistCells.indexed) {
await tester.assertChecklistCellInGrid(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database_view/board/presentation/board_page.dart';
import 'package:appflowy/plugins/database_view/calendar/presentation/calendar_page.dart';
import 'package:appflowy/plugins/database_view/grid/presentation/grid_page.dart';
Expand All @@ -7,7 +8,7 @@ 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-folder2/view.pb.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

Expand All @@ -22,14 +23,11 @@ void main() {
await tester.tapGoButton();

// create a new page
const name = 'Hello AppFlowy';
await tester.tapNewPageButton();
await tester.enterText(find.byType(TextFormField), name);
await tester.tapOKButton();

// expect to see a new document
tester.expectToSeePageName(
name,
LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
);
// and with one paragraph block
expect(find.byType(TextBlockComponentWidget), findsOneWidget);
Expand Down
29 changes: 26 additions & 3 deletions frontend/appflowy_flutter/integration_test/util/base.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import 'dart:async';
import 'dart:io';

import 'package:appflowy/startup/entry_point.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/presentation/presentation.dart';
import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:flowy_infra/uuid.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';

class FlowyTestContext {
FlowyTestContext({
Expand Down Expand Up @@ -39,8 +41,8 @@ extension AppFlowyTestBase on WidgetTester {
IntegrationMode.integrationTest,
);

await wait(3000);
await pumpAndSettle(const Duration(seconds: 2));
await waitUntilSignInPageShow();

return FlowyTestContext(
applicationDataDirectory: directory,
);
Expand Down Expand Up @@ -78,6 +80,27 @@ extension AppFlowyTestBase on WidgetTester {
return directory.path;
}

Future<void> waitUntilSignInPageShow() async {
final finder = find.byType(GoButton);
await pumpUntilFound(finder);
expect(finder, findsOneWidget);
}

Future<void> pumpUntilFound(
Finder finder, {
Duration timeout = const Duration(seconds: 10),
}) async {
bool timerDone = false;
final timer = Timer(timeout, () => timerDone = true);
while (timerDone != true) {
await pump();
if (any(finder)) {
timerDone = true;
}
}
timer.cancel();
}

Future<void> tapButton(
Finder finder, {
int? pointer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/document/presentation/share/share_button.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/presentation/screens/screens.dart';
import 'package:appflowy/workspace/presentation/home/menu/sidebar/sidebar_new_page_button.dart';
import 'package:appflowy/workspace/presentation/home/menu/view/draggable_view_item.dart';
Expand Down Expand Up @@ -279,7 +282,14 @@ extension CommonOperations on WidgetTester {
// create a new page
await tapAddViewButton(name: parentName ?? gettingStarted);
await tapButtonWithName(layout.menuName);
await tapOKButton();
final settingsOrFailure = await getIt<KeyValueStorage>().getWithFormat(
KVKeys.showRenameDialogWhenCreatingNewFile,
(value) => bool.parse(value),
);
final showRenameDialog = settingsOrFailure.fold((l) => false, (r) => r);
if (showRenameDialog) {
await tapOKButton();
}
await pumpAndSettle();

// hover on it and change it's name
Expand Down
Loading

0 comments on commit 44d7aac

Please sign in to comment.