Skip to content

Commit

Permalink
Use data-cy in fee list test, not fee-list-page class & update the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamik10 committed Dec 20, 2023
1 parent 9ef2f5a commit 100cbb1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/apps/fee-list/FeeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const FeeList: FC = () => {

return (
<>
<div className="fee-list-page">
<div className="fee-list-page" data-cy="fee-list-page">
<h1 data-cy="fee-list-headline" className="text-header-h1 my-32">
{t("feeListHeadlineText")}
</h1>
Expand All @@ -77,7 +77,7 @@ const FeeList: FC = () => {
</>
)}
<List
dataCy="fee-list-before"
dataCy="fee-list"
listHeader={t("unpaidFeesFirstHeadlineText")}
openDetailsModalClickEvent={openDetailsModalClickEvent}
fees={fbsFees}
Expand Down
56 changes: 17 additions & 39 deletions src/apps/fee-list/fee-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("Fee list", () => {
it("Fee list basics (physical loans)", () => {
// 2. System shows:
// 2.a. Headline "Fees & Replacement costs"
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.getBySel("fee-list-headline")
.should("exist")
.should("have.text", "Fees & Replacement costs");
Expand All @@ -130,19 +130,22 @@ describe("Fee list", () => {
cy.getBySel("list-header").should("contain.text", "Unsettled debt");

// 2.d link “See our fees and replacement costs”
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find("[data-cy='fee-list-body']")
.find(".link-tag")
.should("exist")
.should("not.have.attr", "href", "")
.should("have.text", "See our fees and replacement costs");

// 3.b list of intermediates
cy.get(".fee-list-page").find(".list-reservation").eq(0).should("exist");
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist");

// 3.c metadata
// 3.c.a material type
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -154,7 +157,7 @@ describe("Fee list", () => {
.should("have.text", "Dummy bog");

// 3.c.b title
cy.get("[data-cy='fee-list-before']")
cy.get("[data-cy='fee-list']")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -163,7 +166,7 @@ describe("Fee list", () => {
.should("have.text", "Dummy Some Title");

// 3.c.c author
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -178,7 +181,7 @@ describe("Fee list", () => {
);

// 3. d fees charged dd.mm.yyyy
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -190,7 +193,7 @@ describe("Fee list", () => {
.should("have.text", "Fees charged 06. 04. 2022");

// 3. e Label: reason
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -202,51 +205,26 @@ describe("Fee list", () => {
.should("have.text", "Gebyr (for sent)");

// 3. e Label: fee amount
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
.find(".list-reservation__status")
.find(".list-reservation__fee")
.find(".text-body-medium-regular")
.should("exist")
.should("have.text", "Fee 2.56,-");

// 4. a List after date
// Title
cy.get("[data-cy='fee-list-after']")
.find(".list-reservation")
.eq(0)
.should("exist")
.find(".text-header-h4")
.should("exist")
.should("have.text", "Dummy Some Title");

// Author && year
cy.get(".fee-list-page")
.find(".list-reservation")
.eq(1)
.should("exist")
.find(".list-reservation__material")
.find(".list-reservation__information")
.find(".list-reservation__about")
.find(".text-small-caption")
.should("exist")
.should(
"have.text",
"By Dummy Jens Jensen and Dummy Some Corporation (2006)"
);
.should("have.text", "Fee 70,-");

// 4.b +x other materials
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(1)
.should("exist")
.getBySel("stack-size")
.should("exist")
.should("have.text", "+ 2 other materials");

cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(1)
.should("exist")
Expand All @@ -258,7 +236,7 @@ describe("Fee list", () => {
.find("div")
.find(".counter")
.find(".counter__value")
.should("have.text", "32");
.should("have.text", "180");

// counter text
cy.get("div.modal-loan__header")
Expand All @@ -273,7 +251,7 @@ describe("Fee list", () => {
.find("div")
.find(".modal-loan__title")
.should("exist")
.should("have.text", "Turned in 6. April 2022");
.should("have.text", "Turned in 18. October 2019");

// "i accept the Terms of trade*"
cy.getBySel("checkbox_id__fee_details").should("exist");
Expand Down

0 comments on commit 100cbb1

Please sign in to comment.