Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[e2e tests] Improve test stability by using a stricter locator when checking product variation #45710

Merged
merged 1 commit into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

E2E tests: fix variable product flakiness
Expand Up @@ -53,7 +53,7 @@
'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 );
Expand Down Expand Up @@ -94,45 +94,19 @@

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' )
Expand All @@ -158,7 +132,7 @@
'.woocommerce-product-variations__table-body > div'
)
.count()
).toEqual( attributesData.options.length );

Check failure on line 135 in plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/create-variable-product-block-editor.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests in matrix. (1, 1/5)

[Chrome] › merchant/products/block-editor/create-variable-product-block-editor.spec.js:56:8 › Variations tab › Create variable product › can create a variation option and publish the product

1) [Chrome] › merchant/products/block-editor/create-variable-product-block-editor.spec.js:56:8 › Variations tab › Create variable product › can create a variation option and publish the product Error: expect(received).toEqual(expected) // deep equality Expected: 3 Received: 5 133 | ) 134 | .count() > 135 | ).toEqual( attributesData.options.length ); | ^ 136 | 137 | await page 138 | .locator( '.woocommerce-product-variations__table-body > div' ) at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/create-variable-product-block-editor.spec.js:135:6

await page
.locator( '.woocommerce-product-variations__table-body > div' )
Expand Down