mirror of
https://github.com/jaypyles/Scraperr.git
synced 2025-11-11 11:55:59 +00:00
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
export const signup = () => {
|
|
cy.intercept("POST", "/api/token").as("token");
|
|
|
|
cy.visit("/").then(() => {
|
|
cy.get("button").contains("Login").click();
|
|
cy.url().should("include", "/login");
|
|
|
|
cy.get("form").should("be.visible");
|
|
cy.get("button")
|
|
.contains("No Account? Sign up")
|
|
.should("be.visible")
|
|
.click();
|
|
|
|
cy.get("input[name='email']").type("test@test.com");
|
|
cy.get("input[name='password']").type("password");
|
|
cy.get("input[name='fullName']").type("John Doe");
|
|
cy.get("button[type='submit']").contains("Signup").click();
|
|
|
|
cy.wait("@token").then((interception) => {
|
|
if (!interception.response) {
|
|
cy.log("No response received!");
|
|
throw new Error("token request did not return a response");
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
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(() => {
|
|
cy.get("button")
|
|
.contains("Login")
|
|
.click()
|
|
.then(() => {
|
|
cy.get("input[name='email']").type("test@test.com");
|
|
cy.get("input[name='password']").type("password");
|
|
cy.get("button[type='submit']").contains("Login").click();
|
|
|
|
cy.wait("@token").then((interception) => {
|
|
if (!interception.response) {
|
|
cy.log("No response received!");
|
|
throw new Error("token request did not return a response");
|
|
}
|
|
});
|
|
|
|
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");
|
|
});
|
|
});
|
|
});
|
|
};
|