database_calendar_test.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart';
  2. import 'package:appflowy_backend/protobuf/flowy-folder2/view.pbenum.dart';
  3. import 'package:flutter_test/flutter_test.dart';
  4. import 'package:integration_test/integration_test.dart';
  5. import 'util/database_test_op.dart';
  6. import 'util/util.dart';
  7. void main() {
  8. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  9. group('database', () {
  10. const location = 'appflowy';
  11. setUp(() async {
  12. await TestFolder.cleanTestLocation(location);
  13. await TestFolder.setTestLocation(location);
  14. });
  15. tearDown(() async {
  16. await TestFolder.cleanTestLocation(location);
  17. });
  18. tearDownAll(() async {
  19. await TestFolder.cleanTestLocation(null);
  20. });
  21. testWidgets('update calendar layout', (tester) async {
  22. await tester.initializeAppFlowy();
  23. await tester.tapGoButton();
  24. await tester.tapAddButton();
  25. await tester.tapCreateCalendarButton();
  26. // open setting
  27. await tester.tapDatabaseSettingButton();
  28. await tester.tapDatabaseLayoutButton();
  29. await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Board);
  30. await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Board);
  31. await tester.tapDatabaseSettingButton();
  32. await tester.tapDatabaseLayoutButton();
  33. await tester.selectDatabaseLayoutType(DatabaseLayoutPB.Grid);
  34. await tester.assertCurrentDatabaseLayoutType(DatabaseLayoutPB.Grid);
  35. await tester.pumpAndSettle();
  36. });
  37. testWidgets('calendar start from day setting', (tester) async {
  38. await tester.initializeAppFlowy();
  39. await tester.tapGoButton();
  40. // Create calendar view
  41. await tester.createNewPageWithName(ViewLayoutPB.Calendar, 'calendar');
  42. // Open setting
  43. await tester.tapDatabaseSettingButton();
  44. await tester.tapCalendarLayoutSettingButton();
  45. // select the first day of week is Monday
  46. await tester.tapFirstDayOfWeek();
  47. await tester.tapFirstDayOfWeekStartFromMonday();
  48. // Open the other page and open the new calendar page again
  49. await tester.openPage(readme);
  50. await tester.pumpAndSettle(const Duration(milliseconds: 300));
  51. await tester.openPage('calendar');
  52. // Open setting again and check the start from Monday is selected
  53. await tester.tapDatabaseSettingButton();
  54. await tester.tapCalendarLayoutSettingButton();
  55. await tester.tapFirstDayOfWeek();
  56. tester.assertFirstDayOfWeekStartFromMonday();
  57. await tester.pumpAndSettle();
  58. });
  59. });
  60. }