@@ -17,19 +17,18 @@ describe('CreateGitRepositoryDialog', () => {
1717
1818 it ( 'creates a git repository with valid data' , ( ) => {
1919 const onClose = cy . stub ( ) ;
20- const onSuccess = cy . stub ( ) ;
2120
2221 cy . mount (
2322 < CreateGitRepositoryDialog
2423 isOpen = { true }
2524 namespace = "default"
2625 useCreateGitRepository = { fakeUseCreateGitRepository }
2726 onClose = { onClose }
28- onSuccess = { onSuccess }
2927 /> ,
3028 ) ;
3129
3230 const expectedPayload = {
31+ namespace : 'default' ,
3332 name : 'test-repo' ,
3433 interval : '5m0s' ,
3534 url : 'https://github.com/test/repo' ,
@@ -51,24 +50,22 @@ describe('CreateGitRepositoryDialog', () => {
5150
5251 // Dialog should close on success
5352 cy . wrap ( onClose ) . should ( 'have.been.called' ) ;
54- cy . wrap ( onSuccess ) . should ( 'have.been.called' ) ;
5553 } ) ;
5654
5755 it ( 'includes secretRef when provided' , ( ) => {
5856 const onClose = cy . stub ( ) ;
59- const onSuccess = cy . stub ( ) ;
6057
6158 cy . mount (
6259 < CreateGitRepositoryDialog
6360 isOpen = { true }
6461 namespace = "default"
6562 useCreateGitRepository = { fakeUseCreateGitRepository }
6663 onClose = { onClose }
67- onSuccess = { onSuccess }
6864 /> ,
6965 ) ;
7066
7167 const expectedPayload = {
68+ namespace : 'default' ,
7269 name : 'test-repo' ,
7370 interval : '1m0s' ,
7471 url : 'https://github.com/test/repo' ,
@@ -89,20 +86,17 @@ describe('CreateGitRepositoryDialog', () => {
8986
9087 // Dialog should close on success
9188 cy . wrap ( onClose ) . should ( 'have.been.called' ) ;
92- cy . wrap ( onSuccess ) . should ( 'have.been.called' ) ;
9389 } ) ;
9490
9591 it ( 'validates required fields' , ( ) => {
9692 const onClose = cy . stub ( ) ;
97- const onSuccess = cy . stub ( ) ;
9893
9994 cy . mount (
10095 < CreateGitRepositoryDialog
10196 isOpen = { true }
10297 namespace = "default"
10398 useCreateGitRepository = { fakeUseCreateGitRepository }
10499 onClose = { onClose }
105- onSuccess = { onSuccess }
106100 /> ,
107101 ) ;
108102
@@ -115,51 +109,53 @@ describe('CreateGitRepositoryDialog', () => {
115109
116110 // Dialog should not close
117111 cy . wrap ( onClose ) . should ( 'not.have.been.called' ) ;
118- cy . wrap ( onSuccess ) . should ( 'not.have.been.called' ) ;
119112 } ) ;
120113
121114 it ( 'validates URL format' , ( ) => {
122115 const onClose = cy . stub ( ) ;
123- const onSuccess = cy . stub ( ) ;
124116
125117 cy . mount (
126118 < CreateGitRepositoryDialog
127119 isOpen = { true }
128120 namespace = "default"
129121 useCreateGitRepository = { fakeUseCreateGitRepository }
130122 onClose = { onClose }
131- onSuccess = { onSuccess }
132123 /> ,
133124 ) ;
134125
135126 cy . get ( '#name' ) . find ( 'input' ) . type ( 'test-repo' ) ;
136127 cy . get ( '#interval' ) . find ( 'input' ) . clear ( ) . type ( '1m0s' ) ;
137- cy . get ( '#url' ) . find ( 'input' ) . type ( 'not-a-valid-url' ) ;
138128 cy . get ( '#branch' ) . find ( 'input' ) . clear ( ) . type ( 'main' ) ;
139129
140- // Submit the form
130+ // Test 1: Invalid string
131+ cy . get ( '#url' ) . find ( 'input' ) . clear ( ) . type ( 'not-a-valid-url' ) ;
141132 cy . get ( 'ui5-button' ) . contains ( 'Create' ) . click ( ) ;
133+ cy . get ( '#url' ) . should ( 'have.attr' , 'value-state' , 'Negative' ) ;
134+ cy . contains ( 'Must be a valid HTTPS URL' ) . should ( 'exist' ) ;
142135
143- // Should show validation error
136+ // Test 2: HTTP protocol (should fail if we require HTTPS)
137+ cy . get ( '#url' ) . find ( 'input' ) . clear ( ) . type ( 'http://github.com/test/repo' ) ;
138+ cy . get ( 'ui5-button' ) . contains ( 'Create' ) . click ( ) ;
144139 cy . get ( '#url' ) . should ( 'have.attr' , 'value-state' , 'Negative' ) ;
145140 cy . contains ( 'Must be a valid HTTPS URL' ) . should ( 'exist' ) ;
146141
147- // Dialog should not close
148- cy . wrap ( onClose ) . should ( 'not.have.been.called' ) ;
149- cy . wrap ( onSuccess ) . should ( 'not.have.been.called' ) ;
142+ // Test 3: Valid HTTPS URL (should pass)
143+ cy . get ( '#url' ) . find ( 'input' ) . clear ( ) . type ( 'https://github.com/test/repo' ) ;
144+ cy . get ( 'ui5-button' ) . contains ( 'Create' ) . click ( ) ;
145+
146+ // Dialog should close on success
147+ cy . wrap ( onClose ) . should ( 'have.been.called' ) ;
150148 } ) ;
151149
152150 it ( 'closes dialog when cancel is clicked' , ( ) => {
153151 const onClose = cy . stub ( ) ;
154- const onSuccess = cy . stub ( ) ;
155152
156153 cy . mount (
157154 < CreateGitRepositoryDialog
158155 isOpen = { true }
159156 namespace = "default"
160157 useCreateGitRepository = { fakeUseCreateGitRepository }
161158 onClose = { onClose }
162- onSuccess = { onSuccess }
163159 /> ,
164160 ) ;
165161
@@ -171,20 +167,17 @@ describe('CreateGitRepositoryDialog', () => {
171167
172168 // Dialog should close without calling onSuccess
173169 cy . wrap ( onClose ) . should ( 'have.been.called' ) ;
174- cy . wrap ( onSuccess ) . should ( 'not.have.been.called' ) ;
175170 } ) ;
176171
177172 it ( 'uses default values for interval and branch' , ( ) => {
178173 const onClose = cy . stub ( ) ;
179- const onSuccess = cy . stub ( ) ;
180174
181175 cy . mount (
182176 < CreateGitRepositoryDialog
183177 isOpen = { true }
184178 namespace = "default"
185179 useCreateGitRepository = { fakeUseCreateGitRepository }
186180 onClose = { onClose }
187- onSuccess = { onSuccess }
188181 /> ,
189182 ) ;
190183
@@ -202,15 +195,13 @@ describe('CreateGitRepositoryDialog', () => {
202195 } ) ;
203196
204197 const onClose = cy . stub ( ) ;
205- const onSuccess = cy . stub ( ) ;
206198
207199 cy . mount (
208200 < CreateGitRepositoryDialog
209201 isOpen = { true }
210202 namespace = "default"
211203 useCreateGitRepository = { failingUseCreateGitRepository }
212204 onClose = { onClose }
213- onSuccess = { onSuccess }
214205 /> ,
215206 ) ;
216207
@@ -225,7 +216,6 @@ describe('CreateGitRepositoryDialog', () => {
225216
226217 // Dialog should NOT close on failure
227218 cy . wrap ( onClose ) . should ( 'not.have.been.called' ) ;
228- cy . wrap ( onSuccess ) . should ( 'not.have.been.called' ) ;
229219
230220 // Dialog should still be visible
231221 cy . contains ( 'Create Git Repository' ) . should ( 'be.visible' ) ;
0 commit comments