Fixed variations test
This commit is contained in:
parent
0eacfc31cf
commit
50852ca9ea
|
@ -14,7 +14,7 @@ const defaultAttributes = [ 'val2', 'val1', 'val2' ];
|
|||
const stockAmount = '100';
|
||||
const lowStockAmount = '10';
|
||||
|
||||
test.describe.serial( 'Add New Variable Product Page', () => {
|
||||
test.describe( 'Add New Variable Product Page', () => {
|
||||
test.use( { storageState: process.env.ADMINSTATE } );
|
||||
|
||||
test.afterAll( async ( { baseURL } ) => {
|
||||
|
@ -52,20 +52,15 @@ test.describe.serial( 'Add New Variable Product Page', () => {
|
|||
|
||||
// add 3 attributes
|
||||
for ( let i = 0; i < 3; i++ ) {
|
||||
await page.click( 'button.add_attribute' );
|
||||
if ( i > 0 ) {
|
||||
await page.click( 'button.add_attribute' );
|
||||
}
|
||||
await page.waitForSelector( `input[name="attribute_names[${ i }]"]` );
|
||||
await page.fill(
|
||||
`input[name="attribute_names[${ i }]"]`,
|
||||
`attr #${ i + 1 }`
|
||||
);
|
||||
await page.fill(
|
||||
`textarea[name="attribute_values[${ i }]"]`,
|
||||
'val1 | val2'
|
||||
);
|
||||
}
|
||||
await page.click( 'text=Save attributes', { force: true } );
|
||||
await page.waitForLoadState( 'networkidle' );
|
||||
|
||||
await page.locator( `input[name="attribute_names[${ i }]"]` ).first().type( `attr #${ i + 1 }` );
|
||||
await page.locator( `textarea[name="attribute_values[${ i }]"]` ).first().type( 'val1 | val2' );
|
||||
}
|
||||
await page.click( 'text=Save attributes' );
|
||||
// wait for the attributes to be saved
|
||||
await page.waitForResponse(
|
||||
( response ) =>
|
||||
|
@ -81,24 +76,20 @@ test.describe.serial( 'Add New Variable Product Page', () => {
|
|||
|
||||
// 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,
|
||||
} );
|
||||
await page.selectOption( '#field_to_edit', 'link_all_variations' );
|
||||
page.on( 'dialog', ( dialog ) => dialog.accept() );
|
||||
|
||||
await page.click( 'a.do_variation_action' );
|
||||
|
||||
await page.waitForLoadState( 'networkidle' );
|
||||
|
||||
// add variation attributes
|
||||
for ( let i = 0; i < 4; i++ ) {
|
||||
for ( let i = 0; i < 8; i++ ) {
|
||||
const val1 = 'val1';
|
||||
const val2 = 'val2';
|
||||
const attr3 = !! ( i % 2 ); // 0-1,4-5 / 2-3,6-7
|
||||
const attr2 = i % 4 > 1; // 0-3 / 4-7
|
||||
// const attr1 = i > 3;
|
||||
// await expect(
|
||||
// page.locator( `select[name="attribute_attr-1[${ i }]"]` )
|
||||
// ).toHaveValue( attr1 ? val2 : val1 );
|
||||
const attr1 = i > 3;
|
||||
await expect(
|
||||
page.locator( `select[name="attribute_attr-1[${ i }]"]` )
|
||||
).toHaveValue( attr1 ? val2 : val1 );
|
||||
await expect(
|
||||
page.locator( `select[name="attribute_attr-2[${ i }]"]` )
|
||||
).toHaveValue( attr2 ? val2 : val1 );
|
||||
|
|
Loading…
Reference in New Issue