Skip to content

Commit fa3632f

Browse files
tests: add chakra tests (native Enum)
1 parent c8b5e62 commit fa3632f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

apps/web/cypress/component/autoform/chakra-zod/basic.cy.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ import { AutoForm } from "@autoform/chakra";
33
import { ZodProvider, fieldConfig } from "@autoform/zod";
44
import { z } from "zod/v3";
55

6+
enum Sports {
7+
Football = "Football/Soccer",
8+
Basketball = "Basketballs",
9+
Baseball = "Baseballs",
10+
Hockey = "Hockey (Ice)",
11+
None = "I don't like sports",
12+
}
13+
614
describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
715
const basicSchema = z.object({
816
name: z.string().min(2, "Name must be at least 2 characters"),
917
age: z.coerce.number().min(18, "Must be at least 18 years old"),
1018
email: z.string().email("Invalid email address"),
1119
website: z.string().url("Invalid URL").optional(),
20+
sports: z.nativeEnum(Sports),
1221
birthdate: z.coerce.date(),
1322
isStudent: z.boolean(),
1423
});
@@ -32,6 +41,7 @@ describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
3241
);
3342
cy.get('input[name="email"]').should("exist");
3443
cy.get('input[name="website"]').should("exist");
44+
cy.get('select[name="sports"]').should("exist");
3545
cy.get('input[name="birthdate"]');
3646
cy.get('input[name="isStudent"]').should("have.attr", "type", "checkbox");
3747
});
@@ -46,6 +56,12 @@ describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
4656
cy.get('input[name="age"]').type("25");
4757
cy.get('input[name="email"]').type("[email protected]");
4858
cy.get('input[name="website"]').type("https://example.com");
59+
cy.get(".chakra-select__root")
60+
.within(() => {
61+
cy.get('select[name="sports"]').should("exist");
62+
})
63+
.click();
64+
cy.get('.chakra-select__item[data-value="Hockey (Ice)"]').click();
4965
cy.get('input[name="birthdate"]').clear().type("1990-01-01");
5066
cy.get('input[name="isStudent"]')
5167
.parent()
@@ -60,6 +76,7 @@ describe("AutoForm Basic Tests (CHAKRA-ZOD)", () => {
6076
age: 25,
6177
6278
website: "https://example.com",
79+
sports: "Hockey (Ice)",
6380
birthdate: new Date("1990-01-01"),
6481
isStudent: true,
6582
});

0 commit comments

Comments
 (0)