From 1dfdbd6de4d3c3519b863504b1f12411a60e1cbf Mon Sep 17 00:00:00 2001 From: pooja-muchandikar Date: Thu, 28 Jul 2022 12:24:52 +0530 Subject: [PATCH 1/3] Migrate Conver Block Type test to Playwright --- .../convert-block-type.test.js.snap | 13 -------- .../editor/various/convert-block-type.test.js | 32 ------------------- ...ert-to-a-preformatted-block-1-chromium.txt | 3 ++ ...ert-to-a-preformatted-block-2-chromium.txt | 3 ++ .../editor/various/convert-block-type.spec.js | 28 ++++++++++++++++ 5 files changed, 34 insertions(+), 45 deletions(-) delete mode 100644 packages/e2e-tests/specs/editor/various/__snapshots__/convert-block-type.test.js.snap delete mode 100644 packages/e2e-tests/specs/editor/various/convert-block-type.test.js create mode 100644 test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt create mode 100644 test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt create mode 100644 test/e2e/specs/editor/various/convert-block-type.spec.js diff --git a/packages/e2e-tests/specs/editor/various/__snapshots__/convert-block-type.test.js.snap b/packages/e2e-tests/specs/editor/various/__snapshots__/convert-block-type.test.js.snap deleted file mode 100644 index 830161bea53c9..0000000000000 --- a/packages/e2e-tests/specs/editor/various/__snapshots__/convert-block-type.test.js.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Code block should convert to a preformatted block 1`] = ` -" -
print \\"Hello Dolly!\\"
-" -`; - -exports[`Code block should convert to a preformatted block 2`] = ` -" -
print \\"Hello Dolly!\\"
-" -`; diff --git a/packages/e2e-tests/specs/editor/various/convert-block-type.test.js b/packages/e2e-tests/specs/editor/various/convert-block-type.test.js deleted file mode 100644 index 101a40b6dd229..0000000000000 --- a/packages/e2e-tests/specs/editor/various/convert-block-type.test.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * WordPress dependencies - */ -import { - getEditedPostContent, - createNewPost, - insertBlock, - transformBlockTo, -} from '@wordpress/e2e-test-utils'; - -describe( 'Code block', () => { - beforeEach( async () => { - await createNewPost(); - } ); - - it( 'should convert to a preformatted block', async () => { - const code = 'print "Hello Dolly!"'; - - await insertBlock( 'Code' ); - await page.keyboard.type( code ); - - // Verify the content starts out as a Code block. - const originalPostContent = await getEditedPostContent(); - expect( originalPostContent ).toMatchSnapshot(); - - await transformBlockTo( 'Preformatted' ); - - // The content should now be a Preformatted block with no data loss. - const convertedPostContent = await getEditedPostContent(); - expect( convertedPostContent ).toMatchSnapshot(); - } ); -} ); diff --git a/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt new file mode 100644 index 0000000000000..5908ebefcb09b --- /dev/null +++ b/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt @@ -0,0 +1,3 @@ + +
print "Hello Dolly!"
+ \ No newline at end of file diff --git a/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt new file mode 100644 index 0000000000000..d2a89d3774b79 --- /dev/null +++ b/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt @@ -0,0 +1,3 @@ + +
print "Hello Dolly!"
+ \ No newline at end of file diff --git a/test/e2e/specs/editor/various/convert-block-type.spec.js b/test/e2e/specs/editor/various/convert-block-type.spec.js new file mode 100644 index 0000000000000..11b5e7f435fb7 --- /dev/null +++ b/test/e2e/specs/editor/various/convert-block-type.spec.js @@ -0,0 +1,28 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'Code block', () => { + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + + test( 'should convert to a preformatted block', async ( { + page, + editor, + } ) => { + const code = 'print "Hello Dolly!"'; + + await editor.insertBlock( { name: 'core/code' } ); + await page.keyboard.type( code ); + + // Verify the content starts out as a Code block. + expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + + await editor.transformBlockTo( 'core/preformatted' ); + + // The content should now be a Preformatted block with no data loss. + expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + } ); +} ); From f00627e3e14a12d33e706a0724c34a7e8ac5ffdf Mon Sep 17 00:00:00 2001 From: pooja-muchandikar Date: Thu, 28 Jul 2022 15:54:12 +0530 Subject: [PATCH 2/3] Addressed Review Feedbacks --- ...convert-to-a-preformatted-block-1-chromium.txt | 3 --- ...convert-to-a-preformatted-block-2-chromium.txt | 3 --- .../editor/various/convert-block-type.spec.js | 15 +++++++++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt delete mode 100644 test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt diff --git a/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt deleted file mode 100644 index 5908ebefcb09b..0000000000000 --- a/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-1-chromium.txt +++ /dev/null @@ -1,3 +0,0 @@ - -
print "Hello Dolly!"
- \ No newline at end of file diff --git a/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt b/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt deleted file mode 100644 index d2a89d3774b79..0000000000000 --- a/test/e2e/specs/editor/various/__snapshots__/Code-block-should-convert-to-a-preformatted-block-2-chromium.txt +++ /dev/null @@ -1,3 +0,0 @@ - -
print "Hello Dolly!"
- \ No newline at end of file diff --git a/test/e2e/specs/editor/various/convert-block-type.spec.js b/test/e2e/specs/editor/various/convert-block-type.spec.js index 11b5e7f435fb7..c7fb07ddc6fa8 100644 --- a/test/e2e/specs/editor/various/convert-block-type.spec.js +++ b/test/e2e/specs/editor/various/convert-block-type.spec.js @@ -8,6 +8,10 @@ test.describe( 'Code block', () => { await admin.createNewPost(); } ); + test.afterEach( async ( { requestUtils } ) => { + await requestUtils.deleteAllPosts(); + } ); + test( 'should convert to a preformatted block', async ( { page, editor, @@ -18,11 +22,18 @@ test.describe( 'Code block', () => { await page.keyboard.type( code ); // Verify the content starts out as a Code block. - expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + // expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + await expect.poll( editor.getEditedPostContent ).toBe( ` +
${code}
+` ); await editor.transformBlockTo( 'core/preformatted' ); // The content should now be a Preformatted block with no data loss. - expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + // expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + await expect.poll( editor.getEditedPostContent ) + .toBe( ` +
${code}
+` ); } ); } ); From 2500196531528268215b3ae28491412ec508c624 Mon Sep 17 00:00:00 2001 From: pooja-muchandikar Date: Thu, 28 Jul 2022 16:45:23 +0530 Subject: [PATCH 3/3] Fix Stylint Issue --- test/e2e/specs/editor/various/convert-block-type.spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/editor/various/convert-block-type.spec.js b/test/e2e/specs/editor/various/convert-block-type.spec.js index c7fb07ddc6fa8..b26cc6124f831 100644 --- a/test/e2e/specs/editor/various/convert-block-type.spec.js +++ b/test/e2e/specs/editor/various/convert-block-type.spec.js @@ -22,18 +22,17 @@ test.describe( 'Code block', () => { await page.keyboard.type( code ); // Verify the content starts out as a Code block. - // expect( await editor.getEditedPostContent() ).toMatchSnapshot(); + await expect.poll( editor.getEditedPostContent ).toBe( ` -
${code}
+
${ code }
` ); await editor.transformBlockTo( 'core/preformatted' ); // The content should now be a Preformatted block with no data loss. - // expect( await editor.getEditedPostContent() ).toMatchSnapshot(); await expect.poll( editor.getEditedPostContent ) .toBe( ` -
${code}
+
${ code }
` ); } ); } );