Skip to content

Commit

Permalink
correct e2e test + snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Nov 5, 2019
1 parent 328788b commit d5b0721
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 33 deletions.
194 changes: 190 additions & 4 deletions packages/server/__snapshots__/2_cookies_spec.coffee.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports['e2e cookies / passes'] = `
exports['e2e cookies with baseurl'] = `
====================================================================================================
Expand All @@ -17,6 +17,191 @@ exports['e2e cookies / passes'] = `
Running: cookies_spec.coffee (1 of 1)
cookies
with whitelist
✓ can get all cookies
✓ resets cookies between tests correctly
✓ should be only two left now
✓ handles undefined cookies
without whitelist
✓ sends cookies to <base domain>:2121
✓ handles expired cookies secure
✓ issue: #224 sets expired cookies between redirects
✓ issue: #1321 failing to set or parse cookie
✓ issue: #2724 does not fail on invalid cookies
✓ can set and clear cookie
in a cy.visit
Result of cy.getCookies():
[ { name: 'namefoo8',
value: 'valfoo8',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo7',
value: 'valfoo7',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo6',
value: 'valfoo6',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo5',
value: 'valfoo5',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo4',
value: 'valfoo4',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo3',
value: 'valfoo3',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo2',
value: 'valfoo2',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo1',
value: 'valfoo1',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo0',
value: 'valfoo0',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false } ]
✓ can set cookies on way too many redirects with HTTPS intermediary
Result of cy.getCookies():
[ { name: 'namefoo8',
value: 'valfoo8',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo7',
value: 'valfoo7',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo6',
value: 'valfoo6',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo5',
value: 'valfoo5',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo4',
value: 'valfoo4',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo3',
value: 'valfoo3',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo2',
value: 'valfoo2',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo1',
value: 'valfoo1',
path: '/',
domain: '<2nd domain>',
secure: false,
httpOnly: false },
{ name: 'namefoo0',
value: 'valfoo0',
path: '/',
domain: '<base domain>',
secure: false,
httpOnly: false } ]
✓ can set cookies on way too many redirects with HTTP intermediary
12 passing
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 12 │
│ Passing: 12 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: cookies_spec.coffee │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/cookies_spec.coffee.mp4 (X second)
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ cookies_spec.coffee XX:XX 12 12 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 12 12 - - -
`

exports['e2e cookies with no baseurl'] = `
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (cookies_spec_no_baseurl.coffee) │
│ Searched: cypress/integration/cookies_spec_no_baseurl.coffee │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: cookies_spec_no_baseurl.coffee (1 of 1)
cookies
with whitelist
✓ can get all cookies
Expand Down Expand Up @@ -45,14 +230,15 @@ exports['e2e cookies / passes'] = `
│ Screenshots: 0 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: cookies_spec.coffee
│ Spec Ran: cookies_spec_no_baseurl.coffee │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/cookies_spec.coffee.mp4 (X second)
- Finished processing: /XXX/XXX/XXX/cypress/videos/cookies_spec_no_baseurl.coffee. (X second)
mp4
====================================================================================================
Expand All @@ -62,7 +248,7 @@ exports['e2e cookies / passes'] = `
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ cookies_spec.coffee XX:XX 9 9 - - - │
│ ✔ cookies_spec_no_baseurl.coffee XX:XX 9 9 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 9 9 - - -
Expand Down
56 changes: 27 additions & 29 deletions packages/server/test/e2e/2_cookies_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,20 @@ describe "e2e cookies", ->
format,
baseDomain
]) =>
httpUrl = "http://#{baseDomain}#{if haveRoot then '' else ":#{httpPort}"}"
httpsUrl = "https://#{baseDomain}#{if haveRoot then '' else ":#{httpsPort}"}"

context "with #{format} urls", ->
[
[httpUrl, false],
[httpsUrl, true]
].forEach ([
baseUrl,
https
]) ->
[
true, false
].forEach (useDefaultPort) ->
httpUrl = "http://#{baseDomain}#{if useDefaultPort then '' else ":#{httpPort}"}"
httpsUrl = "https://#{baseDomain}#{if useDefaultPort then '' else ":#{httpsPort}"}"
true, false
].forEach (useDefaultPort) ->
httpUrl = "http://#{baseDomain}#{if useDefaultPort then '' else ":#{httpPort}"}"
httpsUrl = "https://#{baseDomain}#{if useDefaultPort then '' else ":#{httpsPort}"}"

[
[httpUrl, false],
[httpsUrl, true]
].forEach ([
baseUrl,
https
]) ->
e2e.it "passes with baseurl: #{baseUrl}", {
config: {
baseUrl
Expand All @@ -167,27 +164,28 @@ describe "e2e cookies", ->
spec: "cookies_spec.coffee"
snapshot: true
expectedExitCode: 0
originalTitle: "e2e cookies with baseurl"
onStdout: (stdout) ->
stdout.replace(otherDomain, '<2nd domain>')
.replace(baseDomain, '<base domain>')
onRun: (exec) ->
if useDefaultPort and not haveRoot
console.warn('cannot use default port since not root, skipping')
return @skip()

exec()
exec({
originalTitle: "e2e cookies with baseurl"
onStdout: (stdout) ->
stdout.replace(new RegExp(otherDomain, 'g'), '<2nd domain>')
.replace(new RegExp(baseDomain, 'g'), '<base domain>')
})
}

e2e.it "passes with no baseurl", {
config: {
env: {
httpUrl
httpsUrl
e2e.it "passes with no baseurl", {
config: {
env: {
httpUrl
httpsUrl
}
}
originalTitle: "e2e cookies with no baseurl"
spec: "cookies_spec_no_baseurl.coffee"
snapshot: true
expectedExitCode: 0
}
originalTitle: "e2e cookies with no baseurl"
spec: "cookies_spec_no_baseurl.coffee"
snapshot: true
expectedExitCode: 0
}

0 comments on commit d5b0721

Please sign in to comment.