Skip to content

Commit

Permalink
Show toast after succesful signup
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas authored and agnlez committed Nov 18, 2024
1 parent 3158e8c commit 418f001
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion client/src/containers/auth/signup/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { useToast } from "@/components/ui/toast/use-toast";

import { signUpAction } from "./action";
import { signUpSchemaForm } from "./schema";
Expand All @@ -33,6 +34,7 @@ const TokenSignUpForm: FC = () => {
ok: undefined,
message: "",
});
const { toast } = useToast();

const formRef = useRef<HTMLFormElement>(null);
const form = useForm<z.infer<typeof signUpSchemaForm>>({
Expand All @@ -47,9 +49,13 @@ const TokenSignUpForm: FC = () => {

useEffect(() => {
if (status.ok) {
toast({
description:
"Sign up successful! Please check your email to verify your account.",
});
push("/auth/signin");
}
}, [status, push]);
}, [status, push, toast]);

return (
<>
Expand Down
12 changes: 11 additions & 1 deletion e2e/tests/auth/sign-up.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,18 @@ test.describe("Auth - Sign Up", () => {

await page.getByRole("button", { name: /Create account/i }).click();

await expect(
// Has to be a more specific selector targeting the notification list item
page.getByRole("list").getByRole("status").filter({
hasText:
"Sign up successful! Please check your email to verify your account.",
}),
).toBeVisible();

await page.waitForURL("/auth/signin");
await expect(page.getByText("Welcome to Blue Carbon Cost")).toBeVisible();
await expect(
page.getByText("Welcome to Blue Carbon Cost", { exact: true }),
).toBeVisible();

const registeredUser = await testManager
.getDataSource()
Expand Down

0 comments on commit 418f001

Please sign in to comment.