-
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.
n70: test: Authorization page JEST -> CYPRESS
- Loading branch information
1 parent
2711418
commit 4cb7b9d
Showing
2 changed files
with
53 additions
and
74 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,53 @@ | ||
import { testUsers } from "#utils/testing/test-users" | ||
|
||
describe("Authorization", () => { | ||
it("logs in successfully", () => { | ||
cy.visit("/auth") | ||
|
||
expect(localStorage.authToken).to.be.equal(undefined) | ||
cy.contains("Welcome").should("be.visible") | ||
cy.contains("Log in").should("be.disabled") | ||
cy.get('input[name="username"]').type("john-doe") | ||
cy.get('input[name="password"]').type("john-doe-password") | ||
cy.contains("Log in").should("be.enabled").click() | ||
cy.contains("Welcome").should("not.exist") | ||
expect(localStorage.authToken).to.match(/.+/) | ||
cy.contains("Log in").should("not.exist") | ||
cy.contains("Log out").should("be.visible") | ||
cy.contains("You are logged in as john-doe.").should("be.visible") | ||
}) | ||
|
||
it("case: user enters unexisting username", () => { | ||
cy.visit("/auth") | ||
|
||
cy.get('input[name="username"]').type("john-doe-WITH-A-TYPO") | ||
cy.get('input[name="password"]').type("john-doe-password") | ||
cy.contains("Log in").click() | ||
cy.contains("User not found.").should("be.visible") | ||
cy.get('input[name="username"]').clear().type("john-doe") | ||
cy.contains("Log in").click() | ||
cy.contains("You are logged in as john-doe.").should("be.visible") | ||
}) | ||
|
||
it("case: user enters invalid password", () => { | ||
cy.visit("/auth") | ||
|
||
cy.get('input[name="username"]').type("john-doe") | ||
cy.get('input[name="password"]').type("john-doe-password-WITH-A-TYPO") | ||
cy.contains("Log in").click() | ||
cy.contains("Invalid password.").should("be.visible") | ||
cy.get('input[name="password"]').clear().type("john-doe-password") | ||
cy.contains("Log in").click() | ||
cy.contains("You are logged in as john-doe.").should("be.visible") | ||
}) | ||
|
||
it("logs out successfully", () => { | ||
cy.authorize(testUsers.johnDoe.id) | ||
cy.visit("/auth") | ||
|
||
expect(localStorage.authToken).to.match(/.+/) | ||
cy.contains("Log out").click() | ||
cy.contains("Log in").should("be.visible") | ||
expect(localStorage.authToken).to.be.equal(undefined) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.