Skip to content

Commit 420a520

Browse files
committed
feat(website): vae collective form submit button is now enabled by default
1 parent eaa5736 commit 420a520

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

packages/reva-website/src/app/inscription-candidat/vae-collective/_components/VaeCollectiveCodeForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function VaeCollectiveCodeForm() {
4040
register,
4141
handleSubmit,
4242
watch,
43-
formState: { errors, isDirty },
43+
formState: { errors },
4444
setError,
4545
clearErrors,
4646
} = useForm<FormData>({
@@ -52,7 +52,6 @@ export function VaeCollectiveCodeForm() {
5252
});
5353

5454
const codeValue = watch("code");
55-
const isFormComplete = codeValue.length === 8;
5655

5756
const { refetch: validateCode, isLoading } = useQuery({
5857
queryKey: ["validateVaeCollectiveCode", codeValue],
@@ -99,7 +98,7 @@ export function VaeCollectiveCodeForm() {
9998
className="w-full justify-center"
10099
priority="primary"
101100
type="submit"
102-
disabled={!isDirty || !isFormComplete || isLoading}
101+
disabled={isLoading}
103102
>
104103
Accéder à cette VAE collective
105104
</Button>

packages/reva-website/tests/vae-collective.spec.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,36 +95,35 @@ test.describe("VAE Collective Code Page", () => {
9595
).toBeVisible();
9696
});
9797

98-
test("should validate form input constraints", async ({ page, msw }) => {
99-
msw.use(
100-
fvae.query("getVaeCollectiveCohort", () => {
101-
return HttpResponse.json({
102-
data: {
103-
cohorteVaeCollective: null,
104-
},
105-
});
106-
}),
107-
);
108-
98+
test("should show an error when the code is less than 8 characters", async ({
99+
page,
100+
}) => {
109101
const codeInput = page.getByRole("textbox");
102+
103+
await codeInput.fill("ABC");
104+
110105
const submitButton = page.getByRole("button", {
111106
name: "Accéder à cette VAE collective",
112107
});
113108

114-
await expect(submitButton).toBeDisabled();
109+
await submitButton.click();
110+
111+
await expect(
112+
page.getByText("Le code doit contenir exactement 8 caractères"),
113+
).toBeVisible();
114+
});
115115

116-
await codeInput.fill("ABC");
117-
await expect(submitButton).toBeDisabled();
116+
test("should show an error when the code contains invalid characters", async ({
117+
page,
118+
}) => {
119+
const codeInput = page.getByRole("textbox");
118120

119-
await codeInput.click();
120-
await codeInput.pressSequentially("ABCD1234");
121-
await expect(submitButton).toBeEnabled();
121+
await codeInput.fill("ABCD####");
122122

123-
await codeInput.clear();
124-
await codeInput.click();
125-
await codeInput.pressSequentially("ABCD####");
123+
const submitButton = page.getByRole("button", {
124+
name: "Accéder à cette VAE collective",
125+
});
126126

127-
await expect(submitButton).toBeEnabled();
128127
await submitButton.click();
129128

130129
await expect(

0 commit comments

Comments
 (0)