2023-06-27 15:17:51 +08:00
|
|
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/header/document_header_node_widget.dart';
|
2023-05-03 10:22:16 +03:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:integration_test/integration_test.dart';
|
2023-06-11 14:19:44 +08:00
|
|
|
|
2023-06-27 15:17:51 +08:00
|
|
|
import '../util/emoji.dart';
|
2023-06-21 19:53:29 +08:00
|
|
|
import '../util/util.dart';
|
2023-05-03 10:22:16 +03:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
group('cover image', () {
|
2023-06-11 14:19:44 +08:00
|
|
|
const location = 'cover_image';
|
|
|
|
|
|
|
|
setUp(() async {
|
|
|
|
await TestFolder.cleanTestLocation(location);
|
|
|
|
await TestFolder.setTestLocation(location);
|
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() async {
|
|
|
|
await TestFolder.cleanTestLocation(location);
|
|
|
|
});
|
|
|
|
|
|
|
|
tearDownAll(() async {
|
|
|
|
await TestFolder.cleanTestLocation(null);
|
|
|
|
});
|
2023-05-03 10:22:16 +03:00
|
|
|
|
2023-06-27 15:17:51 +08:00
|
|
|
testWidgets('document cover tests', (tester) async {
|
2023-05-03 10:22:16 +03:00
|
|
|
await tester.initializeAppFlowy();
|
2023-06-27 15:17:51 +08:00
|
|
|
await tester.tapGoButton();
|
|
|
|
|
|
|
|
tester.expectToSeeNoDocumentCover();
|
|
|
|
|
|
|
|
// Hover over cover toolbar to show 'Add Cover' and 'Add Icon' buttons
|
|
|
|
await tester.editor.hoverOnCoverToolbar();
|
|
|
|
tester.expectToSeePluginAddCoverAndIconButton();
|
|
|
|
|
|
|
|
// Insert a document cover
|
|
|
|
await tester.editor.tapOnAddCover();
|
|
|
|
tester.expectToSeeDocumentCover(
|
|
|
|
CoverType.asset,
|
|
|
|
"assets/images/app_flowy_abstract_cover_1.jpg",
|
|
|
|
);
|
|
|
|
|
|
|
|
// 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.hoverOnCover();
|
|
|
|
await tester.editor.tapOnChangeCover();
|
|
|
|
await tester.editor.switchSolidColorBackground();
|
|
|
|
await tester.editor.dismissCoverPicker();
|
|
|
|
tester.expectToSeeDocumentCover(CoverType.color, "ffe8e0ff");
|
2023-05-03 10:22:16 +03:00
|
|
|
|
2023-06-27 15:17:51 +08:00
|
|
|
// Remove the cover
|
|
|
|
await tester.editor.hoverOnCover();
|
|
|
|
await tester.editor.tapOnRemoveCover();
|
|
|
|
tester.expectToSeeNoDocumentCover();
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('document icon tests', (tester) async {
|
|
|
|
await tester.initializeAppFlowy();
|
2023-06-11 14:19:44 +08:00
|
|
|
await tester.tapGoButton();
|
2023-06-12 20:32:55 +08:00
|
|
|
|
2023-06-27 15:17:51 +08:00
|
|
|
tester.expectToSeeDocumentIcon(null);
|
|
|
|
|
|
|
|
// Hover over cover toolbar to show the 'Add Cover' and 'Add Icon' buttons
|
|
|
|
await tester.editor.hoverOnCoverToolbar();
|
2023-06-12 20:32:55 +08:00
|
|
|
tester.expectToSeePluginAddCoverAndIconButton();
|
2023-06-27 15:17:51 +08:00
|
|
|
|
|
|
|
// Insert a document icon
|
|
|
|
await tester.editor.tapAddIconButton();
|
|
|
|
await tester.switchToEmojiList();
|
|
|
|
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.switchToEmojiList();
|
|
|
|
await tester.tapEmoji('😀');
|
|
|
|
tester.expectToSeeDocumentIcon('😀');
|
|
|
|
|
|
|
|
// Change the document icon
|
|
|
|
await tester.editor.tapOnIconWidget();
|
|
|
|
await tester.switchToEmojiList();
|
|
|
|
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.tapGoButton();
|
|
|
|
|
|
|
|
tester.expectToSeeDocumentIcon(null);
|
|
|
|
tester.expectToSeeNoDocumentCover();
|
|
|
|
|
|
|
|
// Hover over cover toolbar to show the 'Add Cover' and 'Add Icon' buttons
|
|
|
|
await tester.editor.hoverOnCoverToolbar();
|
|
|
|
tester.expectToSeePluginAddCoverAndIconButton();
|
|
|
|
|
|
|
|
// Insert a document icon
|
|
|
|
await tester.editor.tapAddIconButton();
|
|
|
|
await tester.switchToEmojiList();
|
|
|
|
await tester.tapEmoji('😀');
|
|
|
|
|
|
|
|
// Insert a document cover
|
|
|
|
await tester.editor.tapOnAddCover();
|
|
|
|
|
|
|
|
// Expect to see the icon and cover at the same time
|
|
|
|
tester.expectToSeeDocumentIcon('😀');
|
|
|
|
tester.expectToSeeDocumentCover(
|
|
|
|
CoverType.asset,
|
|
|
|
"assets/images/app_flowy_abstract_cover_1.jpg",
|
|
|
|
);
|
|
|
|
|
|
|
|
// Hover over the cover toolbar and see that neither icons are shown
|
|
|
|
await tester.editor.hoverOnCoverToolbar();
|
|
|
|
tester.expectToSeeEmptyDocumentHeaderToolbar();
|
2023-05-03 10:22:16 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|