diff --git a/tests/e2e/specs/d6.woo-sor.spec-with-inventory-new-editor.spec.js b/tests/e2e/specs/d6.woo-sor.spec-with-inventory-new-editor.spec.js index 69f35082..42c76a89 100644 --- a/tests/e2e/specs/d6.woo-sor.spec-with-inventory-new-editor.spec.js +++ b/tests/e2e/specs/d6.woo-sor.spec-with-inventory-new-editor.spec.js @@ -18,11 +18,20 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => { const page = await browser.newPage(); await clearSync( page ); + + await browser.close(); +} ); + +test( 'OnePlus 8 pushed to Square with inventory', async ( { page, baseURL } ) => { + test.slow(); + await deleteAllCatalogItems(); await page.goto( '/wp-admin/admin.php?page=wc-settings&tab=square§ion' ); - await page.locator( '#wc_square_system_of_record' ).selectOption( { label: 'WooCommerce' } ); - await page.locator( '#wc_square_enable_inventory_sync' ).check(); - await page.locator( '.woocommerce-save-button' ).click(); + await page.getByTestId( 'sync-settings-field' ).selectOption( { label: 'WooCommerce' } ); + await page.getByTestId( 'push-inventory-field' ).check(); + await page.getByTestId( 'square-settings-save-button' ).click(); + + await expect( await page.getByText( 'Changes Saved!' ) ).toBeVisible(); if ( ! ( await doesProductExist( baseURL, 'oneplus-8' ) ) ) { await createProduct( @@ -50,20 +59,9 @@ test.beforeAll( 'Setup', async ( { baseURL } ) => { .filter( { hasText: 'Publish' } ) .click(); - await page - .locator( '.woocommerce-product-publish-panel__header .components-button' ) - .filter( { hasText: 'Publish' } ) - .click(); - - await expect( await page.getByText( 'OnePlus 8 is now live.' ) ).toBeVisible(); + await expect( await page.getByText( 'Product published.' ).first() ).toBeVisible(); } - await browser.close(); -} ); - -test( 'OnePlus 8 pushed to Square with inventory', async ( { page } ) => { - test.slow(); - await page.goto( '/wp-admin/admin.php?page=wc-settings&tab=square§ion=update' ); const result = await new Promise( ( resolve ) => { diff --git a/tests/e2e/utils/helper.js b/tests/e2e/utils/helper.js index d5d6429c..2cdbefed 100644 --- a/tests/e2e/utils/helper.js +++ b/tests/e2e/utils/helper.js @@ -63,8 +63,12 @@ export async function createProduct( page, product, save = true, newEditor = fal if ( newEditor ) { await page.goto( '/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=features' ); await page.locator( '#woocommerce_feature_product_block_editor_enabled' ).check(); - await page.locator( '.woocommerce-save-button' ).click(); - await expect( await page.getByText( 'Your settings have been saved' ) ).toBeVisible(); + + const saveButton = await page.locator( '.woocommerce-save-button' ); + if ( ! await saveButton.isDisabled() ) { + saveButton.click(); + await expect( await page.getByText( 'Your settings have been saved' ) ).toBeVisible(); + } await page.goto( '/wp-admin/admin.php?page=wc-admin&path=%2Fadd-product' ); @@ -72,7 +76,6 @@ export async function createProduct( page, product, save = true, newEditor = fal await page.locator( '[data-template-block-id="product-name"] input[name="name"]' ).fill( product.name ); - await page.locator( '#woocommerce-product-tab__pricing' ).click(); await page.locator( 'input[name="regular_price"]' ).fill( product.regularPrice ); await page.locator( '#woocommerce-product-tab__inventory' ).click();