-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add e2e testing to catch up to Week 13 (#237)
- Loading branch information
1 parent
39a9c26
commit 82c38b8
Showing
14 changed files
with
228 additions
and
18 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 @@ | ||
!*.mp4 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe("Logout page", () => { | ||
beforeEach(() => {}); | ||
|
||
it("should redirect a logged out user to login", () => { | ||
cy.visit("/logout"); | ||
cy.wait(250); | ||
cy.url().should("include", "/login"); | ||
}); | ||
|
||
it("should clear a user session", () => { | ||
cy.visit("/login"); | ||
cy.get("input[name=email]").type("johnny@example.com"); | ||
cy.get("input[name=password]").type("password"); | ||
cy.get("button[type=submit]").click(); | ||
cy.wait(250); | ||
cy.url().should("match", /\/$/); | ||
cy.visit("/logout"); | ||
cy.wait(250); | ||
cy.visit("/user/dashboard"); | ||
cy.wait(500); | ||
cy.url().should("include", "/login"); | ||
}); | ||
}); |
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,28 @@ | ||
describe("Staff page rendering", () => { | ||
beforeEach(() => { | ||
cy.visit("/staff"); | ||
cy.wait(250); | ||
cy.get("input[name=email]").type("johnny@example.com"); | ||
cy.get("input[name=password]").type("password"); | ||
cy.get("button[type=submit]").click(); | ||
cy.wait(250); | ||
}); | ||
|
||
it("Should show the staff page", () => { | ||
cy.get("main[aria-label='Staff-only page']"); | ||
}); | ||
|
||
it("Should show a sample list of users", () => { | ||
const usersList = cy.get("[aria-label='Example user list']"); | ||
usersList.should("exist"); | ||
usersList.get("h2").should("contain", "Users List"); | ||
}); | ||
}); | ||
|
||
describe("Staff page functionality", () => { | ||
it("Should redirect to /login if not logged in", () => { | ||
cy.visit("/staff"); | ||
cy.wait(250); | ||
cy.url().should("include", "/login"); | ||
}); | ||
}); |
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,49 @@ | ||
describe("Video upload rendering", () => { | ||
beforeEach(() => { | ||
cy.visit("/upload"); | ||
}); | ||
|
||
it("should contain a heading", () => { | ||
cy.get("h1").contains("Upload a Video"); | ||
}); | ||
|
||
it("should contain an video upload form", () => { | ||
cy.get("form[aria-label='Video upload form']").should("exist"); | ||
}); | ||
|
||
it("should contain a file input", () => { | ||
cy.get("input[type=file]").should("exist"); | ||
}); | ||
|
||
it("should contain a submit button", () => { | ||
cy.get("button[aria-label='Submit video']").should("exist"); | ||
}); | ||
|
||
it("should contain a disabled record button", () => { | ||
const recordButton = cy.get("button[aria-label='Record video']"); | ||
recordButton.should("exist"); | ||
recordButton.should("be.disabled"); | ||
}); | ||
}); | ||
|
||
describe("Video upload functionality", () => { | ||
beforeEach(() => { | ||
cy.visit("/upload"); | ||
}); | ||
|
||
it("should not upload a video when not logged in", () => { | ||
cy.intercept( | ||
{ | ||
method: "POST", | ||
url: "/api/video/upload", | ||
}, | ||
{ data: { success: true, filePath: "test.mp4" } } | ||
).as("videoUploadApi"); | ||
cy.get("input[type=file]").selectFile("cypress/test-data/test.mp4"); | ||
cy.get("button[aria-label='Submit video']").click(); | ||
cy.wait("@videoUploadApi").then((interception) => { | ||
expect(interception.response.statusCode).to.equal(200); | ||
}); | ||
cy.url().should("include", "/upload/status"); | ||
}); | ||
}); |
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,50 @@ | ||
describe("User dashboard functionality", () => { | ||
it("should redirect to /login if not logged in", () => { | ||
cy.visit("/user/dashboard"); | ||
cy.wait(250); | ||
cy.url().should("include", "/login"); | ||
}); | ||
|
||
it("should display the user dashboard if logged in", () => { | ||
cy.visit("/user/dashboard"); | ||
cy.wait(250); | ||
cy.url().should("include", "/login"); | ||
cy.get("input[name=email]").type("johnny@example.com"); | ||
cy.get("input[name=password]").type("password"); | ||
cy.get("button[type=submit]").click(); | ||
cy.wait(250); | ||
cy.url().should("include", "/user/dashboard"); | ||
}); | ||
}); | ||
|
||
describe("User dashboard rendering", () => { | ||
beforeEach(() => { | ||
cy.visit("/user/dashboard"); | ||
cy.wait(250); | ||
cy.url().should("include", "/login"); | ||
cy.get("input[name=email]").type("johnny@example.com"); | ||
cy.get("input[name=password]").type("password"); | ||
cy.get("button[type=submit]").click(); | ||
cy.wait(250); | ||
cy.url().should("include", "/user/dashboard"); | ||
}); | ||
|
||
it("should display the user dashboard", () => { | ||
cy.get("h1").contains("Hi,"); | ||
cy.get("div[aria-label='User Dashboard']").should("exist"); | ||
}); | ||
|
||
it("should have an appointments section", () => { | ||
cy.get("h2").contains("Upcoming Appointments"); | ||
cy.get("div[aria-label='Upcoming Appointments']").should("exist"); | ||
}); | ||
|
||
it("should have a user card", () => { | ||
cy.get("div[aria-label='Your Personal Information']").should("exist"); | ||
}); | ||
|
||
it("should have a recent messages section", () => { | ||
cy.get("h2").contains("Recent Messages"); | ||
cy.get("div[aria-label='Recent Messages']").should("exist"); | ||
}); | ||
}); |
Binary file not shown.
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,12 @@ | ||
/* | ||
* Created on Sun Dec 03 2023 | ||
* Author: Connor Doman | ||
*/ | ||
|
||
interface StaffAreaLayoutProps { | ||
children?: React.ReactNode; | ||
} | ||
|
||
export default async function StaffAreaLayout({ children }: StaffAreaLayoutProps) { | ||
return <main aria-label="Staff-only page">{children}</main>; | ||
} |
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
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