Skip to content

Commit 631f587

Browse files
Merge branch 'sessions-refactor-pt4' of https://github.com/cypress-io/cypress into sessions-refactor-pt4
2 parents d3b4d9f + 311c12a commit 631f587

File tree

8 files changed

+106
-103
lines changed

8 files changed

+106
-103
lines changed

npm/vue/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [@cypress/vue-v3.1.2](https://github.com/cypress-io/cypress/compare/@cypress/vue-v3.1.1...@cypress/vue-v3.1.2) (2022-05-03)
2+
3+
4+
### Bug Fixes
5+
6+
* head content reset, fix [#19721](https://github.com/cypress-io/cypress/issues/19721) ([#21291](https://github.com/cypress-io/cypress/issues/21291)) ([77ab6a5](https://github.com/cypress-io/cypress/commit/77ab6a51a0de1929171a2275e9cec9580c57241d))
7+
18
# [@cypress/vue-v3.1.1](https://github.com/cypress-io/cypress/compare/@cypress/vue-v3.1.0...@cypress/vue-v3.1.1) (2022-02-10)
29

310

npm/vue/src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ type CyMountOptions<Props, Data = {}> = Omit<MountingOptions<Props, Data>, 'atta
3939
}
4040
} & Partial<StyleOptions>
4141

