const bodyParser = require('body-parser')
const systemTests = require('../lib/system-tests').default
let count = 0
const onServer = function (app) {
app.use(bodyParser.json())
app.get('/first', (req, res) => {
// reset the count anytime we visit first again
count = 0
return res.send('
first
second')
})
app.get('/second', (req, res) => {
count += 1
return res.send(`second
slow${count}`)
})
app.get('/slow', (req, res) => {
return setTimeout(() => {
return res.send('slow
')
}
, 2000)
})
app.get('/form', (req, res) => {
return res.send(`\
\
`)
})
app.get('/redirected-to', (req, res) => {
return res.send(`\
I AM THE NEW PAGE
\
`)
})
app.post('/json', (req, res) => {
return res.json({
body: req.body,
})
})
return app.get('/html', (req, res) => {
return res.send('content')
})
}
describe('e2e page_loading', () => {
systemTests.setup({
servers: [{
port: 1717,
onServer,
}, {
port: 17170,
static: true,
}],
})
// this tests that __cypress.initial is set correctly whilst navigating
// between pages, or during cy.reload
// additionally this creates an edge case where after __cypress.initial is
// set we send an XHR which should not inject because its requested for JSON
// but that another XHR which is requested for html should inject
systemTests.it('passes', {
browser: '!webkit', // TODO(webkit): fix+unskip (related to document.cookie issue?)
spec: 'page_loading.cy.js',
snapshot: true,
})
})