Skip to content

Commit

Permalink
Merge branch 'develop' into 66e8896-master-into-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Barthélémy Ledoux authored Aug 12, 2021
2 parents 66e8896 + 9df2543 commit 3ab80fd
Show file tree
Hide file tree
Showing 39 changed files with 1,608 additions and 907 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.16.0
14.17.0
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branches:
# https://www.appveyor.com/docs/lang/nodejs-iojs/
environment:
# use matching version of Node.js
nodejs_version: "14.16.0"
nodejs_version: "14.17.0"
# encode secure variables which will NOT be used
# in pull requests
# https://www.appveyor.com/docs/build-configuration/#secure-variables
Expand Down
4 changes: 2 additions & 2 deletions browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "93.0.4577.18",
"chrome:stable": "92.0.4515.107"
"chrome:beta": "93.0.4577.25",
"chrome:stable": "92.0.4515.131"
}
5 changes: 3 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers:node14.16.0-chrome90-ff88
- image: cypress/browsers:node14.17.0-chrome91-ff89
# by default, we use "small" to save on CI costs. bump on a per-job basis if needed.
resource_class: small
environment:
Expand All @@ -58,7 +58,7 @@ executors:
# Docker image with non-root "node" user
non-root-docker-user:
docker:
- image: cypress/browsers:node14.16.0-chrome90-ff88
- image: cypress/browsers:node14.17.0-chrome91-ff89
user: node
environment:
PLATFORM: linux
Expand Down Expand Up @@ -1126,6 +1126,7 @@ jobs:

runner-integration-tests-electron:
<<: *defaults
resource_class: medium
parallelism: 2
steps:
- run-runner-integration-tests:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"yarn-deduplicate": "3.1.0"
},
"engines": {
"node": ">=14.16.0",
"node": ">=14.17.0",
"yarn": ">=1.17.3"
},
"productName": "Cypress",
Expand Down
80 changes: 80 additions & 0 deletions packages/driver/cypress/integration/commands/net_stubbing_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,61 @@ describe('network stubbing', { retries: 2 }, function () {
cy.get('#request').click()
cy.get('#result').should('contain', 'client')
})

it('works with reply', () => {
cy.intercept({
method: 'POST',
times: 1,
url: '/post-only',
},
(req) => {
req.reply('stubbed data')
}).as('interceptor')

cy.visit('fixtures/request.html')

cy.get('#request').click()
cy.get('#result').should('contain', 'stubbed data')

cy.get('#request').click()
cy.get('#result').should('contain', 'client')
})

it('works with reply and fallthrough', () => {
let times = 0

cy.intercept({
method: 'POST',
times: 3,
url: '/post-only',
},
(req) => {
req.reply(`${req.body === 'foo' ? 'foo' : 'nothing'} stubbed data ${times++}`)
})

cy.intercept({
method: 'POST',
times: 2,
url: '/post-only',
},
(req) => {
req.body = 'foo'
})

cy.visit('fixtures/request.html')

cy.get('#request').click()
cy.get('#result').should('contain', 'foo stubbed data 0')

cy.get('#request').click()
cy.get('#result').should('contain', 'foo stubbed data 1')

cy.get('#request').click()
cy.get('#result').should('contain', 'nothing stubbed data 2')

cy.get('#request').click()
cy.get('#result').should('contain', 'client')
})
})
})
})
Expand Down Expand Up @@ -2628,6 +2683,31 @@ describe('network stubbing', { retries: 2 }, function () {
.wait('@get')
})

// https://github.com/cypress-io/cypress/issues/17084
it('does not overwrite the json-related content-type header', () => {
cy.intercept('/json-content-type', (req) => {
req.on('response', (res) => {
res.send({
statusCode: 500,
headers: {
'content-type': 'application/problem+json',
'access-control-allow-origin': '*',
},
body: {
status: 500,
title: 'Internal Server Error',
},
})
})
})
.then(() => {
return fetch('/json-content-type')
.then((res) => {
expect(res.headers.get('content-type')).to.eq('application/problem+json')
})
})
})

