Skip to content

Commit

Permalink
Merge branch 'develop' into copy-moment-props
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov authored Dec 3, 2020
2 parents 1e0821e + c42667e commit f36a0c0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
54 changes: 54 additions & 0 deletions packages/driver/cypress/integration/commands/net_stubbing_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,60 @@ describe('network stubbing', { retries: 2 }, function () {
})
})

context('events', function () {
// @see https://github.com/cypress-io/cypress/issues/9170
it('gracefully handles request received without a known route', function () {
cy.intercept('/valid.json', (req) => {
req.reply({ bad: 'should not be received' })
})
.then(() => {
const routeIds = _.keys(state('routes'))

// delete the driver-side route - the server-side route will still exist and cause an event
// to be emitted to the driver
delete state('routes')[routeIds[0]]
expect(state('routes')).to.deep.eq({})

return $.get('/fixtures/valid.json')
})
.then((body) => {
expect(body).to.include({ foo: 1 })
})
})

it('gracefully handles response received without a known route', function () {
cy.intercept('/valid.json', (req) => {
state('routes', {})

req.reply((res) => {
res.send({ bad: 'should not be received' })
})
})
.then(() => {
return $.get('/fixtures/valid.json')
})
.then((body) => {
expect(body).to.include({ foo: 1 })
})
})

it('gracefully handles response completed without a known route', function () {
cy.intercept('/valid.json', (req) => {
req.reply((res) => {
state('routes', {})

res.send({ bar: 2 })
})
})
.then(() => {
return $.get('/fixtures/valid.json')
})
.then((body) => {
expect(body).to.include({ bar: 2 })
})
})
})

context('network handling', function () {
// @see https://github.com/cypress-io/cypress/issues/8497
it('can load transfer-encoding: chunked redirects', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ export const onRequestReceived: HandlerFn<NetEventFrames.HttpRequestReceived> =

continueSent = true

if (request) {
request.state = 'Intercepted'
}

if (continueFrame) {
// copy changeable attributes of userReq to req in frame
// @ts-ignore
Expand All @@ -149,7 +145,10 @@ export const onRequestReceived: HandlerFn<NetEventFrames.HttpRequestReceived> =
emitNetEvent('http:request:continue', continueFrame)
}

request.log.fireChangeEvent()
if (request) {
request.state = 'Intercepted'
request.log && request.log.fireChangeEvent()
}
}

if (!route) {
Expand Down

0 comments on commit f36a0c0

Please sign in to comment.