fix: cypress test

This commit is contained in:
Jayden Pyles
2025-05-31 19:29:48 -05:00
parent 41c7f6795c
commit ff809d7833
4 changed files with 51 additions and 19 deletions

View File

@@ -0,0 +1,23 @@
describe("Global setup", () => {
it("signs up user once", () => {
cy.request({
method: "POST",
url: "/api/signup",
body: JSON.stringify({
data: {
email: "test@test.com",
password: "password",
full_name: "John Doe",
},
}),
headers: {
"Content-Type": "application/json",
},
failOnStatusCode: false,
}).then((response) => {
if (response.status !== 200 && response.status !== 201) {
console.warn("Signup failed:", response.status, response.body);
}
});
});
});

View File

@@ -18,20 +18,3 @@ import "./commands";
// Alternatively you can use CommonJS syntax:
// require('./commands')
before(() => {
cy.request({
method: "POST",
url: "/api/signup",
body: {
email: "test@test.com",
password: "password",
fullName: "John Doe",
},
failOnStatusCode: false,
}).then((response) => {
if (response.status !== 200 && response.status !== 201) {
console.warn("Signup failed:", response.status, response.body);
}
});
});

View File

@@ -27,6 +27,8 @@ export const signup = () => {
export const login = () => {
cy.intercept("POST", "/api/token").as("token");
cy.intercept("GET", "/api/me").as("me");
cy.intercept("GET", "/api/check").as("check");
cy.visit("/").then(() => {
cy.get("body").then(() => {
@@ -43,9 +45,23 @@ export const login = () => {
cy.log("No response received!");
throw new Error("token request did not return a response");
}
cy.url().should("not.include", "/login");
});
cy.wait("@me").then((interception) => {
if (!interception.response) {
cy.log("No response received!");
throw new Error("me request did not return a response");
}
});
cy.wait("@check").then((interception) => {
if (!interception.response) {
cy.log("No response received!");
throw new Error("check request did not return a response");
}
});
cy.url().should("not.include", "/login");
});
});
});

View File

@@ -1,5 +1,15 @@
export const cleanUpJobs = () => {
cy.intercept("POST", "/api/retrieve").as("retrieve");
cy.visit("/jobs");
cy.wait("@retrieve", { timeout: 10000 }).then((interception) => {
if (!interception.response) {
cy.log("No response received!");
throw new Error("retrieve request did not return a response");
}
});
cy.get("tbody tr")
.first()
.within(() => {