/
cypress-in-cypress-run-mode.cy.ts
104 lines (86 loc) · 3.49 KB
/
cypress-in-cypress-run-mode.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
describe('Cypress In Cypress - run mode', { viewportWidth: 1200 }, () => {
it('e2e run mode spec runner header is correct', () => {
cy.scaffoldProject('cypress-in-cypress')
cy.findBrowsers()
cy.openProject('cypress-in-cypress')
cy.startAppServer()
cy.visitApp()
simulateRunModeInUI()
cy.contains('dom-content.spec').click()
cy.waitForSpecToFinish()
cy.findByTestId('aut-url').should('be.visible')
cy.findByTestId('playground-activator').should('not.exist')
cy.findByLabelText('Stats').within(() => {
cy.get('.passed .num', { timeout: 10000 }).should('have.text', '1')
})
// confirm expected content is rendered
cy.contains('1000x660').should('be.visible')
cy.contains('71%').should('be.visible')
cy.contains('Chrome 1').should('be.visible')
cy.contains('http://localhost:4455/cypress/e2e/dom-content.html').should('be.visible')
// confirm no interactions are implemented
cy.findByTestId('viewport').click()
cy.contains('The viewport determines').should('not.exist')
cy.contains('Chrome 1').click()
cy.contains('Firefox').should('not.exist')
// cy.percySnapshot() // TODO: restore when Percy CSS is fixed. See https://github.com/cypress-io/cypress/issues/23435
})
// TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23306
it('component testing run mode spec runner header is correct', { retries: 15 }, () => {
cy.scaffoldProject('cypress-in-cypress')
cy.findBrowsers()
cy.openProject('cypress-in-cypress')
cy.startAppServer('component')
cy.visitApp()
simulateRunModeInUI()
cy.contains('TestComponent.spec').click()
cy.waitForSpecToFinish()
cy.findByTestId('aut-url').should('not.exist')
cy.findByTestId('playground-activator').should('not.exist')
cy.findByLabelText('Stats').within(() => {
cy.get('.passed .num', { timeout: 10000 }).should('have.text', '1')
})
// confirm expected content is rendered
cy.contains('500x500').should('be.visible')
cy.contains('Chrome 1').should('be.visible')
// confirm no interactions are implemented
cy.findByTestId('viewport').click()
cy.contains('The viewport determines').should('not.exist')
cy.contains('Chrome 1').click()
cy.contains('Firefox').should('not.exist')
// cy.percySnapshot() // TODO: restore when Percy CSS is fixed. See https://github.com/cypress-io/cypress/issues/23435
})
it('hides reporter when NO_COMMAND_LOG is set in run mode', () => {
cy.scaffoldProject('cypress-in-cypress')
cy.findBrowsers()
cy.openProject('cypress-in-cypress')
cy.startAppServer()
cy.withCtx(async (ctx, o) => {
const config = await ctx.project.getConfig()
o.sinon.stub(ctx.project, 'getConfig').resolves({
...config,
env: {
...config.env,
NO_COMMAND_LOG: 1,
},
})
})
cy.visitApp()
simulateRunModeInUI()
cy.contains('dom-content.spec').click()
cy.contains('http://localhost:4455/cypress/e2e/dom-content.html').should('be.visible')
cy.findByLabelText('Stats').should('not.exist')
cy.findByTestId('specs-list-panel').should('not.be.visible')
cy.findByTestId('reporter-panel').should('not.be.visible')
cy.findByTestId('sidebar').should('not.exist')
})
})
function simulateRunModeInUI () {
// this simulates run mode enough for this test
cy.window().then((win) => {
win.__CYPRESS_MODE__ = 'run'
cy.get('body').then(($el) => {
$el.find('[data-cy="sidebar"]')?.remove()
})
})
}