cover_image_test.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import 'package:flowy_infra_ui/widget/rounded_button.dart';
  2. import 'package:flutter/gestures.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'package:integration_test/integration_test.dart';
  6. import 'util/util.dart';
  7. /// Integration tests for an empty board. The [TestWorkspaceService] will load
  8. /// a workspace from an empty board `assets/test/workspaces/board.zip` for all
  9. /// tests.
  10. ///
  11. /// To create another integration test with a preconfigured workspace.
  12. /// Use the following steps.
  13. /// 1. Create a new workspace from the AppFlowy launch screen.
  14. /// 2. Modify the workspace until it is suitable as the starting point for
  15. /// the integration test you need to land.
  16. /// 3. Use a zip utility program to zip the workspace folder that you created.
  17. /// 4. Add the zip file under `assets/test/workspaces/`
  18. /// 5. Add a new enumeration to [TestWorkspace] in `integration_test/utils/data.dart`.
  19. /// For example, if you added a workspace called `empty_calendar.zip`,
  20. /// then [TestWorkspace] should have the following value:
  21. /// ```dart
  22. /// enum TestWorkspace {
  23. /// board('board'),
  24. /// empty_calendar('empty_calendar');
  25. ///
  26. /// /* code */
  27. /// }
  28. /// ```
  29. /// 6. Double check that the .zip file that you added is included as an asset in
  30. /// the pubspec.yaml file under appflowy_flutter.
  31. void main() {
  32. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  33. const service = TestWorkspaceService(TestWorkspace.coverImage);
  34. group('cover image', () {
  35. setUpAll(() async => await service.setUpAll());
  36. setUp(() async => await service.setUp());
  37. testWidgets(
  38. 'hovering on cover image will display change and delete cover image buttons',
  39. (tester) async {
  40. await tester.initializeAppFlowy();
  41. expect(find.byType(Image), findsOneWidget);
  42. final TestPointer pointer = TestPointer(1, PointerDeviceKind.mouse);
  43. final imageFinder = find.byType(Image);
  44. Offset offset = tester.getCenter(imageFinder);
  45. pointer.hover(offset);
  46. expect(find.byType(RoundedTextButton), findsOneWidget);
  47. });
  48. });
  49. }