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' );
|
||||
|
||||
// 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.selectOption( '#field_to_edit', 'link_all_variations', {
|
||||
force: true,
|
||||
|
@ -199,33 +206,50 @@ test.describe.serial( 'Add New Variable Product Page', () => {
|
|||
'val1 | val2'
|
||||
);
|
||||
await page.click( `input[name="attribute_variation[${ i }]"]` );
|
||||
}
|
||||
await page.click( 'text=Save attributes' );
|
||||
await page.click( 'a[href="#variable_product_options"]' );
|
||||
await expect(
|
||||
page
|
||||
.locator( '.woocommerce_attribute.closed' )
|
||||
.filter( { hasText: `attr #${ i + 1 }` } )
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
// 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
|
||||
await page.click( 'a[href="#variable_product_options"]' );
|
||||
await page.selectOption( '#field_to_edit', 'add_variation', {
|
||||
force: true,
|
||||
} );
|
||||
await page.click( 'a.do_variation_action' );
|
||||
await expect( page.locator( '.variation-needs-update' ) ).toBeVisible();
|
||||
for ( let i = 0; i < defaultAttributes.length; i++ ) {
|
||||
await page.selectOption(
|
||||
`select[name="attribute_attr-${ i + 1 }[0]"]`,
|
||||
`.variation-needs-update h3 select >> nth=${ i }`,
|
||||
defaultAttributes[ i ]
|
||||
);
|
||||
}
|
||||
await page.click( 'button.save-variation-changes' );
|
||||
for ( let i = 0; i < defaultAttributes.length; i++ ) {
|
||||
await expect(
|
||||
page.locator(
|
||||
`select[name="attribute_attr-${
|
||||
i + 1
|
||||
}[0]"] > option[selected]`
|
||||
)
|
||||
page
|
||||
.locator( '.woocommerce_variation' )
|
||||
.first()
|
||||
.locator( 'select' )
|
||||
.nth( i )
|
||||
.locator( 'option[selected]' )
|
||||
).toHaveText( defaultAttributes[ i ] );
|
||||
}
|
||||
|
||||
await page.locator( '#save-post' ).click();
|
||||
await expect(
|
||||
page.getByText( 'Product draft updated. ' )
|
||||
).toBeVisible();
|
||||
} );
|
||||
|
||||
test( 'can manage stock at variation level', async ( { page } ) => {
|
||||
|
|
Loading…
Reference in New Issue