Show Login and Ask an organizer sent and error states.
Connect the live modals to the drawn sent, expired, invalid-email, and send-failed screens, pin the phone footer above the keyboard, and send the light login email.
This commit is contained in:
1 parent
44010c7b73
commit
27d74e510c
29 files changed
+771
-281
No files matched your search
@@ -73,7 +73,7 @@ describe("LoginForm", () => {
|
||||
screen.getByRole("textbox", { name: /email address/i }),
|
||||
).toHaveAttribute("maxLength", String(EMAIL_MAX_LEN));
|
||||
expect(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -95,10 +95,10 @@ describe("LoginForm", () => {
|
||||
"not-an-email",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
expect(
|
||||
await screen.findByText(/enter a valid email address/i),
|
||||
await screen.findByText(/enter an email address like name@example.org/i),
|
||||
).toBeInTheDocument();
|
||||
expect(requestMagicLink).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -112,7 +112,7 @@ describe("LoginForm", () => {
|
||||
" Pat@Example.COM ",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledWith(
|
||||
@@ -124,8 +124,14 @@ describe("LoginForm", () => {
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: /check your email/i }),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText(/we sent a login link/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/check spam or promotions/i)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/we sent a login link to pat@example.com/i),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText(/it works for 60 minutes/i)).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: /^close$/i })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("button", { name: /send it again/i }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("submits a long email without treating length as invalid", async () => {
|
||||
@@ -139,7 +145,7 @@ describe("LoginForm", () => {
|
||||
email,
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledWith(email, "/", undefined);
|
||||
@@ -162,7 +168,7 @@ describe("LoginForm", () => {
|
||||
"save@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledWith(
|
||||
@@ -199,7 +205,7 @@ describe("LoginForm", () => {
|
||||
"guest@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledWith(
|
||||
@@ -237,7 +243,7 @@ describe("LoginForm", () => {
|
||||
"guest@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledWith(
|
||||
@@ -286,7 +292,7 @@ describe("LoginForm", () => {
|
||||
"a@b.co",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledWith(
|
||||
@@ -309,7 +315,7 @@ describe("LoginForm", () => {
|
||||
"ok@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
expect(await screen.findByText("Server says no")).toBeInTheDocument();
|
||||
});
|
||||
@@ -327,7 +333,7 @@ describe("LoginForm", () => {
|
||||
"ok@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
expect(
|
||||
await screen.findByText(/try again in 4 seconds/i),
|
||||
@@ -338,7 +344,13 @@ describe("LoginForm", () => {
|
||||
navMock.searchParams = new URLSearchParams("error=expired_link");
|
||||
renderLoginForm();
|
||||
expect(
|
||||
screen.getByText(/that login link has expired/i),
|
||||
screen.getByRole("heading", { name: /that link has expired/i }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/expired or was already used/i),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("button", { name: /send a new link/i }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -346,7 +358,10 @@ describe("LoginForm", () => {
|
||||
navMock.searchParams = new URLSearchParams("error=invalid_link");
|
||||
renderLoginForm();
|
||||
expect(
|
||||
screen.getByText(/that login link is not valid/i),
|
||||
screen.getByRole("heading", { name: /that link has expired/i }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("button", { name: /send a new link/i }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -383,10 +398,30 @@ describe("LoginForm", () => {
|
||||
"ok@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send me a magic link/i }),
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
expect(
|
||||
await screen.findByText(/check your connection/i),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("send it again requests another link from the sent state", async () => {
|
||||
const user = userEvent.setup();
|
||||
vi.mocked(requestMagicLink).mockResolvedValue({ ok: true });
|
||||
renderLoginForm();
|
||||
await user.type(
|
||||
screen.getByRole("textbox", { name: /email address/i }),
|
||||
"pat@example.com",
|
||||
);
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: /send login link/i }),
|
||||
);
|
||||
expect(
|
||||
await screen.findByRole("button", { name: /send it again/i }),
|
||||
).toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: /send it again/i }));
|
||||
await waitFor(() => {
|
||||
expect(requestMagicLink).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user