-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathtabs.cy.js
89 lines (79 loc) · 1.78 KB
/
tabs.cy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* eslint-disable no-undef */
Cypress.on('uncaught:exception', () => {
return false
})
// Function to set up intercepts for the requests
function setupIntercepts() {
const exceptions = [
'/healthz',
'/instance/retrieval',
'/status',
'/admin/config',
]
cy.intercept('GET', '/healthz*', {
statusCode: 200,
body: {
edition: 'standard',
},
})
cy.intercept('GET', '/instance/retrieval*', {
statusCode: 200,
body: {
status: 'inactive',
},
})
cy.intercept('GET', '/status*', {
statusCode: 200,
body: {
status: {
code: 'OK',
message: 'Instance is ready',
},
pools: [],
cloning: {
clones: [],
},
retrieving: {
status: 'inactive',
},
},
})
// Intercept all fetch requests and return a 200
cy.intercept('GET', '*', (req) => {
if (
req.resourceType === 'fetch' &&
exceptions.every((e) => !req.url.includes(e))
) {
req.reply({
statusCode: 200,
body: {
status: 'active',
},
})
}
})
}
describe('Configuration tab', () => {
// It should intercept the requests
beforeEach(() => {
setupIntercepts()
})
it('should have a "Configuration" tab', () => {
cy.visit('/', {
retryOnStatusCodeFailure: true,
onLoad: () => {
cy.get('.MuiTabs-flexContainer')
.contains('Configuration', { timeout: 10000 })
.should('be.visible')
.click({ force: true })
},
})
})
it('should have form inputs in the "Configuration" tab', () => {
cy.get('.MuiTabs-flexContainer')
.contains('Configuration', { timeout: 10000 })
.should('be.visible')
.click({ force: true })
cy.get('button[type="button"]').should('exist')
})
})