Skip to content

Commit 1ee11d0

Browse files
committed
small changes
1 parent 6d9c000 commit 1ee11d0

4 files changed

Lines changed: 29 additions & 22 deletions

File tree

helpers/optionalParamsInterfaces/OptionalParams.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ export interface ClientSideValiationErrorOptionalParamsInterface {
3434

3535

3636
export interface UserShippingDetailsParams {
37-
company?: string, streetAddress?: string, streetFieldindex?: number, city?: string, state?: string,
38-
postalCode?: string, country?: string, phoneNumber?: string, shippingMethod?: string, firstname?: string,
37+
company?: string,
38+
streetAddress?: string,
39+
streetFieldIndex?: number,
40+
city?: string,
41+
state?: string,
42+
postalCode?: string,
43+
country?: string,
44+
phoneNumber?: string,
45+
shippingMethod?: string,
46+
firstname?: string,
3947
lastname?: string
4048
}

pages/checkoutPage/CheckOutShippingPage.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,25 @@ export class CheckoutShippingPage extends LumaMainPage {
3737
if (options?.signIn && options.email !== undefined && options.password !== undefined) {
3838
await this.signIn(options.email, options.password)
3939
await this.page.waitForTimeout(2500);
40-
const existingUserAddressDetails = this.page.locator(this.existingAddressLocator);
41-
const isUserAddressDetailsVisibile = await existingUserAddressDetails.isVisible()
42-
if (!isUserAddressDetailsVisibile) {
43-
await this.fillCompanyName(options.company!);
44-
await this.fillStreetAddress(options.streetFieldindex!, options.streetAddress!);
45-
await this.fillCityName(options.city!);
46-
await this.selectState(options.state!)
47-
await this.fillPostalCode(options.postalCode!);
48-
await this.selectCountry(options.country!);
49-
await this.fillPhoneNumber(options.phoneNumber!);
50-
await this.chooseShippingMethod(options.shippingMethod!);
51-
} else {
52-
const addressDetails = await this.getAddressDetailsList();
53-
expect(addressDetails).toEqual(options.expectedUserAddressDetails);
54-
}
55-
await this.chooseShippingMethod(options.shippingMethod!)
5640
} else if (options?.email !== undefined && options.firstname !== undefined && options.lastname !== undefined) {
5741
await this.fillEmailAddress(options?.email!);
5842
await this.fillFirstName(options?.firstname!);
5943
await this.fillLastName(options?.lastname!);
44+
}
45+
const existingUserAddressDetails = this.page.locator(this.existingAddressLocator);
46+
const isUserAddressDetailsVisibile = await existingUserAddressDetails.isVisible()
47+
if (isUserAddressDetailsVisibile) {
48+
const addressDetails = await this.getAddressDetailsList();
49+
expect(addressDetails).toEqual(options?.expectedUserAddressDetails);
6050
} else {
61-
throw new Error('none of the conditions were satisfied in the fillShippingDetails function')
51+
await this.fillCompanyName(options?.company!);
52+
await this.fillStreetAddress(options?.streetFieldIndex!, options?.streetAddress!);
53+
await this.fillCityName(options?.city!);
54+
await this.selectState(options?.state!)
55+
await this.fillPostalCode(options?.postalCode!);
56+
await this.selectCountry(options?.country!);
57+
await this.fillPhoneNumber(options?.phoneNumber!);
58+
await this.chooseShippingMethod(options?.shippingMethod!);
6259
}
6360
}
6461

pages/checkoutPage/CheckoutReviewAndPaymentPage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export class CheckoutReviewAndPaymentPage extends LumaMainPage {
1717
public async validateBillingAndShippingDetails(billingShippingDetails: string[]) {
1818
const shippingDetailsInnerText = await this.getInnerText(this.billingAddressDetailsLocator);
1919
const shippingDetailsList = shippingDetailsInnerText.split('\n')
20-
expect(shippingDetailsList).toContain(billingShippingDetails);
20+
shippingDetailsList.splice(shippingDetailsList.indexOf('edit'), 5);
21+
expect(shippingDetailsList).toEqual(billingShippingDetails);
2122
}
2223

2324
public async validateOrderSummaryExpenses(tableRowText: string, expectedOrderTotal: string) {

tests/menCategoryShopping/BuyFilteredProductFromMenCategory.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ test('purchase product from specific category', { tag: ['@MEN_CATEGORY_SHOPPING'
2525
let phoneNumber: string = Randomizer.getRandomPhoneNumber();
2626
let shippingMethod: string = 'Best Way';
2727
let purchaseConfirmation: string = 'Thank you for your purchase!';
28+
let streetFieldIndex: number = 0;
2829

2930
await test.step('choose men category then hover over men tops and click on jackets', async () => {
3031
await menCategoryPage.chooseMenuBarOption(MenuBar.MEN);
@@ -43,9 +44,9 @@ test('purchase product from specific category', { tag: ['@MEN_CATEGORY_SHOPPING'
4344
await menCategoryPage.performActionsOnShoppingCart({ cartTotalItems: cartQuantity, clickProceedToCheckout: true })
4445
})
4546
await test.step('fill shipping details, choose shipping method and click on next for payment address validation', async () => {
46-
await checkoutShippingPage.fillShippingDetails({ email, firstname, lastname, country, company, streetAddress, city, state, postalCode, phoneNumber, shippingMethod });
47+
await checkoutShippingPage.fillShippingDetails({ email, firstname, lastname, country, company, streetFieldIndex: streetFieldIndex, streetAddress, city, state, postalCode, phoneNumber, shippingMethod });
4748
await checkoutShippingPage.clickNext();
48-
await checkoutPaymentPage.validateBillingAndShippingDetails([`${firstname} ${lastname}`, streetAddress, `${city}, ${state} ${postalCode}`, country, phoneNumber])
49+
await checkoutPaymentPage.validateBillingAndShippingDetails([`${firstname} ${lastname}`, streetAddress, `${city}, ${state} ${postalCode}`, country, phoneNumber])
4950
})
5051
await test.step('place order and validate order was successful', async () => {
5152
await checkoutPaymentPage.clickPlaceOrder();

0 commit comments

Comments
 (0)