Skip to content

Commit

Permalink
fix: integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Nov 12, 2023
1 parent dc2f6a8 commit 821e5c0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ void main() {

// 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();
Expand Down Expand Up @@ -62,10 +61,9 @@ void main() {

// 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.editor.tapGettingStartedIcon();
await tester.tapEmoji('😀');
tester.expectToSeeDocumentIcon('😀');

Expand Down Expand Up @@ -100,10 +98,9 @@ void main() {

// 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.editor.tapGettingStartedIcon();
await tester.tapEmoji('😀');

// Insert a document cover
Expand All @@ -122,8 +119,7 @@ void main() {
await tester.initializeAppFlowy();
await tester.tapGoButton();

await tester.editor.hoverOnCoverToolbar();
await tester.editor.tapAddIconButton();
await tester.editor.tapGettingStartedIcon();

// click the shuffle button
await tester.tapButton(
Expand All @@ -136,8 +132,7 @@ void main() {
await tester.initializeAppFlowy();
await tester.tapGoButton();

await tester.editor.hoverOnCoverToolbar();
await tester.editor.tapAddIconButton();
await tester.editor.tapGettingStartedIcon();

final searchEmojiTextField = find.byWidgetPredicate(
(widget) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ class EditorOperations {
expect(find.byType(FlowyEmojiPicker), findsOneWidget);
}

Future<void> tapGettingStartedIcon() async {
await tester.tapButton(
find.descendant(
of: find.byType(DocumentHeaderNodeWidget),
matching: find.findTextInFlowyText('⭐️'),
),
);
}

/// Taps on the 'Skin tone' button
///
/// Must call [tapAddIconButton] first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
}
final document = editorState.document;
final lastNode = document.root.children.lastOrNull;
if (lastNode == null || lastNode.type != ParagraphBlockKeys.type) {
if (lastNode == null || lastNode.delta == null) {
final transaction = editorState.transaction;
transaction.insertNode([document.root.children.length], paragraphNode());
transaction.afterSelection = transaction.beforeSelection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ CharacterShortcutEvent insertChildNodeInsideToggleList = CharacterShortcutEvent(
// insert a toggle list block below the current toggle list block
transaction
..deleteText(node, selection.startIndex, slicedDelta.length)
..insertNode(
..insertNodes(
selection.start.path.next,
toggleListBlockNode(collapsed: true, delta: slicedDelta),
[
toggleListBlockNode(collapsed: true, delta: slicedDelta),
paragraphNode(),
],
)
..afterSelection = Selection.collapsed(
Position(path: selection.start.path.next, offset: 0),
Expand Down

0 comments on commit 821e5c0

Please sign in to comment.