@@ -45,14 +45,14 @@ describe('Create courses', () => {
4545
4646 it ( 'has flash messages when is invalid' , ( ) => {
4747 cy . get ( 'input[name="id"]' ) . clear ( ) . type ( 'invalid course id' ) ;
48- cy . get ( 'form' ) . submit ( ) ;
48+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
4949
5050 cy . get ( 'input[name="id"] + p' ) . contains ( 'Invalid course id' ) ;
5151 } ) ;
5252
5353 it ( 'maintain the value introduced by the user when invalid' , ( ) => {
5454 cy . get ( 'input[name="id"]' ) . clear ( ) . type ( 'invalid course id' ) ;
55- cy . get ( 'form' ) . submit ( ) ;
55+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
5656
5757 cy . get ( 'input[name="id"]' ) . should ( 'have.value' , 'invalid course id' ) ;
5858 } ) ;
@@ -61,23 +61,23 @@ describe('Create courses', () => {
6161 const uuid = faker . random . uuid ( ) ;
6262
6363 cy . get ( 'input[name="id"]' ) . clear ( ) . type ( uuid ) ;
64- cy . get ( 'form' ) . submit ( ) ;
64+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
6565
6666 cy . get ( 'input[name="id"]' ) . should ( 'have.value' , uuid ) ;
6767 } ) ;
6868 } ) ;
6969
7070 describe ( 'Name field' , ( ) => {
7171 it ( 'has flash messages when is empty' , ( ) => {
72- cy . get ( 'form' ) . submit ( ) ;
72+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
7373
7474 cy . get ( 'input[name="name"] + p' ) . contains ( 'Invalid name' ) ;
7575 } ) ;
7676
7777 it ( 'has flash messages when is longer than 30 character' , ( ) => {
7878 cy . get ( 'input[name="name"]' ) . type ( faker . random . alphaNumeric ( 31 ) ) ;
7979
80- cy . get ( 'form' ) . submit ( ) ;
80+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
8181
8282 cy . get ( 'input[name="name"] + p' ) . contains ( 'Invalid name' ) ;
8383 } ) ;
@@ -86,7 +86,7 @@ describe('Create courses', () => {
8686 const invalidCourseName = faker . random . alphaNumeric ( 3 ) ;
8787
8888 cy . get ( 'input[name="name"]' ) . clear ( ) . type ( invalidCourseName ) ;
89- cy . get ( 'form' ) . submit ( ) ;
89+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
9090
9191 cy . get ( 'input[name="name"]' ) . should ( 'have.value' , invalidCourseName ) ;
9292 } ) ;
@@ -95,31 +95,31 @@ describe('Create courses', () => {
9595 const validCourseName = faker . random . alphaNumeric ( 1 ) ;
9696
9797 cy . get ( 'input[name="name"]' ) . clear ( ) . type ( validCourseName ) ;
98- cy . get ( 'form' ) . submit ( ) ;
98+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
9999
100100 cy . get ( 'input[name="name"]' ) . should ( 'have.value' , validCourseName ) ;
101101 } ) ;
102102 } ) ;
103103
104104 describe ( 'Duration field' , ( ) => {
105105 it ( 'has flash messages when is empty' , ( ) => {
106- cy . get ( 'form' ) . submit ( ) ;
106+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
107107
108108 cy . get ( 'input[name="duration"] + p' ) . contains ( 'Invalid duration' ) ;
109109 } ) ;
110110
111111 it ( 'has flash messages when is shorter than 4 character' , ( ) => {
112112 cy . get ( 'input[name="duration"]' ) . type ( faker . random . alphaNumeric ( 3 ) ) ;
113113
114- cy . get ( 'form' ) . submit ( ) ;
114+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
115115
116116 cy . get ( 'input[name="duration"] + p' ) . contains ( 'Invalid duration' ) ;
117117 } ) ;
118118
119119 it ( 'has flash messages when is longer than 100 character' , ( ) => {
120120 cy . get ( 'input[name="duration"]' ) . type ( faker . random . alphaNumeric ( 101 ) ) ;
121121
122- cy . get ( 'form' ) . submit ( ) ;
122+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
123123
124124 cy . get ( 'input[name="duration"] + p' ) . contains ( 'Invalid duration' ) ;
125125 } ) ;
@@ -128,7 +128,7 @@ describe('Create courses', () => {
128128 const invalidCourseDuration = faker . random . alphaNumeric ( 101 ) ;
129129
130130 cy . get ( 'input[name="duration"]' ) . clear ( ) . type ( invalidCourseDuration ) ;
131- cy . get ( 'form' ) . submit ( ) ;
131+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
132132
133133 cy . get ( 'input[name="duration"]' ) . should ( 'have.value' , invalidCourseDuration ) ;
134134 } ) ;
@@ -137,7 +137,7 @@ describe('Create courses', () => {
137137 const validCourseDuration = faker . random . alphaNumeric ( 5 ) ;
138138
139139 cy . get ( 'input[name="duration"]' ) . clear ( ) . type ( validCourseDuration ) ;
140- cy . get ( 'form' ) . submit ( ) ;
140+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
141141
142142 cy . get ( 'input[name="duration"]' ) . should ( 'have.value' , validCourseDuration ) ;
143143 } ) ;
0 commit comments