-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
41 lines (39 loc) · 1.35 KB
/
auth.ts
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
import { ScenarioMap, ScenarioStep, step } from "../features/scenario-replays/types";
import { ScenarioComponents } from "./types";
function fillLoginForm(): ScenarioStep<ScenarioComponents>[] {
return [
step(
"email",
async (context) => await context.componentMethod("AuthPage", "changeEmail", { value: "[email protected]" })
),
step(
"password",
async (context) => await context.componentMethod("AuthPage", "changePassword", { value: "spamhameggs" })
),
];
}
export const SCENARIOS: ScenarioMap<ScenarioComponents> = {
"login/success": () => [
step("start", async (context) => await context.navigateTo("/auth")),
...fillLoginForm(),
step("submit", async (context) => {
context.blockBackendPath("/auth/login");
context.componentMethod("AuthPage", "submit", {});
}),
step("authenticated", async (context) => {
context.restoreBackendPath("/auth/login");
}),
],
"login/submit-error": () => [
step("start", async (context) => await context.navigateTo("/auth")),
...fillLoginForm(),
step("submit", async (context) => {
context.sabotageBackendPath("/auth/login");
context.blockBackendPath("/auth/login");
context.componentMethod("AuthPage", "submit", {});
}),
step("error", async (context) => {
context.restoreBackendPath("/auth/login");
}),
],
};