-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: customer address update in the My Account section (#1315)
Co-authored-by: Silke <s.grueber@intershop.de>
- Loading branch information
1 parent
80d5f9d
commit a98d391
Showing
14 changed files
with
392 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { fillFormField } from '../../framework'; | ||
import { Registration } from '../account/registration.page'; | ||
import { HeaderModule } from '../header.module'; | ||
|
||
export type AddressDetailsTypes = Partial< | ||
Pick<Registration, 'countryCode' | 'companyName1' | 'firstName' | 'lastName' | 'addressLine1' | 'postalCode' | 'city'> | ||
>; | ||
export class AddressesPage { | ||
readonly header = new HeaderModule(); | ||
readonly tag = 'ish-account-addresses'; | ||
|
||
get defaultAddress() { | ||
return cy.get(this.tag).find('[data-testing-id="preferred-invoice-and-shipping-address"]'); | ||
} | ||
|
||
get furtherAddress() { | ||
return cy.get(this.tag).find('[data-testing-id="further-addresses"]'); | ||
} | ||
|
||
get shippingAddress() { | ||
return cy.get(this.tag).find('[data-testing-id="preferred-shipping-address"]'); | ||
} | ||
|
||
get invoiceAddress() { | ||
return cy.get(this.tag).find('[data-testing-id="preferred-invoice-address"]'); | ||
} | ||
|
||
createAddress() { | ||
cy.get('[data-testing-id="create-address-button"]').click(); | ||
} | ||
|
||
fillForm(user: string, password: string) { | ||
cy.get('input[data-testing-id="login"]').clear().type(user).blur(); | ||
cy.get('input[data-testing-id="password"]').clear().type(password).blur(); | ||
return this; | ||
} | ||
|
||
fillCreateAddressForm(address: AddressDetailsTypes) { | ||
Object.keys(address).forEach(key => fillFormField('[data-testing-id="create-address-form"]', key, address[key])); | ||
return this; | ||
} | ||
|
||
fillUpdateAddressForm(address: AddressDetailsTypes) { | ||
Object.keys(address).forEach(key => fillFormField('[data-testing-id="update-address-form"]', key, address[key])); | ||
return this; | ||
} | ||
|
||
cancel() { | ||
cy.get('button').contains('Cancel').click(); | ||
} | ||
|
||
saveAddress() { | ||
cy.get('button').contains('Save Address').click(); | ||
} | ||
|
||
selectShippingAddress() { | ||
cy.get('select[placeholder="Change preferred shipping address"]').select(1); | ||
} | ||
|
||
selectInvoiceAddress() { | ||
cy.get('select[placeholder="Change preferred invoice address"]').select(2); | ||
} | ||
|
||
updateAddress() { | ||
cy.get('[data-testing-id="update-address-button"]').last().click(); | ||
} | ||
|
||
submit() { | ||
cy.intercept('PUT', '**/customers/**').as('customers'); | ||
cy.wait(500); | ||
|
||
cy.get(this.tag).find('button[type="submit"]').click(); | ||
|
||
return cy.wait('@customers'); | ||
} | ||
|
||
deleteAddress() { | ||
cy.get('[data-testing-id="delete-address-icon"]').last().click(); | ||
cy.get('button').contains('Delete').click(); | ||
} | ||
|
||
get successMessage() { | ||
return { | ||
message: cy.get('#toast-container').find('.toast-message'), | ||
}; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
e2e/cypress/e2e/specs/account/addresses-crud.b2b.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { at } from '../../framework'; | ||
import { createB2BUserViaREST } from '../../framework/b2b-user'; | ||
import { AddressDetailsTypes, AddressesPage } from '../../pages/account/addresses.page'; | ||
import { LoginPage } from '../../pages/account/login.page'; | ||
import { Registration, sensibleDefaults } from '../../pages/account/registration.page'; | ||
|
||
const _ = { | ||
user: { | ||
login: `testuser${new Date().getTime()}@test.intershop.de`, | ||
...sensibleDefaults, | ||
companyName1: 'Big Foods', | ||
} as Registration, | ||
address: { | ||
countryCode: 'DE', | ||
companyName1: 'Intershop', | ||
firstName: 'Pablo', | ||
lastName: 'Parked', | ||
addressLine1: 'Marcher Str. 87', | ||
city: 'Stuttgart', | ||
postalCode: '12345', | ||
} as AddressDetailsTypes, | ||
furtherAddress: { | ||
companyName1: 'Samsung', | ||
firstName: 'Daniel', | ||
lastName: 'Circus', | ||
addressLine1: 'Berg Str. 83', | ||
city: 'Heidelberg', | ||
postalCode: '36890', | ||
countryCode: 'DE', | ||
} as AddressDetailsTypes, | ||
newAddress: { | ||
companyName1: 'Samsung DE', | ||
firstName: 'Daniels', | ||
lastName: 'Decorous', | ||
addressLine1: 'HeidelBerg Str. 83', | ||
city: 'Heidelberg', | ||
postalCode: '36890', | ||
countryCode: 'DE', | ||
} as AddressDetailsTypes, | ||
}; | ||
|
||
describe('Addresses Page Functionality', () => { | ||
before(() => { | ||
createB2BUserViaREST(_.user); | ||
LoginPage.navigateTo('/account/addresses'); | ||
at(LoginPage, page => { | ||
page.fillForm(_.user.login, _.user.password); | ||
page.submit().its('response.statusCode').should('equal', 200); | ||
}); | ||
at(AddressesPage, page => { | ||
page.defaultAddress.should('exist'); | ||
}); | ||
}); | ||
|
||
it('should be able to create address and assign as shipping address', () => { | ||
at(AddressesPage, page => { | ||
page.createAddress(); | ||
cy.wait(500); | ||
page.fillCreateAddressForm(_.address); | ||
page.saveAddress(); | ||
page.furtherAddress.should('contain', _.address.addressLine1); | ||
page.selectShippingAddress(); | ||
page.shippingAddress.should('contain', _.address.addressLine1); | ||
}); | ||
}); | ||
|
||
it('should be able to create a further address and see changes', () => { | ||
at(AddressesPage, page => { | ||
page.createAddress(); | ||
page.fillCreateAddressForm(_.furtherAddress); | ||
page.saveAddress(); | ||
page.furtherAddress.should('contain', _.furtherAddress.addressLine1); | ||
}); | ||
}); | ||
|
||
it('should be able to assign the further address as default invoice address', () => { | ||
at(AddressesPage, page => { | ||
page.selectInvoiceAddress(); | ||
page.invoiceAddress.should('contain', _.furtherAddress.addressLine1); | ||
}); | ||
}); | ||
|
||
it('should be able to update address details and see changes', () => { | ||
at(AddressesPage, page => { | ||
page.updateAddress(); | ||
page.fillUpdateAddressForm(_.newAddress).submit().its('response.statusCode').should('equal', 200); | ||
page.successMessage.message.should('contain', 'updated'); | ||
page.furtherAddress.should('contain', `${_.newAddress.firstName} ${_.newAddress.lastName}`); | ||
}); | ||
}); | ||
|
||
it('should be able to delete an address and see changes', () => { | ||
at(AddressesPage, page => { | ||
page.deleteAddress(); | ||
page.successMessage.message.should('contain', 'deleted'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.