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-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();
|
2023-07-01 23:13:09 +08:00
|
|
|
tester.expectToSeeDocumentCover(CoverType.asset);
|
2023-06-27 15:17:51 +08:00
|
|
|
|
|
|
|
// 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();
|
2023-07-01 23:13:09 +08:00
|
|
|
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);
|
|
|
|
await tester.editor.switchNetworkImageCover(imageUrl);
|
|
|
|
await tester.editor.dismissCoverPicker();
|
|
|
|
tester.expectToSeeDocumentCover(CoverType.file);
|
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('😀');
|
2023-07-01 23:13:09 +08:00
|
|
|
tester.expectToSeeDocumentCover(CoverType.asset);
|
2023-06-27 15:17:51 +08:00
|
|
|
|
|
|
|
// 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
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|