forked from Together-100Devs/Together
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.js
36 lines (33 loc) · 886 Bytes
/
commands.js
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
/// <reference types="cypress" />
import tgt from "./tgt";
Cypress.Commands.add(
"login",
(userCode, closeModal = false, loginButtonText = "Login with Discord") => {
cy.intercept(
{
method: "GET",
url: "https://discord.com/oauth2/authorize*",
times: 1,
},
req =>
req.redirect(
Cypress.config().baseUrl + "/auth/discord/callback?code=" + userCode
)
).as("discordAuthorize");
cy.contains("button", loginButtonText).click();
cy.wait("@discordAuthorize");
if (closeModal) tgt.modal.close();
}
);
Cypress.Commands.add("createOwnEvents", (userCode, ...events) => {
cy.login(userCode);
cy.request("GET", "/getDisplayName").then(({ body }) => {
for (const event of events) {
cy.task("createEvent", {
...event,
user: body._id,
});
}
});
cy.reload();
});