Skip to content

Commit

Permalink
Adjust e2e tests for min and max shipping times
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemd24 committed Sep 18, 2024
1 parent 8652d24 commit 5a9db1a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/specs/dashboard/edit-free-listings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test.describe( 'Edit Free Listings', () => {

test( 'Check recommended shipping settings', async () => {
await editFreeListingsPage.checkRecommendShippingSettings();
await editFreeListingsPage.fillCountriesShippingTimeInput( '5' );
await editFreeListingsPage.fillCountriesShippingTimeInput( '5', '10' );
await editFreeListingsPage.checkDestinationBasedTaxRates();
const saveChangesButton =
await editFreeListingsPage.getSaveChangesButton();
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/specs/setup-mc/step-2-product-listings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ test.describe( 'Configure product listings', () => {
await expect( minimumOrderForFreeShippingText ).toBeVisible();
} );

test( 'should show error message if clicking "Continue" button when shipping time is < 0', async () => {
await productListingsPage.fillEstimatedShippingTimes( '-1' );
test( 'should show error message if min shipping time is bigger than max time', async () => {
await productListingsPage.fillEstimatedShippingTimes( '9', '7' );
await productListingsPage.clickContinueButton();
const estimatedTimesError =
productListingsPage.getEstimatedShippingTimesError();
Expand Down Expand Up @@ -370,7 +370,7 @@ test.describe( 'Configure product listings', () => {
request.postDataJSON().time === 14
);

await productListingsPage.fillEstimatedShippingTimes( '14' );
await productListingsPage.fillEstimatedShippingTimes( '14', '20' );

const request = await requestPromise;
const response = await request.response();
Expand Down Expand Up @@ -438,7 +438,7 @@ test.describe( 'Configure product listings', () => {
// Mock MC contact information
productListingsPage.mockContactInformation();
productListingsPage.checkRecommendedShippingRateRadioButton();
await productListingsPage.fillEstimatedShippingTimes( '14' );
await productListingsPage.fillEstimatedShippingTimes( '14', '20' );
await productListingsPage.checkNonDestinationBasedTaxRateRadioButton();
} );

Expand Down
9 changes: 6 additions & 3 deletions tests/e2e/utils/pages/edit-free-listings.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ export default class EditFreeListingsPage extends MockRequests {
/**
* Fill the countries shipping time input.
*
* @param {string} input The shipping time
* @param {string} min The minimum shipping time
* @param {string} max The maximum shipping time
* @return {Promise<void>}
*/
async fillCountriesShippingTimeInput( input ) {
await this.page.locator( '.countries-time input' ).fill( input );
async fillCountriesShippingTimeInput( min, max ) {
const timesLocator = this.page.locator( '.countries-time input' );
await timesLocator.first().fill( min );
await timesLocator.last().fill( max );
}

/**
Expand Down
14 changes: 9 additions & 5 deletions tests/e2e/utils/pages/setup-mc/step-2-product-listings.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class ProductListingsPage extends MockRequests {
*/
getEstimatedShippingTimesError() {
return this.getEstimatedShippingTimesCard().getByText(
'Please specify estimated shipping times for all the countries, and the time cannot be less than 0'
'The minimum shipping time must not be more than the maximum shipping time.'
);
}

Expand Down Expand Up @@ -514,16 +514,20 @@ export default class ProductListingsPage extends MockRequests {
/**
* Fill estimated shipping times.
*
* @param {string} days
* @param {string} min The minimum shipping time
* @param {string} max The maximum shipping time
*
* @return {Promise<void>}
*/
async fillEstimatedShippingTimes( days = '0' ) {
async fillEstimatedShippingTimes( min = '0', max = '10' ) {
const estimatedTimesInputBox = this.getEstimatedShippingTimesInputBox();
await estimatedTimesInputBox.fill( days );

await estimatedTimesInputBox.first().fill( min );
await estimatedTimesInputBox.last().fill( max );

// A hack to finish typing in the input box, similar to pressing anywhere in the page.
await estimatedTimesInputBox.press( 'Tab' );
await estimatedTimesInputBox.first().press( 'Tab' );
await estimatedTimesInputBox.last().press( 'Tab' );

await this.page.waitForLoadState( LOAD_STATE.DOM_CONTENT_LOADED );
}
Expand Down

0 comments on commit 5a9db1a

Please sign in to comment.