2021-09-27 10:04:21 +00:00
|
|
|
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
Cypress.Commands.add("assertVisibility", selector => {
|
2021-07-12 13:35:26 +00:00
|
|
|
cy.get(selector).then(
|
2022-06-27 16:49:35 +00:00
|
|
|
element => expect(element, "element should be visible").to.be.visible,
|
2021-07-12 13:35:26 +00:00
|
|
|
);
|
2021-02-11 12:20:00 +00:00
|
|
|
});
|
2021-07-15 10:25:39 +00:00
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
"expectCorrectBasicAddress",
|
|
|
|
(responseAddress, expectedAddress) => {
|
2022-06-27 09:30:51 +00:00
|
|
|
expect(responseAddress.city.toUpperCase()).to.eq(
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.city.toUpperCase(),
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(responseAddress).to.have.property(
|
|
|
|
"countryArea",
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.countryArea,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(responseAddress).to.have.property("phone", expectedAddress.phone);
|
|
|
|
expect(responseAddress).to.have.property(
|
|
|
|
"postalCode",
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.postalCode,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(responseAddress).to.have.property(
|
|
|
|
"streetAddress1",
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.streetAddress1,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(responseAddress).to.have.property(
|
|
|
|
"streetAddress2",
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.streetAddress2,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-15 10:25:39 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
"expectCorrectFullAddress",
|
|
|
|
(responseAddress, expectedAddress) => {
|
2022-06-27 09:30:51 +00:00
|
|
|
expect(responseAddress).to.have.property(
|
|
|
|
"firstName",
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.firstName,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
|
|
|
expect(responseAddress).to.have.property(
|
|
|
|
"firstName",
|
2022-06-27 16:49:35 +00:00
|
|
|
expectedAddress.lastName,
|
2022-06-27 09:30:51 +00:00
|
|
|
);
|
2021-07-15 10:25:39 +00:00
|
|
|
cy.expectCorrectBasicAddress(responseAddress, expectedAddress);
|
2022-06-27 16:49:35 +00:00
|
|
|
},
|
2021-07-15 10:25:39 +00:00
|
|
|
);
|
2021-09-27 10:04:21 +00:00
|
|
|
|
2022-06-27 09:30:51 +00:00
|
|
|
Cypress.Commands.add("expectSkeletonIsVisible", () => {
|
2021-09-27 10:04:21 +00:00
|
|
|
cy.get(SHARED_ELEMENTS.circularProgress).should("not.exist");
|
2022-04-28 07:52:57 +00:00
|
|
|
cy.get(SHARED_ELEMENTS.progressBar).should("be.visible");
|
2021-09-27 10:04:21 +00:00
|
|
|
cy.get("body").then($body => {
|
|
|
|
if ($body.find(SHARED_ELEMENTS.skeleton).length) {
|
2022-06-27 09:30:51 +00:00
|
|
|
cy.assertVisibility(SHARED_ELEMENTS.skeleton);
|
2021-09-27 10:04:21 +00:00
|
|
|
} else {
|
2022-06-27 09:30:51 +00:00
|
|
|
expect(
|
2022-06-27 16:49:35 +00:00
|
|
|
$body.find(SHARED_ELEMENTS.skeleton, "skeleton should exist").length,
|
2022-06-27 09:30:51 +00:00
|
|
|
).to.be.eq(1);
|
2021-09-27 10:04:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-06-06 10:27:18 +00:00
|
|
|
|
|
|
|
Cypress.Commands.add("waitForSkeletonToDisappear", () => {
|
|
|
|
cy.get(SHARED_ELEMENTS.skeleton)
|
|
|
|
.should("be.visible")
|
|
|
|
.get(SHARED_ELEMENTS.skeleton)
|
|
|
|
.should("not.exist");
|
|
|
|
});
|