Skip to content

Commit

Permalink
fix:emoji shortcut insert tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony-MK committed Dec 2, 2023
1 parent 657bb35 commit 7391e01
Showing 1 changed file with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,89 @@ import '../util/util.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

const emoji = '😁';

group('emoji shortcut in document', () {
testWidgets('Update page icon in sidebar', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();

// create document, board, grid and calendar views
for (final value in ViewLayoutPB.values) {
await tester.createNewPageWithName(
name: value.name,
parentName: gettingStarted,
layout: value,
);

// update its icon
await tester.updatePageIconInSidebarByName(
name: value.name,
parentName: gettingStarted,
layout: value,
icon: emoji,
);

tester.expectViewHasIcon(
value.name,
value,
emoji,
);
}
});

testWidgets('insert gringing emoji', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();
insertEmoji(tester, ':gringing', "😃", false);

await tester.createNewPageWithName(
name: 'gringing',
layout: ViewLayoutPB.Document,
);

/*
await tester.tap(find.byType(SingleInnerViewItem).first);
await tester.pumpAndSettle();
// This is a workaround since the openAfterCreated
// option does not work in createNewPageWithName method
await tester.editor.tapLineOfEditorAt(0);
await tester.pumpAndSettle();
*/

// Search the emoji list with keyword
await tester.ime.insertText(":gringing");
await tester.pumpAndSettle();

await FlowyTestKeyboard.simulateKeyDownEvent(
tester: tester,
// Insert the emoji
[LogicalKeyboardKey.enter],
);

final editorState = tester.editor.getCurrentEditorState();
expect(
editorState.document.last!.delta!.toPlainText(),
"😃",
);
});

testWidgets('insert gringing emoji with arrow keys', (tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();

insertEmoji(tester, ':gringing', "😃", true);
});

testWidgets('insert angry emoji', (tester) async {
await tester.initializeAppFlowy();

await tester.tapGoButton();

insertEmoji(tester, ':angry', "😃", false);
});

testWidgets('insert angry emoji with arrow keys', (tester) async {
await tester.initializeAppFlowy();

await tester.tapGoButton();
insertEmoji(tester, ':angry', "😃", true);
});
Expand All @@ -49,9 +109,10 @@ void insertEmoji(
await tester.createNewPageWithName(
name: 'document_${uuid()}',
layout: ViewLayoutPB.Document,
openAfterCreated: true,
);

await tester.pumpAndSettle();

await tester.tap(find.byType(SingleInnerViewItem).first);
await tester.pumpAndSettle();

Expand All @@ -61,7 +122,7 @@ void insertEmoji(
await tester.pumpAndSettle();

// Search the emoji list with keyword
tester.ime.insertText(emojiKeyword);
await tester.ime.insertText(emojiKeyword);
await tester.pumpAndSettle();

await FlowyTestKeyboard.simulateKeyDownEvent(
Expand All @@ -79,7 +140,6 @@ void insertEmoji(
]
: [LogicalKeyboardKey.enter], // Insert the emoji
);
await tester.pumpAndSettle();

final editorState = tester.editor.getCurrentEditorState();
expect(
Expand Down

0 comments on commit 7391e01

Please sign in to comment.