E2E: Update tests in `create-variable-product.spec.js` to avoid creating variations from all attributes automatically (#36008)
* Update selectors and added some important assertions * Save product before going to Variations tab
This commit is contained in:
parent
393cc629d9
commit
1276d54da5
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Update the "can manually add a variation" E2E test to prevent automatic creation of variations from all attributes.
|
|
@ -65,7 +65,14 @@ test.describe.serial( 'Add New Variable Product Page', () => {
|
||||||
}
|
}
|
||||||
await page.click( 'text=Save attributes' );
|
await page.click( 'text=Save attributes' );
|
||||||
|
|
||||||
// create variations from all attributes
|
// Save before going to the Variations tab to prevent variations from all attributes to be automatically created
|
||||||
|
await page.locator( '#save-post' ).click();
|
||||||
|
await expect(
|
||||||
|
page.getByText( 'Product draft updated. ' )
|
||||||
|
).toBeVisible();
|
||||||
|
await page.click( '.updated.notice .notice-dismiss' );
|
||||||
|
|
||||||
|
// manually create variations from all attributes
|
||||||
await page.click( 'a[href="#variable_product_options"]' );
|
await page.click( 'a[href="#variable_product_options"]' );
|
||||||
await page.selectOption( '#field_to_edit', 'link_all_variations', {
|
await page.selectOption( '#field_to_edit', 'link_all_variations', {
|
||||||
force: true,
|
force: true,
|
||||||
|
@ -199,33 +206,50 @@ test.describe.serial( 'Add New Variable Product Page', () => {
|
||||||
'val1 | val2'
|
'val1 | val2'
|
||||||
);
|
);
|
||||||
await page.click( `input[name="attribute_variation[${ i }]"]` );
|
await page.click( `input[name="attribute_variation[${ i }]"]` );
|
||||||
|
await page.click( 'text=Save attributes' );
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator( '.woocommerce_attribute.closed' )
|
||||||
|
.filter( { hasText: `attr #${ i + 1 }` } )
|
||||||
|
).toBeVisible();
|
||||||
}
|
}
|
||||||
await page.click( 'text=Save attributes' );
|
|
||||||
await page.click( 'a[href="#variable_product_options"]' );
|
// Save before going to the Variations tab to prevent variations from all attributes to be automatically created
|
||||||
|
await page.locator( '#save-post' ).click();
|
||||||
|
await expect(
|
||||||
|
page.getByText( 'Product draft updated. ' )
|
||||||
|
).toBeVisible();
|
||||||
|
await page.click( '.updated.notice .notice-dismiss' );
|
||||||
|
|
||||||
// manually adds a variation
|
// manually adds a variation
|
||||||
|
await page.click( 'a[href="#variable_product_options"]' );
|
||||||
await page.selectOption( '#field_to_edit', 'add_variation', {
|
await page.selectOption( '#field_to_edit', 'add_variation', {
|
||||||
force: true,
|
force: true,
|
||||||
} );
|
} );
|
||||||
await page.click( 'a.do_variation_action' );
|
await page.click( 'a.do_variation_action' );
|
||||||
|
await expect( page.locator( '.variation-needs-update' ) ).toBeVisible();
|
||||||
for ( let i = 0; i < defaultAttributes.length; i++ ) {
|
for ( let i = 0; i < defaultAttributes.length; i++ ) {
|
||||||
await page.selectOption(
|
await page.selectOption(
|
||||||
`select[name="attribute_attr-${ i + 1 }[0]"]`,
|
`.variation-needs-update h3 select >> nth=${ i }`,
|
||||||
defaultAttributes[ i ]
|
defaultAttributes[ i ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await page.click( 'button.save-variation-changes' );
|
await page.click( 'button.save-variation-changes' );
|
||||||
for ( let i = 0; i < defaultAttributes.length; i++ ) {
|
for ( let i = 0; i < defaultAttributes.length; i++ ) {
|
||||||
await expect(
|
await expect(
|
||||||
page.locator(
|
page
|
||||||
`select[name="attribute_attr-${
|
.locator( '.woocommerce_variation' )
|
||||||
i + 1
|
.first()
|
||||||
}[0]"] > option[selected]`
|
.locator( 'select' )
|
||||||
)
|
.nth( i )
|
||||||
|
.locator( 'option[selected]' )
|
||||||
).toHaveText( defaultAttributes[ i ] );
|
).toHaveText( defaultAttributes[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.locator( '#save-post' ).click();
|
await page.locator( '#save-post' ).click();
|
||||||
|
await expect(
|
||||||
|
page.getByText( 'Product draft updated. ' )
|
||||||
|
).toBeVisible();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can manage stock at variation level', async ( { page } ) => {
|
test( 'can manage stock at variation level', async ( { page } ) => {
|
||||||
|
|
Loading…
Reference in New Issue