@@ -45,14 +45,14 @@ describe('Create courses', () => {
45
45
46
46
it ( 'has flash messages when is invalid' , ( ) => {
47
47
cy . get ( 'input[name="id"]' ) . clear ( ) . type ( 'invalid course id' ) ;
48
- cy . get ( 'form' ) . submit ( ) ;
48
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
49
49
50
50
cy . get ( 'input[name="id"] + p' ) . contains ( 'Invalid course id' ) ;
51
51
} ) ;
52
52
53
53
it ( 'maintain the value introduced by the user when invalid' , ( ) => {
54
54
cy . get ( 'input[name="id"]' ) . clear ( ) . type ( 'invalid course id' ) ;
55
- cy . get ( 'form' ) . submit ( ) ;
55
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
56
56
57
57
cy . get ( 'input[name="id"]' ) . should ( 'have.value' , 'invalid course id' ) ;
58
58
} ) ;
@@ -61,23 +61,23 @@ describe('Create courses', () => {
61
61
const uuid = faker . random . uuid ( ) ;
62
62
63
63
cy . get ( 'input[name="id"]' ) . clear ( ) . type ( uuid ) ;
64
- cy . get ( 'form' ) . submit ( ) ;
64
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
65
65
66
66
cy . get ( 'input[name="id"]' ) . should ( 'have.value' , uuid ) ;
67
67
} ) ;
68
68
} ) ;
69
69
70
70
describe ( 'Name field' , ( ) => {
71
71
it ( 'has flash messages when is empty' , ( ) => {
72
- cy . get ( 'form' ) . submit ( ) ;
72
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
73
73
74
74
cy . get ( 'input[name="name"] + p' ) . contains ( 'Invalid name' ) ;
75
75
} ) ;
76
76
77
77
it ( 'has flash messages when is longer than 30 character' , ( ) => {
78
78
cy . get ( 'input[name="name"]' ) . type ( faker . random . alphaNumeric ( 31 ) ) ;
79
79
80
- cy . get ( 'form' ) . submit ( ) ;
80
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
81
81
82
82
cy . get ( 'input[name="name"] + p' ) . contains ( 'Invalid name' ) ;
83
83
} ) ;
@@ -86,7 +86,7 @@ describe('Create courses', () => {
86
86
const invalidCourseName = faker . random . alphaNumeric ( 3 ) ;
87
87
88
88
cy . get ( 'input[name="name"]' ) . clear ( ) . type ( invalidCourseName ) ;
89
- cy . get ( 'form' ) . submit ( ) ;
89
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
90
90
91
91
cy . get ( 'input[name="name"]' ) . should ( 'have.value' , invalidCourseName ) ;
92
92
} ) ;
@@ -95,31 +95,31 @@ describe('Create courses', () => {
95
95
const validCourseName = faker . random . alphaNumeric ( 1 ) ;
96
96
97
97
cy . get ( 'input[name="name"]' ) . clear ( ) . type ( validCourseName ) ;
98
- cy . get ( 'form' ) . submit ( ) ;
98
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
99
99
100
100
cy . get ( 'input[name="name"]' ) . should ( 'have.value' , validCourseName ) ;
101
101
} ) ;
102
102
} ) ;
103
103
104
104
describe ( 'Duration field' , ( ) => {
105
105
it ( 'has flash messages when is empty' , ( ) => {
106
- cy . get ( 'form' ) . submit ( ) ;
106
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
107
107
108
108
cy . get ( 'input[name="duration"] + p' ) . contains ( 'Invalid duration' ) ;
109
109
} ) ;
110
110
111
111
it ( 'has flash messages when is shorter than 4 character' , ( ) => {
112
112
cy . get ( 'input[name="duration"]' ) . type ( faker . random . alphaNumeric ( 3 ) ) ;
113
113
114
- cy . get ( 'form' ) . submit ( ) ;
114
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
115
115
116
116
cy . get ( 'input[name="duration"] + p' ) . contains ( 'Invalid duration' ) ;
117
117
} ) ;
118
118
119
119
it ( 'has flash messages when is longer than 100 character' , ( ) => {
120
120
cy . get ( 'input[name="duration"]' ) . type ( faker . random . alphaNumeric ( 101 ) ) ;
121
121
122
- cy . get ( 'form' ) . submit ( ) ;
122
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
123
123
124
124
cy . get ( 'input[name="duration"] + p' ) . contains ( 'Invalid duration' ) ;
125
125
} ) ;
@@ -128,7 +128,7 @@ describe('Create courses', () => {
128
128
const invalidCourseDuration = faker . random . alphaNumeric ( 101 ) ;
129
129
130
130
cy . get ( 'input[name="duration"]' ) . clear ( ) . type ( invalidCourseDuration ) ;
131
- cy . get ( 'form' ) . submit ( ) ;
131
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
132
132
133
133
cy . get ( 'input[name="duration"]' ) . should ( 'have.value' , invalidCourseDuration ) ;
134
134
} ) ;
@@ -137,7 +137,7 @@ describe('Create courses', () => {
137
137
const validCourseDuration = faker . random . alphaNumeric ( 5 ) ;
138
138
139
139
cy . get ( 'input[name="duration"]' ) . clear ( ) . type ( validCourseDuration ) ;
140
- cy . get ( 'form' ) . submit ( ) ;
140
+ cy . get ( 'form[data-cy="create-course"] ' ) . submit ( ) ;
141
141
142
142
cy . get ( 'input[name="duration"]' ) . should ( 'have.value' , validCourseDuration ) ;
143
143
} ) ;
0 commit comments