From 6286f7fbd646e3b6eb2f881b49e2df4ecce21ac5 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Mon, 11 Oct 2021 18:55:38 +0700 Subject: [PATCH] Add e2e tests for Newest Products (https://github.com/woocommerce/woocommerce-blocks/pull/4789) --- .../__fixtures__/newest-products.fixture.json | 1 + .../e2e/specs/backend/product-new.test.js | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 plugins/woocommerce-blocks/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json create mode 100644 plugins/woocommerce-blocks/tests/e2e/specs/backend/product-new.test.js diff --git a/plugins/woocommerce-blocks/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json b/plugins/woocommerce-blocks/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json new file mode 100644 index 00000000000..5ffe302fc75 --- /dev/null +++ b/plugins/woocommerce-blocks/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json @@ -0,0 +1 @@ +{"title":"Newest Products Block","pageContent":""} \ No newline at end of file diff --git a/plugins/woocommerce-blocks/tests/e2e/specs/backend/product-new.test.js b/plugins/woocommerce-blocks/tests/e2e/specs/backend/product-new.test.js new file mode 100644 index 00000000000..ec5ff81ab82 --- /dev/null +++ b/plugins/woocommerce-blocks/tests/e2e/specs/backend/product-new.test.js @@ -0,0 +1,30 @@ +/** + * External dependencies + */ +import { getAllBlocks, switchUserToAdmin } from '@wordpress/e2e-test-utils'; + +import { visitBlockPage } from '@woocommerce/blocks-test-utils'; + +import { insertBlockDontWaitForInsertClose } from '../../utils.js'; + +const block = { + name: 'Newest Products', + slug: 'woocommerce/product-new', + class: '.wc-block-product-new', +}; + +describe( `${ block.name } Block`, () => { + beforeAll( async () => { + await switchUserToAdmin(); + await visitBlockPage( `${ block.name } Block` ); + } ); + + it( 'renders without crashing', async () => { + await expect( page ).toRenderBlock( block ); + } ); + + it( 'can be inserted more than once', async () => { + await insertBlockDontWaitForInsertClose( block.name ); + expect( await getAllBlocks() ).toHaveLength( 2 ); + } ); +} );