forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont_flooding_spec.js
51 lines (46 loc) · 1.45 KB
/
font_flooding_spec.js
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
const fs = require('fs-extra')
const path = require('path')
const systemTests = require('../lib/system-tests').default
const Fixtures = require('../lib/fixtures')
const {
createRoutes,
setupStubbedServer,
enableCaptureProtocol,
} = require('../lib/serverStub')
const { PROTOCOL_STUB_FONT_FLOODING } = require('../lib/protocol-stubs/protocolStubResponse')
const getFilePath = (filename) => {
return path.join(
Fixtures.projectPath('protocol'),
'cypress',
'system-tests-protocol-dbs',
`${filename}.json`,
)
}
const BROWSERS = ['chrome', 'electron']
describe('capture-protocol', () => {
setupStubbedServer(createRoutes())
enableCaptureProtocol(PROTOCOL_STUB_FONT_FLOODING)
describe('font flooding', () => {
BROWSERS.forEach((browser) => {
it(`verifies the number of font requests is correct - ${browser}`, function () {
return systemTests.exec(this, {
key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',
project: 'protocol',
spec: 'font-flooding.cy.js',
record: true,
expectedExitCode: 0,
port: 2121,
browser,
config: {
hosts: {
'*foobar.com': '127.0.0.1',
},
},
}).then(() => {
const protocolEvents = fs.readFileSync(getFilePath('e9e81b5e-cc58-4026-b2ff-8ae3161435a6.db'), 'utf8')
expect(JSON.parse(protocolEvents).numberOfFontRequests).to.equal(2)
})
})
})
})
})