Skip to content

Commit

Permalink
test(my-store): implement e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
karenhsieh75 committed May 24, 2024
1 parent 355cf13 commit 416ed80
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions cypress/e2e/my-store.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
describe("8. My Store Page", () => {
beforeEach(() => {
cy.viewport(375, 464);
cy.visit("/");

// avoid repeated login
cy.session("login", () => {
cy.login();
});
cy.visit("/my/stores");
});

context("8.1 info section", () => {
it("post display correct information", () => {
cy.get(".rounded-lg")
.eq(0)
.then(($el) => {
cy.wrap($el).find("img").should("exist");
cy.wrap($el).find(".font-semibold").should("exist");
cy.wrap($el).find(".text-sm").should("exist");
cy.wrap($el).find(".text-muted-foreground").should("exist");
});
});
});

context("8.2 store dish management", () => {
it("can increase dish count", () => {
cy.get(".rounded-lg").eq(0).find("button").click();
cy.wait(1000);
cy.get(".rounded-lg")
.eq(0)
.then(($el) => {
const text = $el.find("p").text();
const cnt = parseInt(text, 10);
cy.wrap($el).find("svg").eq(2).click({ force: true });
cy.contains("Store dish has been updated.").should("be.visible");
cy.wrap($el)
.find("p")
.should("contain", `${cnt + 1}`);
});
});

it("can decrease dish count", () => {
cy.get(".rounded-lg").eq(0).find("button").click();
cy.wait(1000);
cy.get(".rounded-lg")
.eq(0)
.then(($el) => {
const text = $el.find("p").text();
const cnt = parseInt(text, 10);
cy.wrap($el).find("svg").eq(1).click({ force: true });
cy.contains("Store dish has been updated.").should("be.visible");
cy.wrap($el)
.find("p")
.should("contain", `${cnt - 1}`);
});
});

it("can finish reservation", () => {
cy.get(".rounded-lg").eq(0).find("button").click();
cy.wait(1000);
cy.get(".rounded-lg.cursor-pointer").eq(0).find("button").eq(0).click();
cy.contains("confirm").click();
cy.contains("Reservation has been finished").should("exist");
});

it.only("can cancel reservation", () => {
cy.get(".rounded-lg").eq(0).find("button").click();
cy.wait(1000);
cy.get(".rounded-lg.cursor-pointer").eq(0).find("button").eq(1).click();
cy.contains("confirm").click();
cy.contains("Store reservation has been deleted").should("exist");
});
});
});

0 comments on commit 416ed80

Please sign in to comment.