Skip to content

Commit

Permalink
test: authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
boomchanotai committed Feb 20, 2024
1 parent 68aee32 commit 88e5319
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
5 changes: 2 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: "http://localhost:5173",
testIsolation: false,
},
});
59 changes: 56 additions & 3 deletions cypress/e2e/authentication.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
describe("template spec", () => {
it("passes", () => {
cy.visit("https://example.cypress.io");
describe("authentication", () => {
it("can visit the site", () => {
cy.visit("/");
cy.wait(2000);
localStorage.clear();
});

it("can open sidebar", () => {
cy.get("#open-sidebar").click();
});

it("can navigate to login page", () => {
cy.get("a").contains("Admin Login").click();

cy.wait(1000);
cy.url().should("include", "/admin");
cy.get("h1").contains("เข้าสู่ระบบ");
});

it("can login", () => {
cy.wait(2000);
cy.get(`input[name="email"]`).type("[email protected]");
cy.get(`input[name="password"]`).type("12345678");
cy.get("button").contains("เข้าสู่ระบบ").click();

cy.wait(2000);
cy.url().should("include", "/admin/pets");
cy.get("#open-sidebar").click();
cy.get("button").contains("Logout").should("exist");
});

it("can logout", () => {
cy.get("button").contains("Logout").click();

cy.wait(1000);
cy.url().should("include", "/admin");
});

it("can navigate to forget password page", () => {
cy.get("a").contains("ลืมรหัสผ่าน?").click();

cy.wait(1000);
cy.url().should("include", "/admin/forget-password");
cy.get("h1").contains("ลืมรหัสผ่าน?");
});

it("can request forget password", () => {
cy.get(`input[name="email"]`).type("[email protected]");
cy.get("button").contains("รีเซตรหัสผ่าน").click();

cy.wait(1000);
cy.get("h2").contains("อีเมลรีเซ็ตถูกส่งแล้ว").should("exist");
cy.get("button").contains("กลับไปหน้าเข้าสู่ระบบ").click();

cy.wait(1000);
cy.url().should("include", "/admin");
});
});

0 comments on commit 88e5319

Please sign in to comment.