Add todo tag for later fixing
This commit is contained in:
parent
c646236ac2
commit
024dc324f2
|
@ -84,105 +84,117 @@ test.describe( 'Add variations', { tag: '@gutenberg' }, () => {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can manually add a variation', async ( { page } ) => {
|
test(
|
||||||
await test.step( `Open "Edit product" page of product id ${ productId_addManually }`, async () => {
|
'can manually add a variation',
|
||||||
await page.goto(
|
{ tag: '@todo-fix-in-multisite' },
|
||||||
`/wp-admin/post.php?post=${ productId_addManually }&action=edit`
|
async ( { page } ) => {
|
||||||
);
|
await test.step( `Open "Edit product" page of product id ${ productId_addManually }`, async () => {
|
||||||
} );
|
await page.goto(
|
||||||
|
`/wp-admin/post.php?post=${ productId_addManually }&action=edit`
|
||||||
// hook up the woocommerce_variations_added jQuery trigger so we can check if it's fired
|
);
|
||||||
await test.step( 'Hook up the woocommerce_variations_added jQuery trigger', async () => {
|
|
||||||
await page.evaluate( () => {
|
|
||||||
window.woocommerceVariationsAddedFunctionCalls = [];
|
|
||||||
|
|
||||||
window
|
|
||||||
.jQuery( '#variable_product_options' )
|
|
||||||
.on( 'woocommerce_variations_added', ( event, data ) => {
|
|
||||||
window.woocommerceVariationsAddedFunctionCalls.push( [
|
|
||||||
event,
|
|
||||||
data,
|
|
||||||
] );
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
// hook up the woocommerce_variations_added jQuery trigger so we can check if it's fired
|
||||||
await page.locator( '.variations_tab' ).click();
|
await test.step( 'Hook up the woocommerce_variations_added jQuery trigger', async () => {
|
||||||
} );
|
await page.evaluate( () => {
|
||||||
|
window.woocommerceVariationsAddedFunctionCalls = [];
|
||||||
|
|
||||||
await test.step( `Manually add ${ variationsToManuallyCreate.length } variations`, async () => {
|
window
|
||||||
const variationRows = page.locator( '.woocommerce_variation h3' );
|
.jQuery( '#variable_product_options' )
|
||||||
let variationRowsCount = await variationRows.count();
|
.on(
|
||||||
const originalVariationRowsCount = variationRowsCount;
|
'woocommerce_variations_added',
|
||||||
|
( event, data ) => {
|
||||||
for ( const variationToCreate of variationsToManuallyCreate ) {
|
window.woocommerceVariationsAddedFunctionCalls.push(
|
||||||
await test.step( 'Click "Add manually"', async () => {
|
[ event, data ]
|
||||||
const addManuallyButton = page.getByRole( 'button', {
|
);
|
||||||
name: 'Add manually',
|
}
|
||||||
} );
|
|
||||||
|
|
||||||
await addManuallyButton.click();
|
|
||||||
|
|
||||||
await expect( variationRows ).toHaveCount(
|
|
||||||
++variationRowsCount
|
|
||||||
);
|
|
||||||
|
|
||||||
// verify that the woocommerce_variations_added jQuery trigger was fired
|
|
||||||
const woocommerceVariationsAddedFunctionCalls =
|
|
||||||
await page.evaluate(
|
|
||||||
() => window.woocommerceVariationsAddedFunctionCalls
|
|
||||||
);
|
);
|
||||||
expect(
|
|
||||||
woocommerceVariationsAddedFunctionCalls.length
|
|
||||||
).toEqual(
|
|
||||||
variationRowsCount - originalVariationRowsCount
|
|
||||||
);
|
|
||||||
} );
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
for ( const attributeValue of variationToCreate ) {
|
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||||
const attributeName = productAttributes.find(
|
await page.locator( '.variations_tab' ).click();
|
||||||
( { options } ) => options.includes( attributeValue )
|
} );
|
||||||
).name;
|
|
||||||
const addAttributeMenu = variationRows
|
await test.step( `Manually add ${ variationsToManuallyCreate.length } variations`, async () => {
|
||||||
.nth( 0 )
|
const variationRows = page.locator(
|
||||||
.locator( 'select', {
|
'.woocommerce_variation h3'
|
||||||
has: page.locator( 'option', {
|
);
|
||||||
hasText: attributeValue,
|
let variationRowsCount = await variationRows.count();
|
||||||
} ),
|
const originalVariationRowsCount = variationRowsCount;
|
||||||
|
|
||||||
|
for ( const variationToCreate of variationsToManuallyCreate ) {
|
||||||
|
await test.step( 'Click "Add manually"', async () => {
|
||||||
|
const addManuallyButton = page.getByRole( 'button', {
|
||||||
|
name: 'Add manually',
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await test.step( `Select "${ attributeValue }" from the "${ attributeName }" attribute menu`, async () => {
|
await addManuallyButton.click();
|
||||||
await addAttributeMenu.selectOption( attributeValue );
|
|
||||||
|
await expect( variationRows ).toHaveCount(
|
||||||
|
++variationRowsCount
|
||||||
|
);
|
||||||
|
|
||||||
|
// verify that the woocommerce_variations_added jQuery trigger was fired
|
||||||
|
const woocommerceVariationsAddedFunctionCalls =
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
window.woocommerceVariationsAddedFunctionCalls
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
woocommerceVariationsAddedFunctionCalls.length
|
||||||
|
).toEqual(
|
||||||
|
variationRowsCount - originalVariationRowsCount
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
}
|
|
||||||
|
|
||||||
await test.step( 'Click "Save changes"', async () => {
|
|
||||||
await page
|
|
||||||
.getByRole( 'button', {
|
|
||||||
name: 'Save changes',
|
|
||||||
} )
|
|
||||||
.click();
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( `Expect the variation ${ variationToCreate.join(
|
|
||||||
', '
|
|
||||||
) } to be successfully saved.`, async () => {
|
|
||||||
let newlyAddedVariationRow;
|
|
||||||
|
|
||||||
for ( const attributeValue of variationToCreate ) {
|
for ( const attributeValue of variationToCreate ) {
|
||||||
newlyAddedVariationRow = (
|
const attributeName = productAttributes.find(
|
||||||
newlyAddedVariationRow || variationRows
|
( { options } ) =>
|
||||||
).filter( {
|
options.includes( attributeValue )
|
||||||
has: page.locator( 'option[selected]', {
|
).name;
|
||||||
hasText: attributeValue,
|
const addAttributeMenu = variationRows
|
||||||
} ),
|
.nth( 0 )
|
||||||
|
.locator( 'select', {
|
||||||
|
has: page.locator( 'option', {
|
||||||
|
hasText: attributeValue,
|
||||||
|
} ),
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Select "${ attributeValue }" from the "${ attributeName }" attribute menu`, async () => {
|
||||||
|
await addAttributeMenu.selectOption(
|
||||||
|
attributeValue
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect( newlyAddedVariationRow ).toBeVisible();
|
await test.step( 'Click "Save changes"', async () => {
|
||||||
} );
|
await page
|
||||||
}
|
.getByRole( 'button', {
|
||||||
} );
|
name: 'Save changes',
|
||||||
} );
|
} )
|
||||||
|
.click();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Expect the variation ${ variationToCreate.join(
|
||||||
|
', '
|
||||||
|
) } to be successfully saved.`, async () => {
|
||||||
|
let newlyAddedVariationRow;
|
||||||
|
|
||||||
|
for ( const attributeValue of variationToCreate ) {
|
||||||
|
newlyAddedVariationRow = (
|
||||||
|
newlyAddedVariationRow || variationRows
|
||||||
|
).filter( {
|
||||||
|
has: page.locator( 'option[selected]', {
|
||||||
|
hasText: attributeValue,
|
||||||
|
} ),
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
await expect( newlyAddedVariationRow ).toBeVisible();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue