Files
cypress/system-tests/test/session_spec.ts
T
Lachlan Miller 1f28650d68 chore: change integration->e2e throughout code base (#19345)
* hacky way to update snapshots

* new hack to update snapshots

* trying again

* hacky fix

* ci: snapshots

* ci: snapshots

* snapshots

* mas updates

* update spec API

* fix test

* fix test

* update

* update test

* fix test

* update plugin

* update spec

* webpack optinos

* Update launchpad tests

* fix screenshot paths

* updated snapshot

* change pattern

* guard

* fix smoke test

* patch code coverage

* update percy config

* fix specs

* try updating example project

* update snapshots

* remove old test

* remove snapshot hack

* add back appveyor

* remove old code

* update snapshot

* Fix tests

* wip

* revert snapshot

* reverted all snaps

* remove only

* remove commnet

* remove old code

* reverted file

* lint

* revert video compression spec

* update snapshot

* update spec path logic

* update snap

* updated snap

* snaps

* snaps

* fix spec

* rename ignoreTestFiles to ignoreSpecPattern

* update screenshot dir for runner-ct

* update deprecations

* update

* upate

* fix test

* update snaps

* update snap

* updating snap

* added missing snaps

* updated cypress run mode integration spec

* electron snapshot

* update default

* rename integration->e2e

* rename integration->e2e in packages

* spec.ts -> cy.ts

* spec.ts -> cy.ts

* _spec.js -> .cy.js

* .spec.js -> .cy.js

* .spec.js -> .cy.js

* update config

* update config

* update

* update spec ext

* update config

* update config

* ensure newly scaffold specs are cached

* fix launchpad spec

* types

* update test

* transpile based on spec pattern

* add back example

* remove unnecessary async and nodeVersion

* spec.tsx -> cy.tsx

* update stop-only config

* exclude CT from E2E

* removed old test

* update spec pattern in angular

* update spec pattern in design system

* update all specs npm npm/react

* update spec name

* update spec patterns

* remove old script

* update tests path

* update config

* fix test

* update snapshots

* update examples

* update ignore patterns

* update snapshots

* unit tests

* update tests

* patch code coverage

* revert spec name

* rename a lot of speces

* update

* update spec ext

* update spec

* update spec

* update spec ext

* update lint

* update rules

* update lint

* snaps

* update spec dir

* update paths

* remove unused pluginsfile config opt

* update smoke test

* update create cypress tests

* update gitignore

* update types

* update paths

* update spe

* update test

* update all snaps

* update tests

* update http request spec

* update spec file names

* snaps

* update snaps

* updated snaps

* update snaps

* spacing

* spacing

* spacing

* spacing

* fix perf spec

* update

* update

* revert

* update

* snaps

* snaps

* rename spec

* update snaps

* snapshots

* update tests

* update tests

* update

* fix

* update test projects

* update

* updating

* update run-ct test

* update spec pattern and add defensive check around platform

* fix system test script

* update snap

* snaps

* update test

* update spe

* update for FF

* ff

* remove unused feature flag

* added tests

* fix react example

* update test

* update config

* update test projects

* update snapshots

* correctly remove private prefix on darwin

* fix types

* rename integration -> e2e

* update config

* updatec onfig

* fixing app scaffold integration tests

* remove code

* exclude e2e specs from CT

* update snapshot

* integration->e2e

* update path for test file in ts project

* update schematic

* use updated branch for CI

* update config

* update config

* revert some changes

* remove built code

* revert changes

* update gitignore

* include test spec

* update scaffold script

* wip: renames

* script

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* mass rename

* rename

* rename

* fix angular

* update spec in create cypress tests

* remove old file

* fix tests

* access specPattern in a more idiomatic fashion

* do not duplicate variable

* pass correct params to findSpec in files controller

* add comment explaining spec finding

* remove reference to old file that no longer exist

* resolve conflicts

* fix types

* transpile cypress dir

* update circle ymlg

* update spec pattern for example project

* supportFile: false

* fix circle yml

* update test glob

* rename some specs to use correct .cy ext

* more ext renames

* rename spec

* update extensions

* update extensions

* update specs

Co-authored-by: estrada9166 <estrada9166@hotmail.com>
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
2022-01-11 16:29:55 +10:00

150 lines
3.3 KiB
TypeScript

import systemTests from '../lib/system-tests'
import parser from 'cookie-parser'
import BodyParser from 'body-parser'
const it = systemTests.it
const onServer = function (app) {
app.use(parser())
app.get('*', (req, res, next) => {
res.cookie(req.path, 'value', {
sameSite: 'None',
secure: true,
})
next()
})
app.use(BodyParser.urlencoded())
app.get('/link', (req, res) => {
res.send('<html><h1>link</h1><a href=\'https://www.foo.com:44665/cross_origin\'>second</a></html>')
})
app.get('/status/:code', (req, res) => {
res.sendStatus(+req.params.code)
})
app.get('/cross_origin', (req, res) => {
res.send('<html><h1>cross origin</h1></html>')
})
app.get('/cross_origin_iframe/:name', (req, res) => {
res.send(`<html><body><h1>cross_origin_iframe ${req.params.name}</h1><iframe src="https://127.0.0.2:44665/set-localStorage/${req.params.name}"</body></html>`)
})
app.get('/set-localStorage/:name', (req, res) => {
res.send(`<html><body><h1>set-localStorage ${req.params.name}</h1><script>window.localStorage.clear(); window.localStorage.name = "${req.params.name}"</script></body></html>`)
})
app.get('/make-reqs', (req, res) => {
res.send(`<body><script>(function() {
fetch('/keep_open')
req = new XMLHttpRequest()
req.open('GET', '/keep_open')
req.send()
})()</script></body>`)
})
app.get('/form', (req, res) => {
res.send(`\
<html>
<h1>form</h1>
<form method='POST' action='/submit'>
<input name='delay' />
</form>
</html>\
`)
})
app.post('/submit', (req, res) => {
if (req.body.delay) {
return setTimeout(() => {
res.redirect('/home')
}, +req.body.delay)
}
res.redirect('/home')
})
app.get('/home', (req, res) => {
res.send('<html><h1>home</h1></html>')
})
app.get('/redirect', (req, res) => {
res.redirect('/home')
})
app.get('/keep_open', (req, res) => {
// dont respond
})
app.get('/javascript', (req, res) => {
res.send(`\
<html>
<script type='text/javascript'>
window.redirect = function(){
window.location.href = 'https://www.foo.com:44665/cross_origin'
}
</script>
<h1>javascript</h1>
<button onclick='redirect()'>click me</button>
</html>\
`)
})
app.get('/cors', (req, res) => {
res.send(`<script>
fetch('https://127.0.0.2:44665/cross_origin')
.then((res) => res.text())
.then(text => {
if (text.includes('cross origin')) document.write('success!')
})
.catch(err => document.write(err.message))
</script>`)
})
}
describe('e2e sessions', () => {
systemTests.setup({
servers: [{
port: 4466,
https: true,
onServer,
}, {
port: 44665,
https: true,
onServer,
}, {
port: 4465,
// https: true,
onServer,
}],
settings: {
hosts: {
'*.foo.com': '127.0.0.1',
},
},
})
it('session tests', {
spec: 'session.cy.js',
snapshot: true,
config: {
experimentalSessionSupport: true,
video: false,
},
})
it('sessions persist on reload, and clear between specs', {
spec: 'session_persist_spec_1.js,session_persist_spec_2.js',
snapshot: true,
config: {
experimentalSessionSupport: true,
video: false,
},
})
})