Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion apps/web/cypress/component/autoform/ant-joi/basics.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import Joi from "joi";
import { AutoForm } from "@autoform/ant";
import { JoiProvider } from "@autoform/joi";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (ANT-JOI)", () => {
const basicSchema = Joi.object({
name: Joi.string().min(2).required().messages({
Expand All @@ -20,6 +28,7 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
website: Joi.string().uri().optional().messages({
"string.uri": "Invalid URL",
}),
sports: Joi.valid(...Object.values(Sports)),
birthdate: Joi.date().required(),
isStudent: Joi.boolean().required(),
});
Expand All @@ -39,11 +48,12 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
cy.get('input[name="age"]').should("have.class", "ant-input-number-input");
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('input[name="birthdate"]');
cy.get('input[name="isStudent"]').should(
"have.class",
"ant-checkbox-input"
);
cy.get('input[id="sports"]').should("exist");
cy.get('input[name="birthdate"]');
});

it("submits form with correct data types", () => {
Expand All @@ -56,6 +66,8 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get('input[id="sports"]').click();
cy.get('.ant-select-item-option[title="Hockey (Ice)"]').click();
cy.get('input[name="birthdate"]').clear().type("1990-01-01");
cy.get('input[name="isStudent"]').check();

Expand All @@ -67,6 +79,7 @@ describe("AutoForm Basic Tests (ANT-JOI)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
15 changes: 14 additions & 1 deletion apps/web/cypress/component/autoform/ant-zod/basic.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ import { AutoForm } from "@autoform/ant";
import { ZodProvider, fieldConfig } from "@autoform/zod";
import { z } from "zod/v3";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (ANT-ZOD)", () => {
const basicSchema = z.object({
name: z.string().min(2, "Name must be at least 2 characters"),
age: z.coerce.number().min(18, "Must be at least 18 years old"),
email: z.string().email("Invalid email address"),
website: z.string().url("Invalid URL").optional(),
sports: z.nativeEnum(Sports),
birthdate: z.coerce.date(),
isStudent: z.boolean(),
});
Expand All @@ -28,7 +37,8 @@ describe("AutoForm Basic Tests (ANT-ZOD)", () => {
cy.get('input[name="age"]').should("have.class", "ant-input-number-input");
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('input[name="birthdate"]');
cy.get('input[id="sports"]').should("exist");
cy.get('input[name="birthdate"]').should("exist");
cy.get('input[name="isStudent"]').should(
"have.class",
"ant-checkbox-input"
Expand All @@ -45,6 +55,8 @@ describe("AutoForm Basic Tests (ANT-ZOD)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get('input[id="sports"]').click();
cy.get('.ant-select-item-option[title="Hockey (Ice)"]').click();
cy.get('input[name="birthdate"]').clear().type("1990-01-01");
cy.get('input[name="isStudent"]').check();

Expand All @@ -56,6 +68,7 @@ describe("AutoForm Basic Tests (ANT-ZOD)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
15 changes: 14 additions & 1 deletion apps/web/cypress/component/autoform/ant-zod4-mini/basics.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import { AutoForm } from "@autoform/ant";
import { ZodProvider } from "@autoform/zod";
import { z } from "zod/mini";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (ANT-ZOD-V4-MINI)", () => {
const basicSchema = z.object({
name: z.string().check(
Expand All @@ -13,6 +21,7 @@ describe("AutoForm Basic Tests (ANT-ZOD-V4-MINI)", () => {
z.gte(18)
// Custom error messages are not supported in .check()
),
sports: z.enum(Sports),
email: z.string(), // Zod Mini does not provide a built-in .email() check
website: z.optional(z.string()), // .url() is not available in Zod Mini
birthdate: z.coerce.date(),
Expand All @@ -34,7 +43,8 @@ describe("AutoForm Basic Tests (ANT-ZOD-V4-MINI)", () => {
cy.get('input[name="age"]').should("have.class", "ant-input-number-input");
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('input[name="birthdate"]');
cy.get('input[id="sports"]').should("exist");
cy.get('input[name="birthdate"]').should("exist");
cy.get('input[name="isStudent"]').should(
"have.class",
"ant-checkbox-input"
Expand All @@ -51,6 +61,8 @@ describe("AutoForm Basic Tests (ANT-ZOD-V4-MINI)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get('input[id="sports"]').click();
cy.get('.ant-select-item-option[title="Hockey (Ice)"]').click();
cy.get('input[name="birthdate"]').clear().type("1990-01-01");
cy.get('input[name="isStudent"]').check();

Expand All @@ -62,6 +74,7 @@ describe("AutoForm Basic Tests (ANT-ZOD-V4-MINI)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
17 changes: 17 additions & 0 deletions apps/web/cypress/component/autoform/chakra-zod/basic.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ import { AutoForm } from "@autoform/chakra";
import { ZodProvider, fieldConfig } from "@autoform/zod";
import { z } from "zod/v3";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
const basicSchema = z.object({
name: z.string().min(2, "Name must be at least 2 characters"),
age: z.coerce.number().min(18, "Must be at least 18 years old"),
email: z.string().email("Invalid email address"),
website: z.string().url("Invalid URL").optional(),
sports: z.nativeEnum(Sports),
birthdate: z.coerce.date(),
isStudent: z.boolean(),
});
Expand All @@ -32,6 +41,7 @@ describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
);
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('select[name="sports"]').should("exist");
cy.get('input[name="birthdate"]');
cy.get('input[name="isStudent"]').should("have.attr", "type", "checkbox");
});
Expand All @@ -46,6 +56,12 @@ describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get(".chakra-select__root")
.within(() => {
cy.get('select[name="sports"]').should("exist");
})
.click();
cy.get('.chakra-select__item[data-value="Hockey (Ice)"]').click();
cy.get('input[name="birthdate"]').clear().type("1990-01-01");
cy.get('input[name="isStudent"]')
.parent()
Expand All @@ -60,6 +76,7 @@ describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
19 changes: 17 additions & 2 deletions apps/web/cypress/component/autoform/mantine-zod/basic.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import { ZodProvider, fieldConfig } from "@autoform/zod";
import { z } from "zod/v3";
import { TestWrapper } from "./utils";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
const basicSchema = z.object({
name: z.string().min(2, "Name must be at least 2 characters"),
age: z.coerce.number().min(18, "Must be at least 18 years old"),
email: z.string().email("Invalid email address"),
website: z.string().url("Invalid URL").optional(),
sports: z.nativeEnum(Sports),
birthdate: z.coerce.date(),
isStudent: z.boolean(),
});
Expand All @@ -31,6 +40,7 @@ describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
cy.get('input[name="age"]').should("have.attr", "type", "number");
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('input[name="sports"]').should("exist");
cy.get('[data-dates-input="true"]').should("exist");
cy.get('input[name="isStudent"]').should("have.attr", "type", "checkbox");
});
Expand All @@ -47,9 +57,13 @@ describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get('[data-dates-input="true"]').type("1990-01-01");
cy.get('input[name="isStudent"]').check();

cy.get(".mantine-Select-input").eq(0).click();
cy.get('.mantine-Select-option[value="Hockey (Ice)"]')
.should("exist")
.and("be.visible")
.click();
cy.get('[data-dates-input="true"]').type("1990-01-01");
cy.get('button[type="submit"]').click();

cy.get("@onSubmit").should("have.been.calledOnce");
Expand All @@ -58,6 +72,7 @@ describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
13 changes: 13 additions & 0 deletions apps/web/cypress/component/autoform/mui-yup/basics.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ import { AutoForm } from "@autoform/mui";
import { YupProvider, fieldConfig } from "@autoform/yup";
import * as Yup from "yup";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (MUI-YUP)", () => {
const basicSchema = Yup.object({
name: Yup.string().min(2, "Name must be at least 2 characters"),
age: Yup.number().min(18, "Must be at least 18 years old"),
email: Yup.string().email("Invalid email address"),
website: Yup.string().url("Invalid URL").optional(),
sports: Yup.mixed().oneOf(Object.values(Sports)),
birthdate: Yup.date(),
isStudent: Yup.boolean(),
});
Expand All @@ -28,6 +37,7 @@ describe("AutoForm Basic Tests (MUI-YUP)", () => {
cy.get('input[name="age"]').should("have.attr", "type", "number");
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('input[name="sports"]').should("exist");
cy.get('input[name="birthdate"]').should("have.attr", "type", "date");
cy.get('input[name="isStudent"]').should("have.attr", "type", "checkbox");
});
Expand All @@ -42,6 +52,8 @@ describe("AutoForm Basic Tests (MUI-YUP)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get("#mui-component-select-sports").click();
cy.get('.MuiMenuItem-root[data-value="Hockey (Ice)"]').click();
cy.get('input[name="birthdate"]').type("1990-01-01");
cy.get('input[name="isStudent"]').check();

Expand All @@ -53,6 +65,7 @@ describe("AutoForm Basic Tests (MUI-YUP)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
13 changes: 13 additions & 0 deletions apps/web/cypress/component/autoform/mui-zod/basic.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ import { AutoForm } from "@autoform/mui";
import { ZodProvider, fieldConfig } from "@autoform/zod";
import { z } from "zod/v3";

enum Sports {
Football = "Football/Soccer",
Basketball = "Basketballs",
Baseball = "Baseballs",
Hockey = "Hockey (Ice)",
None = "I don't like sports",
}

describe("AutoForm Basic Tests (MUI-ZOD)", () => {
const basicSchema = z.object({
name: z.string().min(2, "Name must be at least 2 characters"),
age: z.coerce.number().min(18, "Must be at least 18 years old"),
email: z.string().email("Invalid email address"),
website: z.string().url("Invalid URL").optional(),
sports: z.nativeEnum(Sports),
birthdate: z.coerce.date(),
isStudent: z.boolean(),
});
Expand All @@ -28,6 +37,7 @@ describe("AutoForm Basic Tests (MUI-ZOD)", () => {
cy.get('input[name="age"]').should("have.attr", "type", "number");
cy.get('input[name="email"]').should("exist");
cy.get('input[name="website"]').should("exist");
cy.get('input[name="sports"]').should("exist");
cy.get('input[name="birthdate"]').should("have.attr", "type", "date");
cy.get('input[name="isStudent"]').should("have.attr", "type", "checkbox");
});
Expand All @@ -42,6 +52,8 @@ describe("AutoForm Basic Tests (MUI-ZOD)", () => {
cy.get('input[name="age"]').type("25");
cy.get('input[name="email"]').type("[email protected]");
cy.get('input[name="website"]').type("https://example.com");
cy.get("#mui-component-select-sports").click();
cy.get('.MuiMenuItem-root[data-value="Hockey (Ice)"]').click();
cy.get('input[name="birthdate"]').type("1990-01-01");
cy.get('input[name="isStudent"]').check();

Expand All @@ -53,6 +65,7 @@ describe("AutoForm Basic Tests (MUI-ZOD)", () => {
age: 25,
email: "[email protected]",
website: "https://example.com",
sports: "Hockey (Ice)",
birthdate: new Date("1990-01-01"),
isStudent: true,
});
Expand Down
Loading