diff --git a/plugins/woocommerce/changelog/e2e-fix-flaky-create-variable-product-test b/plugins/woocommerce/changelog/e2e-fix-flaky-create-variable-product-test new file mode 100644 index 000000000000..c8d6d152c7a3 --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-fix-flaky-create-variable-product-test @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +E2E tests: fix variable product flakiness diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/create-variable-product-block-editor.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/create-variable-product-block-editor.spec.js index 9300e0252f83..6b65bd07a737 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/create-variable-product-block-editor.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/create-variable-product-block-editor.spec.js @@ -53,7 +53,7 @@ test.describe( 'Variations tab', () => { 'The block product editor is not being tested' ); - test( 'can create a variation option and publish the product', async ( { + test.only( 'can create a variation option and publish the product', async ( { page, } ) => { await page.goto( NEW_EDITOR_ADD_PRODUCT_URL ); @@ -94,45 +94,19 @@ test.describe( 'Variations tab', () => { await expect( attributeColumn ).toHaveValue( 'Size' ); - await page - .locator( '//input[@placeholder="Search or create value"]' ) - .fill( attributesData.options[ 0 ] ); - - await page - .locator( `text=Create "${ attributesData.options[ 0 ] }"` ) - .click(); - - await expect( - page.getByText( attributesData.options[ 0 ] ).first() - ).toBeVisible(); - - await page - .locator( - '.woocommerce-new-attribute-modal__table-attribute-value-column .woocommerce-experimental-select-control__input' - ) - .fill( attributesData.options[ 1 ] ); - - await page - .locator( `text=Create "${ attributesData.options[ 1 ] }"` ) - .click(); - - await expect( - page.getByText( attributesData.options[ 1 ] ).first() - ).toBeVisible(); - - await page - .locator( - '.woocommerce-new-attribute-modal__table-attribute-value-column .woocommerce-experimental-select-control__input' - ) - .fill( attributesData.options[ 2 ] ); + for ( const option of attributesData.options ) { + await page + .locator( + '.woocommerce-new-attribute-modal__table-attribute-value-column .woocommerce-experimental-select-control__input' + ) + .fill( option ); - await page - .locator( `text=Create "${ attributesData.options[ 2 ] }"` ) - .click(); + await page.locator( `text=Create "${ option }"` ).click(); - await expect( - page.getByText( attributesData.options[ 2 ] ).first() - ).toBeVisible(); + await expect( + page.locator( '.woocommerce-attribute-term-field' ) + ).toContainText( option ); + } await page .locator( '.woocommerce-new-attribute-modal__buttons' )