Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Sep 4, 2024
1 parent e25c43a commit f33dd13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
28 changes: 13 additions & 15 deletions tests/e2e/specs/d6.woo-sor.spec-with-inventory-new-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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&section' );
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(
Expand Down Expand Up @@ -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&section=update' );

const result = await new Promise( ( resolve ) => {
Expand Down
9 changes: 6 additions & 3 deletions tests/e2e/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ export async function createProduct( page, product, save = true, newEditor = fal
if ( newEditor ) {
await page.goto( '/wp-admin/admin.php?page=wc-settings&tab=advanced&section=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' );

await page.locator( '#woocommerce-product-tab__general' ).click();

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();
Expand Down

0 comments on commit f33dd13

Please sign in to comment.