/
config-warning.cy.ts
113 lines (95 loc) · 4.19 KB
/
config-warning.cy.ts
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
describe('baseUrl', () => {
it('should show baseUrl warning if Cypress cannot connect to provided baseUrl', () => {
cy.scaffoldProject('config-with-base-url-warning')
cy.openProject('config-with-base-url-warning')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="alert"]').contains('Warning: Cannot Connect Base Url Warning')
cy.withCtx((ctx) => {
sinon.stub(ctx._apis.projectApi, 'isListening').resolves(undefined)
})
cy.contains('button', 'Try again').click()
cy.get('[data-cy="alert"]').should('not.exist')
})
it('should clear baseUrl warning if Cypress can connect to provided baseUrl', () => {
cy.scaffoldProject('config-with-base-url-warning')
cy.openProject('config-with-base-url-warning')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="alert"]').contains('Warning: Cannot Connect Base Url Warning')
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', `
module.exports = {
e2e: {
supportFile: false,
baseUrl: 'http://localhost:5555',
},
}
`)
})
cy.get('h1').should('contain', 'Choose a Browser')
cy.get('[data-cy="alert"]').should('not.exist')
})
it('should add baseUrl warning when going from good to bad config', () => {
cy.scaffoldProject('config-with-js')
cy.openProject('config-with-js')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('h1').should('contain', 'Choose a Browser')
cy.get('[data-cy="alert"]').should('not.exist')
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', `
module.exports = {
pageLoadTimeout: 10000,
e2e: {
supportFile: false,
baseUrl: 'http://localhost:9999',
defaultCommandTimeout: 500,
videoCompression: 20,
},
}
`)
})
cy.get('[data-cy="loading-spinner"]').should('be.visible')
cy.get('h1').should('contain', 'Choose a Browser')
cy.get('[data-cy="alert"]').contains('Warning: Cannot Connect Base Url Warning')
})
})
describe('experimentalStudio', () => {
it('should show experimentalStudio warning if Cypress detects experimentalStudio config has been set', () => {
cy.scaffoldProject('experimental-studio')
cy.openProject('experimental-studio')
cy.visitLaunchpad()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
})
it('should not continually show experimentalStudio warning in the same project', () => {
cy.scaffoldProject('experimental-studio')
cy.openProject('experimental-studio')
cy.visitLaunchpad()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.findAllByLabelText(cy.i18n.components.modal.dismiss).first().click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', await ctx.actions.file.readFileInProject('cypress.config.js'))
})
cy.get('[data-cy="loading-spinner"]')
cy.get('h1').should('contain', 'Welcome to Cypress!')
cy.get('[data-cy="warning-alert"]').should('not.exist')
})
it('should show experimentalStudio warning when opening project and going back', () => {
cy.scaffoldProject('experimental-studio')
cy.addProject('experimental-studio')
cy.openGlobalMode()
cy.visitLaunchpad()
cy.contains('experimental-studio').click()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
cy.findAllByLabelText(cy.i18n.components.modal.dismiss).first().click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.get('a').contains('Projects').click()
cy.contains('[data-cy="project-card"]', 'experimental-studio').click()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="warning-alert"]').contains('Warning: Experimental Studio Removed')
})
})