42-
let initialInnerHtml = ''
43-
4442
Cypress.on('run:start', () => {
4543
// `mount` is designed to work with component testing only.
4644
// it assumes ROOT_ID exists, which is not the case in e2e.
@@ -52,7 +50,6 @@ Cypress.on('run:start', () => {
5250
return
5351
}
5452

55-
initialInnerHtml = document.head.innerHTML
5653
Cypress.on('test:before:run', () => {
5754
Cypress.vueWrapper?.unmount()
5855
// @ts-ignore
@@ -64,7 +61,6 @@ Cypress.on('run:start', () => {
6461
}
6562

6663
el.innerHTML = ''
67-
document.head.innerHTML = initialInnerHtml
6864
})
6965
})
7066

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cypress",
3-
"version": "9.6.0",
3+
"version": "9.6.1",
44
"description": "Cypress.io end to end testing tool",
55
"private": true,
66
"scripts": {

packages/driver/cypress/integration/commands/assertions_spec.js

Lines changed: 67 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ describe('src/cy/commands/assertions', () => {
11511151
})
11521152
})
11531153

1154-
context('format quotation marks', () => {
1154+
describe('message formatting', () => {
11551155
const expectMarkdown = (test, message, done) => {
11561156
cy.then(() => {
11571157
test()
@@ -1168,70 +1168,83 @@ describe('src/cy/commands/assertions', () => {
11681168
})
11691169
}
11701170

1171-
it('preserves quotation marks in number strings', (done) => {
1172-
expectMarkdown(() => {
1173-
try {
1174-
expect(25).to.eq('25')
1175-
} catch (error) {} /* eslint-disable-line no-empty */
1176-
},
1177-
`expected **25** to equal **'25'**`,
1178-
done)
1179-
})
1180-
1181-
it('preserves quotation marks in empty string', (done) => {
1182-
expectMarkdown(() => {
1183-
try {
1184-
expect(42).to.eq('')
1185-
} catch (error) {} /* eslint-disable-line no-empty */
1186-
},
1187-
`expected **42** to equal **''**`,
1188-
done)
1189-
})
1171+
// https://github.com/cypress-io/cypress/issues/19116
1172+
it('text with backslashes', (done) => {
1173+
const text = '"<OE_D]dQ\\'
11901174

1191-
it('preserves quotation marks if escaped', (done) => {
11921175
expectMarkdown(
1193-
() => expect(`\'cypress\'`).to.eq(`\'cypress\'`),
1194-
// ****'cypress'**** -> ** for emphasizing result string + ** for emphasizing the entire result.
1195-
`expected **'cypress'** to equal ****'cypress'****`,
1176+
() => expect(text).to.equal(text),
1177+
`expected **"<OE_D]dQ\\\\** to equal **"<OE_D]dQ\\\\**`,
11961178
done,
11971179
)
11981180
})
11991181

1200-
it('removes quotation marks in DOM elements', (done) => {
1201-
expectMarkdown(
1202-
() => {
1203-
cy.get('body').then(($body) => {
1204-
expect($body).to.contain('div')
1205-
})
1182+
describe('messages with quotation marks', () => {
1183+
it('preserves quotation marks in number strings', (done) => {
1184+
expectMarkdown(() => {
1185+
try {
1186+
expect(25).to.eq('25')
1187+
} catch (error) {} /* eslint-disable-line no-empty */
12061188
},
1207-
`expected **<body>** to contain **div**`,
1208-
done,
1209-
)
1210-
})
1189+
`expected **25** to equal **'25'**`,
1190+
done)
1191+
})
12111192

1212-
it('removes quotation marks in strings', (done) => {
1213-
expectMarkdown(() => expect('cypress').to.eq('cypress'), `expected **cypress** to equal **cypress**`, done)
1214-
})
1193+
it('preserves quotation marks in empty string', (done) => {
1194+
expectMarkdown(() => {
1195+
try {
1196+
expect(42).to.eq('')
1197+
} catch (error) {} /* eslint-disable-line no-empty */
1198+
},
1199+
`expected **42** to equal **''**`,
1200+
done)
1201+
})
12151202

1216-
it('removes quotation marks in objects', (done) => {
1217-
expectMarkdown(
1218-
() => expect({ foo: 'bar' }).to.deep.eq({ foo: 'bar' }),
1219-
`expected **{ foo: bar }** to deeply equal **{ foo: bar }**`,
1220-
done,
1221-
)
1222-
})
1203+
it('preserves quotation marks if escaped', (done) => {
1204+
expectMarkdown(
1205+
() => expect(`\'cypress\'`).to.eq(`\'cypress\'`),
1206+
// ****'cypress'**** -> ** for emphasizing result string + ** for emphasizing the entire result.
1207+
`expected **'cypress'** to equal ****'cypress'****`,
1208+
done,
1209+
)
1210+
})
12231211

1224-
it('formats keys properly for "have.all.keys"', (done) => {
1225-
const person = {
1226-
name: 'Joe',
1227-
age: 20,
1228-
}
1212+
it('removes quotation marks in DOM elements', (done) => {
1213+
expectMarkdown(
1214+
() => {
1215+
cy.get('body').then(($body) => {
1216+
expect($body).to.contain('div')
1217+
})
1218+
},
1219+
`expected **<body>** to contain **div**`,
1220+
done,
1221+
)
1222+
})
12291223

1230-
expectMarkdown(
1231-
() => expect(person).to.have.all.keys('name', 'age'),
1232-
`expected **{ name: Joe, age: 20 }** to have keys **name**, and **age**`,
1233-
done,
1234-
)
1224+
it('removes quotation marks in strings', (done) => {
1225+
expectMarkdown(() => expect('cypress').to.eq('cypress'), `expected **cypress** to equal **cypress**`, done)
1226+
})
1227+
1228+
it('removes quotation marks in objects', (done) => {
1229+
expectMarkdown(
1230+
() => expect({ foo: 'bar' }).to.deep.eq({ foo: 'bar' }),
1231+
`expected **{ foo: bar }** to deeply equal **{ foo: bar }**`,
1232+
done,
1233+
)
1234+
})
1235+
1236+
it('formats keys properly for "have.all.keys"', (done) => {
1237+
const person = {
1238+
name: 'Joe',
1239+
age: 20,
1240+
}
1241+
1242+
expectMarkdown(
1243+
() => expect(person).to.have.all.keys('name', 'age'),
1244+
`expected **{ name: Joe, age: 20 }** to have keys **name**, and **age**`,
1245+
done,
1246+
)
1247+
})
12351248
})
12361249

12371250
describe('formats strings with spaces', (done) => {
@@ -1269,36 +1282,6 @@ describe('src/cy/commands/assertions', () => {
12691282
})
12701283
})
12711284

1272-
// TODO: this suite should be merged with the suite above
1273-
describe('message formatting', () => {
1274-
const expectMarkdown = (test, message, done) => {
1275-
cy.then(() => {
1276-
test()
1277-
})
1278-
1279-
cy.on('log:added', (attrs, log) => {
1280-
if (attrs.name === 'assert') {
1281-
cy.removeAllListeners('log:added')
1282-
1283-
expect(log.get('message')).to.eq(message)
1284-
1285-
done()
1286-
}
1287-
})
1288-
}
1289-
1290-
// https://github.com/cypress-io/cypress/issues/19116
1291-
it('text with backslashes', (done) => {
1292-
const text = '"<OE_D]dQ\\'
1293-
1294-
expectMarkdown(
1295-
() => expect(text).to.equal(text),
1296-
`expected **"<OE_D]dQ\\\\** to equal **"<OE_D]dQ\\\\**`,
1297-
done,
1298-
)
1299-
})
1300-
})
1301-
13021285
context('chai overrides', () => {
13031286
beforeEach(function () {
13041287
this.$body = cy.$$('body')

packages/driver/cypress/integration/cypress/proxy-logging_spec.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,22 @@ describe('Proxy Logging', () => {
181181
}
182182
})
183183

184-
const oldOnload = cy.state('server').options.onLoad
184+
const xhr = new win.XMLHttpRequest()
185185

186-
cy.stub(cy.state('server').options, 'onLoad').log(false).callsFake(function (...args) {
187-
setTimeout(() => {
188-
oldOnload.call(this, ...args)
189-
}, 500)
186+
const logIncomingRequest = Cypress.ProxyLogging.logIncomingRequest
187+
const updateRequestWithResponse = Cypress.ProxyLogging.updateRequestWithResponse
188+
189+
// To simulate the xhr call landing second, we send updateRequestWithResponse immediately after
190+
// the call is intercepted
191+
cy.stub(Cypress.ProxyLogging, 'logIncomingRequest').log(false).callsFake(function (...args) {
192+
logIncomingRequest.call(this, ...args)
193+
updateRequestWithResponse.call(this, {
194+
requestId: args[0].requestId,
195+
status: 404,
196+
})
190197
})
191198

192-
const xhr = new win.XMLHttpRequest()
199+
cy.stub(Cypress.ProxyLogging, 'updateRequestWithResponse').log(false).callsFake(function () {})
193200

194201
xhr.open('GET', '/some-url')
195202
xhr.send()

packages/driver/src/cross-origin/cypress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { $Location } from '../cypress/location'
1010
import $Commands from '../cypress/commands'
1111
import { create as createLog } from '../cypress/log'
1212
import { bindToListeners } from '../cy/listeners'
13-
import { handleOriginFn } from './domain_fn'
13+
import { handleOriginFn } from './origin_fn'
1414
import { FINAL_SNAPSHOT_NAME } from '../cy/snapshots'
1515
import { handleLogs } from './events/logs'
1616
import { handleSocketEvents } from './events/socket'

packages/driver/src/cypress/proxy-logging.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,7 @@ export default class ProxyLogging {
324324
return proxyRequest
325325
}
326326

327-
private updateRequestWithResponse (responseReceived: BrowserResponseReceived): void {
328-
const proxyRequest = _.find(this.proxyRequests, ({ preRequest }) => preRequest.requestId === responseReceived.requestId)
329-
330-
if (!proxyRequest) {
331-
return debug('unmatched responseReceived event %o', responseReceived)
332-
}
333-
327+
private updateProxyRequestWithResponse (proxyRequest, responseReceived) {
334328
proxyRequest.responseReceived = responseReceived
335329

336330
proxyRequest.updateConsoleProps()
@@ -343,6 +337,22 @@ export default class ProxyLogging {
343337
proxyRequest.log?.end()
344338
}
345339

340+
private updateRequestWithResponse (responseReceived: BrowserResponseReceived): void {
341+
const proxyRequest = _.find(this.proxyRequests, ({ preRequest }) => preRequest.requestId === responseReceived.requestId)
342+
343+
if (!proxyRequest) {
344+
return debug('unmatched responseReceived event %o', responseReceived)
345+
}
346+
347+
if (proxyRequest.xhr && proxyRequest.xhr.xhr.readyState !== XMLHttpRequest.DONE) {
348+
proxyRequest.xhr.xhr.addEventListener('load', () => {
349+
this.updateProxyRequestWithResponse(proxyRequest, responseReceived)
350+
})
351+
} else {
352+
this.updateProxyRequestWithResponse(proxyRequest, responseReceived)
353+
}
354+
}
355+
346356
private updateRequestWithError (error: RequestError): void {
347357
const proxyRequest = _.find(this.proxyRequests, ({ preRequest }) => preRequest.requestId === error.requestId)
348358

0 commit comments

Comments
 (0)