@@ -6,6 +6,13 @@ Cypress.on('uncaught:exception', () => {
6
6
7
7
// Function to set up intercepts for the requests
8
8
function setupIntercepts ( ) {
9
+ const exceptions = [
10
+ '/healthz' ,
11
+ '/instance/retrieval' ,
12
+ '/status' ,
13
+ '/admin/config' ,
14
+ ]
15
+
9
16
cy . intercept ( 'GET' , '/healthz*' , {
10
17
statusCode : 200 ,
11
18
body : {
@@ -36,26 +43,47 @@ function setupIntercepts() {
36
43
} ,
37
44
} ,
38
45
} )
46
+
47
+ // Intercept all fetch requests and return a 200
48
+ cy . intercept ( 'GET' , '*' , ( req ) => {
49
+ if (
50
+ req . resourceType === 'fetch' &&
51
+ exceptions . every ( ( e ) => ! req . url . includes ( e ) )
52
+ ) {
53
+ req . reply ( {
54
+ statusCode : 200 ,
55
+ body : {
56
+ status : 'active' ,
57
+ } ,
58
+ } )
59
+ }
60
+ } )
39
61
}
40
62
41
63
describe ( 'Configuration tab' , ( ) => {
64
+ // It should intercept the requests
42
65
beforeEach ( ( ) => {
43
- cy . visit ( '/' )
44
66
setupIntercepts ( )
45
67
} )
46
68
47
- it ( 'should have "Configuration" tab with form inputs' , ( ) => {
48
- cy . get ( '.MuiTabs-flexContainer' ) . contains ( 'Configuration' ) . click ( {
49
- force : true ,
69
+ it ( 'should have a "Configuration" tab' , ( ) => {
70
+ cy . visit ( '/' , {
71
+ retryOnStatusCodeFailure : true ,
72
+ onLoad : ( ) => {
73
+ cy . get ( '.MuiTabs-flexContainer' )
74
+ . contains ( 'Configuration' , { timeout : 10000 } )
75
+ . should ( 'be.visible' )
76
+ . click ( { force : true } )
77
+ } ,
50
78
} )
79
+ } )
51
80
52
- cy . get ( 'input[type="text"]' ) . should ( 'exist' )
53
- cy . get ( 'input[type="checkbox"]' ) . should ( 'exist' )
54
- cy . get ( 'button[type="button"]' ) . should ( 'exist' )
81
+ it ( 'should have form inputs in the "Configuration" tab' , ( ) => {
82
+ cy . get ( '.MuiTabs-flexContainer' )
83
+ . contains ( 'Configuration' , { timeout : 10000 } )
84
+ . should ( 'be.visible' )
85
+ . click ( { force : true } )
55
86
56
- cy . get ( 'button' ) . contains ( 'Cancel' ) . click ( {
57
- force : true ,
58
- } )
59
- cy . url ( ) . should ( 'eq' , Cypress . config ( ) . baseUrl + '/instance' )
87
+ cy . get ( 'button[type="button"]' ) . should ( 'exist' )
60
88
} )
61
89
} )
0 commit comments