This repository was archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathonboarding.spec.ts
More file actions
177 lines (149 loc) · 6.15 KB
/
onboarding.spec.ts
File metadata and controls
177 lines (149 loc) · 6.15 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import * as commands from "../support/commands";
import { VALID_PEER_MATCH } from "../../ui/src/screen/project";
context("onboarding", () => {
const validUser = {
handle: "rafalca",
passphrase: "curled",
};
beforeEach(() => {
commands.resetProxyState();
cy.visit("./public/index.html");
commands.pick("welcome-screen").should("exist");
});
context("navigation", () => {
it("is not possible to exit the flow by pressing escape key", () => {
commands.pick("get-started-button").should("exist");
cy.get("body").type("{esc}");
commands.pick("get-started-button").should("exist");
});
it("makes sure global hotkeys are disabled during onboarding", () => {
commands.pick("get-started-button").should("exist");
cy.get("body").type("?");
commands.pick("hotkey-modal").should("not.exist");
});
it("is possible to use the keyboard for navigation", () => {
// Intro screen.
cy.get("body").type("{enter}");
// Enter name screen.
cy.focused().type(validUser.handle);
cy.focused().type("{enter}");
// Enter passphrase screen.
commands.pick("enter-name-screen").should("exist");
cy.focused().type(validUser.passphrase);
cy.focused().type("{enter}");
cy.focused().type(validUser.passphrase);
cy.focused().type("{enter}");
// Success screen.
commands.pick("peerId").contains(VALID_PEER_MATCH).should("exist");
// Land on profile screen.
cy.get("body").type("{enter}");
commands.pick("entity-name").contains(validUser.handle);
});
it("is possible to step through the identity creation flow", () => {
// Intro screen.
commands.pick("get-started-button").click();
// Enter name screen.
commands.pick("handle-input").type(validUser.handle);
commands.pick("next-button").click();
// Enter passphrase screen.
commands.pick("passphrase-input").type(validUser.passphrase);
commands.pick("repeat-passphrase-input").type(validUser.passphrase);
commands.pick("set-passphrase-button").click();
// Success screen.
commands.pick("peerId").contains(VALID_PEER_MATCH).should("exist");
// Land on profile screen.
commands.pick("go-to-profile-button").click();
commands.pick("entity-name").contains(validUser.handle);
});
context("when clicking the back button on the passphrase screen", () => {
it("sends the user back to the previous screen", () => {
commands.pick("get-started-button").click();
commands.pick("handle-input").type(validUser.handle);
commands.pick("next-button").click();
commands.pick("enter-passphrase-screen").should("exist");
commands.pick("back-button").click();
cy.contains("what should we call you?").should("exist");
commands.pick("handle-input").should("have.value", validUser.handle);
});
});
});
context("validations", () => {
beforeEach(() => {
commands.pick("get-started-button").click();
});
context("handle", () => {
it("requires the user to input a handle", () => {
commands.pick("handle-input").clear();
commands.pick("next-button").click();
commands
.pick("enter-name-screen")
.contains("You must provide a display name");
});
it("starts validation after at least 2 characters are input", () => {
commands.pick("handle-input").type("@");
commands.pick("validation-error-icon").should("not.be.visible");
commands.pick("handle-input").type("@");
commands.pick("validation-error-icon").should("be.visible");
});
it("prevents the user from submitting an invalid handle", () => {
// No spaces.
commands.pick("handle-input").type("no spaces");
commands.pick("handle-input").should("have.value", "no-spaces");
// No special characters.
commands.pick("handle-input").clear();
commands.pick("handle-input").type("bad$");
commands
.pick("enter-name-screen")
.contains(
"Your display name has unsupported characters in it. You can only " +
"use basic letters, numbers, and the _ and - characters."
);
// Can't start with a dash.
commands.pick("handle-input").clear();
commands.pick("handle-input").type("-não");
commands
.pick("enter-name-screen")
.contains(
"Your display name should start with a letter or a number."
);
// Has to be at least two characters long.
commands.pick("handle-input").clear();
commands.pick("handle-input").type("x");
commands
.pick("enter-name-screen")
.contains("Your display name should be at least 2 characters long.");
// Has to be no more than 32 characters long.
commands.pick("handle-input").clear();
commands
.pick("handle-input")
.invoke("val", "x".repeat(33))
.trigger("input");
commands
.pick("enter-name-screen")
.contains(
"Your display name should not be longer than 32 characters."
);
});
});
context("passphrase", () => {
it("prevents the user from submitting an invalid passphrase", () => {
commands.pick("handle-input").type("cloudhead");
commands.pick("next-button").click();
// Only entered once.
commands.pick("passphrase-input").type("123");
commands.pick("set-passphrase-button").should("be.disabled");
// Too short.
commands.pick("repeat-passphrase-input").type("123");
cy.contains("Passphrase must be at least 4 characters").should("exist");
// Does not match.
commands.pick("passphrase-input").type("4");
commands.pick("repeat-passphrase-input").type("5");
cy.contains("Passphrases should match").should("exist");
// Valid passphrase.
commands.pick("passphrase-input").clear().type("abcd");
commands.pick("repeat-passphrase-input").clear().type("abcd");
commands.pick("set-passphrase-button").should("not.be.disabled");
});
});
});
});