forked from TonyMckes/conduit-realworld-example-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
63 additions
and
0 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,15 @@ | ||
import UserSettingsPage from "../page-objects/user-settings-page"; | ||
|
||
describe("Check logout feature", { tags: "@user" }, () => { | ||
before(() => { | ||
cy.loginWithSession(Cypress.env("email"), Cypress.env("password")); | ||
UserSettingsPage.visit(); | ||
}); | ||
|
||
it("Should navigate to home page after logout", () => { | ||
UserSettingsPage.userPic().click(); | ||
cy.getByTestId("logout").click(); | ||
cy.url().should("eq", Cypress.config().baseUrl + "/"); | ||
UserSettingsPage.userPic().should("not.exist"); | ||
}); | ||
}); |
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,33 @@ | ||
import SignUpPage from "../page-objects/signup-page"; | ||
import Utils from "../utils/utils"; | ||
import UserSettingsPage from "../page-objects/user-settings-page"; | ||
|
||
describe("Sign up feature", () => { | ||
beforeEach(() => { | ||
SignUpPage.visit(); | ||
}); | ||
|
||
it("Should register valid new user", () => { | ||
const newUser = Utils.generateNewUserData(); | ||
cy.intercept("GET", "**/api/user").as("getUser"); | ||
SignUpPage.fillForm(newUser); | ||
UserSettingsPage.userPic().parent().should("have.text", newUser.username); | ||
cy.wait("@getUser").then((user) => { | ||
expect(user.response.body.user.email, "User email").to.eq(newUser.email); | ||
}); | ||
}); | ||
|
||
it("Should display error message for email already in use", () => { | ||
cy.intercept("POST", "**/api/users").as("getUser"); | ||
SignUpPage.fillForm({ | ||
username: "testuser", | ||
email: Cypress.env("email"), | ||
password: "password", | ||
}); | ||
cy.wait("@getUser").its("response.statusCode").should("eq", 422); | ||
SignUpPage.errorMessages().should( | ||
"have.text", | ||
"Email already exists.. try logging in" | ||
); | ||
}); | ||
}); |
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,15 @@ | ||
export default class SignUpPage { | ||
static visit() { | ||
cy.visit("/register"); | ||
} | ||
|
||
static fillForm({ username, email, password }) { | ||
cy.getByTestId("username").type(username); | ||
cy.getByTestId("email").type(email); | ||
cy.getByTestId("password").type(password + "{enter}"); | ||
} | ||
|
||
static errorMessages() { | ||
return cy.getByTestId("signup-error"); | ||
} | ||
} |