-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
navigation_spec.ts
48 lines (44 loc) · 2.04 KB
/
navigation_spec.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
import systemTests, { expect } from '../lib/system-tests'
const PORT = 13370
const onServer = function (app) {
app.get('/cross_origin.html', (req, res) => {
res.send('<html><h1>cross origin</h1></html>')
})
}
describe('e2e cross origin navigation', () => {
systemTests.setup({
servers: [{
port: 4466,
onServer,
}],
settings: {
hosts: {
'*.foobar.com': '127.0.0.1',
},
},
})
// TODO: convert to cypress-in-cypress test if possible
// https://github.com/cypress-io/cypress/issues/20973
systemTests.it('captures cross origin failures when "experimentalLoginFlows" config value is falsy', {
// keep the port the same to prevent issues with the snapshot
port: PORT,
spec: 'navigation_cross_origin_errors.ts',
browser: ['chrome', 'electron'],
snapshot: true,
expectedExitCode: 1,
config: {
experimentalLoginFlows: false,
},
async onRun (exec) {
const res = await exec()
expect(res.stdout).to.contain('Cypress detected a cross origin error happened on page load')
expect(res.stdout).to.contain('Before the page load, you were bound to the origin policy:')
expect(res.stdout).to.contain('A cross origin error happens when your application navigates to a new URL which does not match the origin policy above.')
expect(res.stdout).to.contain('A new URL does not match the origin policy if the \'protocol\', \'port\' (if specified), and/or \'host\' (unless of the same superdomain) are different.')
expect(res.stdout).to.contain('Cypress does not allow you to navigate to a different origin URL within a single test.')
expect(res.stdout).to.contain('You may need to restructure some of your test code to avoid this problem.')
expect(res.stdout).to.contain('Alternatively you can also disable Chrome Web Security in Chromium-based browsers which will turn off this restriction by setting { chromeWebSecurity: false } in `cypress.json`.')
expect(res.stdout).to.contain('https://on.cypress.io/cross-origin-violation')
},
})
})