/
multi_domain_snapshot_files.spec.ts
69 lines (52 loc) · 2.01 KB
/
multi_domain_snapshot_files.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { findCrossOriginLogs } from '../../../../support/utils'
// @ts-ignore / session support is needed for visiting about:blank between tests
context('cross-origin snapshot files', { experimentalSessionSupport: true }, () => {
let logs: Map<string, any>
beforeEach(() => {
logs = new Map()
cy.on('log:changed', (attrs, log) => {
logs.set(attrs.id, log)
})
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
})
// NOTE: there is no command log for .fixture(). shows up as a (new url)
it.skip('.fixture()', () => undefined)
it('.readFile()', (done) => {
cy.on('command:queue:end', () => {
setTimeout(() => {
const { crossOriginLog, consoleProps } = findCrossOriginLogs('readFile', logs, 'foobar.com')
expect(crossOriginLog).to.be.true
expect(consoleProps.Command).to.equal('readFile')
expect(consoleProps['File Path']).to.include('cypress/fixtures/example.json')
expect(consoleProps.Contents).to.deep.equal({ example: true })
done()
}, 250)
})
cy.origin('http://foobar.com:3500', () => {
cy.readFile('cypress/fixtures/example.json')
})
})
// FIXME: this test hangs and needs investigation
it.skip('.writeFile()', (done) => {
cy.on('command:queue:end', () => {
setTimeout(() => {
const { crossOriginLog, consoleProps } = findCrossOriginLogs('writeFile', logs, 'foobar.com')
expect(crossOriginLog).to.be.true
expect(consoleProps.Command).to.equal('writeFile')
expect(consoleProps['File Path']).to.equal('foo.json')
expect(consoleProps.Contents).to.equal('{"foo":"bar"}')
done()
}, 250)
})
// FIXME: this test hangs when the console is open.
cy.origin('http://foobar.com:3500', () => {
const contents = JSON.stringify({ foo: 'bar' })
cy.stub(Cypress, 'backend').resolves({
contents,
filePath: 'foo.json',
})
cy.writeFile('foo.json', contents)
})
})
})