From e3decb71f23ba4a8c15bb5d76312edfa77305875 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Mon, 10 Jan 2022 14:06:23 +0500 Subject: [PATCH] test: add tests for streetwriters/notesnook#279 --- apps/web/__e2e__/editor.test.js | 24 ++++++++++++++++++- ...changes-should-get-saved-Firefox-linux.txt | 2 +- ...ine-with-different-font-Chromium-linux.txt | 1 + ...line-with-different-font-Firefox-linux.txt | 1 + ...-line-with-different-font-WebKit-linux.txt | 1 + 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txt create mode 100644 apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txt create mode 100644 apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txt diff --git a/apps/web/__e2e__/editor.test.js b/apps/web/__e2e__/editor.test.js index 8ee8e090b..f63e32ba9 100644 --- a/apps/web/__e2e__/editor.test.js +++ b/apps/web/__e2e__/editor.test.js @@ -132,7 +132,7 @@ test("format changes should get saved", async () => { await page.waitForSelector(".mce-content-body"); - await page.keyboard.press("Control+a"); + await page.keyboard.press("Shift+End"); await page.click(`#editorToolbar button[title="Bold"]`); @@ -206,3 +206,25 @@ test("select all & backspace should clear all content in editor", async () => { await expect(getEditorContent()).resolves.toBe(""); }); + +test.only("last line doesn't get saved if it's font is different", async () => { + const selector = await createNoteAndCheckPresence(); + + await page.keyboard.press("Enter"); + + await page.click(`#editorToolbar button[title="Fonts"]`); + + await page.click(`div[title="Serif"]`); + + await page.type(".mce-content-body", "I am another line in Serif font."); + + await page.waitForTimeout(200); + + await page.click(getTestId("notes-action-button")); + + await page.click(selector); + + const content = await getEditorContentAsHTML(); + + expect(content).toMatchSnapshot(`last-line-with-different-font.txt`); +}); diff --git a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txt index 5e3bcad9b..87df3d45f 100644 --- a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txt +++ b/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txt @@ -1 +1 @@ -

This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1

\ No newline at end of file +

This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1

\ No newline at end of file diff --git a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txt new file mode 100644 index 000000000..e29d00be4 --- /dev/null +++ b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txt @@ -0,0 +1 @@ +

This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1I am another line in Serif font.

\ No newline at end of file diff --git a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txt new file mode 100644 index 000000000..cd7c6a823 --- /dev/null +++ b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txt @@ -0,0 +1 @@ +

This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1I am another line in Serif font.

\ No newline at end of file diff --git a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txt new file mode 100644 index 000000000..e29d00be4 --- /dev/null +++ b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txt @@ -0,0 +1 @@ +

This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1I am another line in Serif font.

\ No newline at end of file