From f4e68859b9c489c3ccb7a99d4aa00f7a82bedb43 Mon Sep 17 00:00:00 2001 From: Rodel Date: Wed, 22 Dec 2021 18:44:17 +0800 Subject: [PATCH] Added: can manually add a variation --- .../merchant/wp-admin-product-new.test.js | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js b/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js index 23188dee967..b83da1626f1 100644 --- a/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js +++ b/packages/js/e2e-core-tests/specs/merchant/wp-admin-product-new.test.js @@ -39,6 +39,8 @@ const openNewProductAndVerify = async () => { await expect(page.title()).resolves.toMatch('Add new product'); } +// mytodo: const selectActionVariations = async()=>{} + const runAddSimpleProductTest = () => { describe('Add New Simple Product Page', () => { beforeAll(async () => { @@ -253,16 +255,64 @@ const runAddVariableProductTest = () => { it( 'can manually add a variation', async () => { // mytodo - } ); + // Select "Add variation" from the actions menu. + await expect( page ).toSelect( + 'select.variation_actions', + 'Add variation' + ); + await expect( page ).toClick( 'a.do_variation_action' ); + await uiUnblocked(); - it( 'can set variation defaults', async () => { - // mytodo + // Set attribute values. + await expect( page ).toSelect( + 'select[name="attribute_attr-1[0]"]', + 'val2' + ); + await expect( page ).toSelect( + 'select[name="attribute_attr-2[0]"]', + 'val1' + ); + await expect( page ).toSelect( + 'select[name="attribute_attr-3[0]"]', + 'val2' + ); + await expect( page ).toClick( 'button.save-variation-changes', { + text: 'Save changes', + } ); + + // Wait for attribute form to save (triggers 2 UI blocks) + await uiUnblocked(); + await uiUnblocked(); + + // Verify that attribute values were saved. + await expect( page ).toMatchElement( + 'select[name="attribute_attr-1[0]"] option[selected]', + { + text: 'val2', + } + ); + await expect( page ).toMatchElement( + 'select[name="attribute_attr-2[0]"] option[selected]', + { + text: 'val1', + } + ); + await expect( page ).toMatchElement( + 'select[name="attribute_attr-3[0]"] option[selected]', + { + text: 'val2', + } + ); } ); it( 'can manage stock at variation level', async () => { // mytodo } ); + it( 'can set variation defaults', async () => { + // mytodo + } ); + it( 'can remove a variation', async () => { // mytodo } );