-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathall.cy.ts
More file actions
73 lines (65 loc) · 2.03 KB
/
Copy pathall.cy.ts
File metadata and controls
73 lines (65 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/// <reference types="cypress" />
/// <reference types="../../cypress/support" />
describe("auth-auth0", () => {
const login = () => {
cy.get("button")
.contains(/sign in/i)
.click();
cy.fixture("auth0-credentials").then((auth) => {
cy.get("#username").type(auth.email);
cy.get("#password").type(auth.password);
});
cy.get("button[type=submit]")
.contains(/continue$/i)
.click({ force: true });
};
beforeEach(() => {
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();
cy.visit("/");
});
describe("login", () => {
it("should login", () => {
login();
cy.location("pathname").should("eq", "/posts");
});
it("should redirect to /login if user not authenticated", () => {
cy.location("pathname").should("eq", "/login");
login();
cy.location("pathname").should("eq", "/posts");
cy.window().then((window) => {
window.history.pushState({}, "", "/test-route");
window.dispatchEvent(new PopStateEvent("popstate"));
});
cy.get(".ant-result-404").should("exist");
cy.clearAllCookies();
cy.clearAllSessionStorage();
cy.clearAllLocalStorage();
cy.reload().then(() => {
cy.location("pathname").should("eq", "/login");
cy.location("search").should("contains", "?to=%2Ftest-route");
});
});
});
describe("logout", () => {
it("should logout", () => {
cy.location("pathname").should("eq", "/login");
login();
cy.location("pathname").should("eq", "/posts");
cy.get(".ant-menu-title-content")
.contains(/logout/i)
.click();
cy.location("pathname").should("eq", "/login");
});
});
describe("get user identity", () => {
it("should render getIdentity response on header", () => {
login();
cy.fixture("auth0-credentials").then((auth) => {
cy.get(".ant-typography").contains(auth.email);
});
cy.get(".ant-avatar > img").should("have.attr", "src");
});
});
});