Skip to content

Commit

Permalink
WIP: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjuhuss committed Jul 1, 2024
1 parent 7aa87dc commit acf0a53
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/tests/signup/SignupMain-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const emptyState: SignupState = {
},
credentials: {
completed: false,
generated_password: "",
},
email: {
completed: false,
Expand Down Expand Up @@ -146,7 +147,7 @@ function happyCaseBackend(state: SignupState) {
mswServer.use(
rest.post("https://signup.eduid.docker/services/signup/get-password", (req, res, ctx) => {
getPasswordCalled = true;
currentState.credentials.password = testPassword;
currentState.credentials.generated_password = testPassword;
currentState.credentials.completed = true;
const payload: SignupStatusResponse = { state: currentState };
return res(ctx.json({ type: "test success", payload }));
Expand Down Expand Up @@ -196,6 +197,35 @@ test("complete signup happy case", async () => {
render(<IndexMain />, {
state: {
config: { ...signupTestState.config },
signup: {
...signupTestState.signup,
state: {
already_signed_up: false,
email: {
completed: true,
address: "[email protected]",
expires_time_left: 270,
expires_time_max: 270,
sent_at: "2024-07-01T01:24:56.062105+00:00",
// throttle_time_left?: number,
// throttle_time_max?: number,
// bad_attempts?: number,
// bad_attempts_max?: number,
},
invite: {
user: { given_name: undefined, surname: "", email: "string " },
code: "",
completed: false,
finish_url: undefined,
initiated_signup: false,
is_logged_in: true,
},
tou: { completed: true, version: "2024" },
captcha: { completed: true },
credentials: { completed: true, generated_password: "test" },
user_created: false,
},
},
},
routes: [`${SIGNUP_BASE_PATH}`],
});
Expand All @@ -213,13 +243,11 @@ test("complete signup happy case", async () => {
await waitFor(() => {
expect(getPasswordCalled).toBe(true);
});

// verify accept button is initially disabled
const okButton = screen.getByRole("button", { name: /^ok/i });
await waitFor(() => {
expect(okButton).toBeDisabled();
});

const repeatInput = screen.getByRole("textbox", { name: /Repeat new password/i });
expect(repeatInput).toHaveFocus();
expect(repeatInput).toHaveProperty("placeholder", "xxxx xxxx xxxx");
Expand Down

0 comments on commit acf0a53

Please sign in to comment.