context('body parsing', function () {
[
'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ describe('src/cy/commands/waiting', () => {
cy.wait('@foo', '@bar')
})

it('throws when passed caallback function', (done) => {
it('throws when passed callback function', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.eq('`cy.wait()` was passed invalid arguments. You cannot pass a function. If you would like to wait on the result of a `cy.wait()`, use `cy.then()`.')
expect(err.docsUrl).to.eq('https://on.cypress.io/wait')
Expand Down
196 changes: 196 additions & 0 deletions packages/driver/cypress/integration/cypress/command_queue_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import _ from 'lodash'
import $Command from '../../../src/cypress/command'

import { create } from '../../../src/cypress/command_queue'

const createCommand = (props = {}) => {
return $Command.create(_.extend({
name: 'get',
args: ['#foo'],
type: 'parent',
chainerId: _.uniqueId('ch'),
userInvocationStack: '',
injected: false,
fn () {},
}, props))
}

const log = (props = {}) => {
return Cypress.log(_.extend({
name: _.uniqueId('l'),
}, props))
}

describe('src/cypress/command_queue', () => {
let queue
const state = () => {}
const timeouts = { timeout () {} }
const stability = { whenStable () {} }
const cleanup = () => {}
const fail = () => {}
const isCy = () => {}

beforeEach(() => {
queue = create(state, timeouts, stability, cleanup, fail, isCy)

queue.add(createCommand({
name: 'get',
logs: [log({ name: 'l1', alias: 'alias-1' }), log({ name: 'l2', alias: 'alias-1' })],
}))

queue.add(createCommand({
name: 'find',
logs: [log({ name: 'l3', alias: 'alias-2' })],
}))

queue.add(createCommand({
name: 'click',
logs: [log({ name: 'l4', alias: 'alias-1' }), log({ name: 'l5', alias: 'alias-3' })],
}))
})

context('#logs', () => {
it('returns a flat list of logs from the commands', () => {
const logs = queue.logs()

expect(_.invokeMap(logs, 'get', 'name')).to.eql(['l1', 'l2', 'l3', 'l4', 'l5'])
})

it('returns a filtered list of logs if filter is provided', () => {
const logs = queue.logs({ alias: 'alias-1' })

expect(_.invokeMap(logs, 'get', 'name')).to.eql(['l1', 'l2', 'l4'])
})
})

context('#get', () => {
it('returns list of commands', () => {
const commands = queue.get()

expect(_.invokeMap(commands, 'get', 'name')).to.eql(['get', 'find', 'click'])
})
})

context('#names', () => {
it('returns list of command names', () => {
const names = queue.names()

expect(names).to.eql(['get', 'find', 'click'])
})
})

context('#insert', () => {
it('inserts command into queue at index', () => {
queue.insert(1, createCommand({ name: 'eq' }))

expect(queue.names()).to.eql(['get', 'eq', 'find', 'click'])
})

it('returns the command', () => {
const command = createCommand({ name: 'eq' })
const result = queue.insert(1, command)

expect(result).to.equal(command)
})

it('resets the next and prev commands', () => {
const command = queue.insert(1, createCommand({ name: 'eq' }))
const prev = queue.at(0)
const next = queue.at(2)

expect(command.get('prev')).to.equal(prev)
expect(command.get('next')).to.equal(next)
expect(prev.get('next')).to.equal(command)
expect(next.get('prev')).to.equal(command)
})

it('works with start boundary index', () => {
const command = queue.insert(0, createCommand({ name: 'eq' }))
const next = queue.at(1)

expect(queue.names()).to.eql(['eq', 'get', 'find', 'click'])
expect(command.get('prev')).to.be.undefined
expect(command.get('next')).to.equal(next)
expect(next.get('prev')).to.equal(command)
})

it('works with end boundary index', () => {
const command = queue.insert(3, createCommand({ name: 'eq' }))
const prev = queue.at(2)

expect(queue.names()).to.eql(['get', 'find', 'click', 'eq'])
expect(command.get('prev')).to.equal(prev)
expect(command.get('next')).to.be.undefined
expect(prev.get('next')).to.equal(command)
})
})

context('#slice', () => {
it('returns commands from the index', () => {
const commands = queue.slice(1)

expect(_.invokeMap(commands, 'get', 'name')).to.eql(['find', 'click'])
})
})

context('#at', () => {
it('returns command at index', () => {
const command = queue.at(1)

expect(command.get('name')).to.equal('find')
})
})

context('#find', () => {
it('returns command that matches attributes', () => {
const command = queue.find({ name: 'click' })

expect(command.get('name')).to.equal('click')
})
})

context('#reset', () => {
it('resets the queue stopped state', () => {
queue.reset()

expect(queue.stopped).to.be.false
})
})

context('#clear', () => {
it('removes all commands from queue', () => {
queue.stop()
queue.clear()

expect(queue.get().length).to.equal(0)
})
})

context('#stop', () => {
it('stops the queue', () => {
queue.stop()

expect(queue.stopped).to.be.true
})
})

context('.length', () => {
it('is the number of commands in the queue', () => {
expect(queue.length).to.equal(3)
queue.insert(0, createCommand({ name: 'eq' }))
expect(queue.length).to.equal(4)
})
})

context('.stopped', () => {
it('is true when queue is stopped', () => {
queue.stop()

expect(queue.stopped).to.true
})

it('is false when queue is not stopped', () => {
expect(queue.stopped).to.false
})
})
})
Loading

0 comments on commit 3ab80fd

Please sign in to comment.