use of page.fill() in variable product e2e tests (#37854)

* tweeak: use locator to fill values

* chore: log change

* format: improve code formatting

* chore: remove locator refference from variable name

* Update create-variable-product.spec.js

Specify last element with selector

* Update create-variable-product.spec.js

Different selector

* Update create-variable-product.spec.js

Third time is a charm.

* Update create-variable-product.spec.js

.second doesn't exist.  User .nth

---------

Co-authored-by: Jonathan Lane <lanej0@users.noreply.github.com>
This commit is contained in:
Ravinder Kumar 2023-04-25 13:15:33 +05:30 committed by GitHub
parent 7cbc3811d8
commit f58ea73702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Use locator.fill to fill variation values in the form instead of page.fill

View File

@ -232,7 +232,9 @@ test.describe( 'Add New Variable Product Page', () => {
await test.step(
`Type "${ variableProductName }" into the "Product name" input field.`,
async () => {
await page.fill( '#title', variableProductName );
await page
.getByLabel( 'Product name' )
.fill( variableProductName );
}
);
@ -715,7 +717,7 @@ test.describe( 'Add New Variable Product Page', () => {
page,
} ) => {
await page.goto( productPageURL );
await page.fill( '#title', manualVariableProduct );
await page.getByLabel( 'Product name' ).fill( manualVariableProduct );
await page.selectOption( '#product-type', 'variable' );
await page
@ -808,15 +810,27 @@ test.describe( 'Add New Variable Product Page', () => {
'#variable_product_options .toolbar-top a.expand_all'
);
await page.check( 'input.checkbox.variable_manage_stock' );
await page.fill( 'input#variable_regular_price_0', variationOnePrice );
const firstVariationContainer = await page
.locator( '.woocommerce_variations .woocommerce_variation' )
.first();
await firstVariationContainer
.getByPlaceholder( 'Variation price (required)' )
.fill( variationOnePrice );
await expect(
page.locator( 'p.variable_stock_status' )
).not.toBeVisible();
await page.fill( 'input#variable_stock0', stockAmount );
await firstVariationContainer
.getByLabel( 'Stock quantity' )
.nth(1)
.fill( stockAmount );
await page.selectOption( '#variable_backorders0', 'notify', {
force: true,
} );
await page.fill( 'input#variable_low_stock_amount0', lowStockAmount );
await firstVariationContainer
.getByPlaceholder( 'Store-wide threshold (2)' )
.fill( lowStockAmount );
await page.click( 'button.save-variation-changes' );
await page.click(
'#variable_product_options .toolbar-top a.expand_all'