@@ -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
0 commit comments