Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust e2e tests for minimum and maximum shipping times #2619

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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