@@ -4,12 +4,21 @@ import { ZodProvider, fieldConfig } from "@autoform/zod";
44import { z } from "zod/v3" ;
55import { TestWrapper } from "./utils" ;
66
7+ enum Sports {
8+ Football = "Football/Soccer" ,
9+ Basketball = "Basketballs" ,
10+ Baseball = "Baseballs" ,
11+ Hockey = "Hockey (Ice)" ,
12+ None = "I don't like sports" ,
13+ }
14+
715describe ( "AutoForm Basic Tests (MANTINE-ZOD)" , ( ) => {
816 const basicSchema = z . object ( {
917 name : z . string ( ) . min ( 2 , "Name must be at least 2 characters" ) ,
1018 age : z . coerce . number ( ) . min ( 18 , "Must be at least 18 years old" ) ,
1119 email : z . string ( ) . email ( "Invalid email address" ) ,
1220 website : z . string ( ) . url ( "Invalid URL" ) . optional ( ) ,
21+ sports : z . nativeEnum ( Sports ) ,
1322 birthdate : z . coerce . date ( ) ,
1423 isStudent : z . boolean ( ) ,
1524 } ) ;
@@ -31,6 +40,7 @@ describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
3140 cy . get ( 'input[name="age"]' ) . should ( "have.attr" , "type" , "number" ) ;
3241 cy . get ( 'input[name="email"]' ) . should ( "exist" ) ;
3342 cy . get ( 'input[name="website"]' ) . should ( "exist" ) ;
43+ cy . get ( 'input[name="sports"]' ) . should ( "exist" ) ;
3444 cy . get ( '[data-dates-input="true"]' ) . should ( "exist" ) ;
3545 cy . get ( 'input[name="isStudent"]' ) . should ( "have.attr" , "type" , "checkbox" ) ;
3646 } ) ;
@@ -47,9 +57,13 @@ describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
4757 cy . get ( 'input[name="age"]' ) . type ( "25" ) ;
4858 cy . get ( 'input[name="email"]' ) . type ( "[email protected] " ) ; 4959 cy . get ( 'input[name="website"]' ) . type ( "https://example.com" ) ;
50- cy . get ( '[data-dates-input="true"]' ) . type ( "1990-01-01" ) ;
5160 cy . get ( 'input[name="isStudent"]' ) . check ( ) ;
52-
61+ cy . get ( ".mantine-Select-input" ) . eq ( 0 ) . click ( ) ;
62+ cy . get ( '.mantine-Select-option[value="Hockey (Ice)"]' )
63+ . should ( "exist" )
64+ . and ( "be.visible" )
65+ . click ( ) ;
66+ cy . get ( '[data-dates-input="true"]' ) . type ( "1990-01-01" ) ;
5367 cy . get ( 'button[type="submit"]' ) . click ( ) ;
5468
5569 cy . get ( "@onSubmit" ) . should ( "have.been.calledOnce" ) ;
@@ -58,6 +72,7 @@ describe("AutoForm Basic Tests (MANTINE-ZOD)", () => {
5872 age : 25 ,
59736074 website : "https://example.com" ,
75+ sports : "Hockey (Ice)" ,
6176 birthdate : new Date ( "1990-01-01" ) ,
6277 isStudent : true ,
6378 } ) ;
0 commit comments