Skip to content

Commit

Permalink
Merge branch 'develop' into fix/set_module_resolution_with_commonjs
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane committed Jan 12, 2024
2 parents 0481c7a + b19c1cd commit 7d295fa
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 62 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ _Released 1/16/2024 (PENDING)_
- Fixed an issue where some cross-origin logs, like assertions or cy.clock(), were getting too many dom snapshots. Fixes [#28609](https://github.com/cypress-io/cypress/issues/28609).
- Fixed asset capture for Test Replay for requests that are routed through service workers. This addresses an issue where styles were not being applied properly in Test Replay and `cy.intercept` was not working properly for requests in this scenario. Fixes [#28516](https://github.com/cypress-io/cypress/issues/28516).
- Fixed an issue where visiting an `http://` site would result in an infinite reload/redirect loop in Chrome 114+. Fixes [#25891](https://github.com/cypress-io/cypress/issues/25891).
- Fixed an issue where requests made from extra tabs do not include their original headers. Fixes [#28641](https://github.com/cypress-io/cypress/issues/28641).

**Performance:**

Expand Down
7 changes: 7 additions & 0 deletions npm/eslint-plugin-dev/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/eslint-plugin-dev-v5.3.3](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.2...@cypress/eslint-plugin-dev-v5.3.3) (2024-01-12)


### Bug Fixes

* allow for versions greater than 4 for eslint-plugin-mocha to prevent force installing dependencies when eslint-plugin-mocha is bumbed in comsumer packages ([#27944](https://github.com/cypress-io/cypress/issues/27944)) ([bf05978](https://github.com/cypress-io/cypress/commit/bf0597847e71f34303364929f9c34cdd6c0e7ad8))

# [@cypress/eslint-plugin-dev-v5.3.2](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.1...@cypress/eslint-plugin-dev-v5.3.2) (2022-08-15)


Expand Down
2 changes: 2 additions & 0 deletions npm/webpack-dev-server/CHANGELOG.md
@@ -1,3 +1,5 @@
# [@cypress/webpack-dev-server-v3.7.3](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v3.7.2...@cypress/webpack-dev-server-v3.7.3) (2024-01-12)

# [@cypress/webpack-dev-server-v3.7.2](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v3.7.1...@cypress/webpack-dev-server-v3.7.2) (2023-12-26)

# [@cypress/webpack-dev-server-v3.7.1](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v3.7.0...@cypress/webpack-dev-server-v3.7.1) (2023-11-22)
Expand Down
9 changes: 9 additions & 0 deletions packages/driver/cypress.config.ts
Expand Up @@ -22,6 +22,15 @@ export default defineConfig({
experimentalOriginDependencies: true,
experimentalModifyObstructiveThirdPartyCode: true,
setupNodeEvents: (on, config) => {
on('task', {
log (message) {
// eslint-disable-next-line no-console
console.log(message)

return null
},
})

return require('./cypress/plugins')(on, config)
},
baseUrl: 'http://localhost:3500',
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/cypress/e2e/commands/task.cy.js
Expand Up @@ -234,7 +234,7 @@ describe('src/cy/commands/task', () => {
expect(lastLog.get('error')).to.eq(err)
expect(lastLog.get('state')).to.eq('failed')

expect(err.message).to.eq(`\`cy.task('bar')\` failed with the following error:\n\nThe task 'bar' was not handled in the setupNodeEvents method. The following tasks are registered: return:arg, return:foo, return:bar, return:baz, cypress:env, arg:is:undefined, wait, create:long:file, check:screenshot:size\n\nFix this in your setupNodeEvents method here:\n${Cypress.config('configFile')}`)
expect(err.message).to.eq(`\`cy.task('bar')\` failed with the following error:\n\nThe task 'bar' was not handled in the setupNodeEvents method. The following tasks are registered: log, return:arg, return:foo, return:bar, return:baz, cypress:env, arg:is:undefined, wait, create:long:file, check:screenshot:size\n\nFix this in your setupNodeEvents method here:\n${Cypress.config('configFile')}`)

done()
})
Expand Down
96 changes: 59 additions & 37 deletions packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts
Expand Up @@ -66,63 +66,72 @@ describe('cy.origin - snapshots', { browser: '!webkit' }, () => {
logs.set(attrs.id, log)
})

cy.task('log', 'beforeEach before visit')

cy.fixture('foo.bar.baz.json').then((fooBarBaz) => {
cy.task('log', 'beforeEach before intercept')

cy.intercept('GET', '/foo.bar.baz.json', { body: fooBarBaz }).as('fooBarBaz')
})

cy.task('log', 'beforeEach before visit')

cy.visit('/fixtures/primary-origin.html')
cy.task('log', 'beforeEach before get')

cy.get('a[data-cy="xhr-fetch-requests-onload"]').click()
cy.task('log', 'beforeEach after get')
})

// TODO: fix failing test: https://github.com/cypress-io/cypress/issues/23840
it.skip('verifies XHR requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => {
cy.origin('http://www.foobar.com:3500', () => {
// need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js
// @ts-ignore
Cypress.config('isInteractive', true)
cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html')
cy.get(`[data-cy="assertion-header"]`).should('exist')
cy.wait('@fooBarBaz')
})
// it.skip('verifies XHR requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => {
// cy.origin('http://www.foobar.com:3500', () => {
// // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js
// // @ts-ignore
// Cypress.config('isInteractive', true)
// cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html')
// cy.get(`[data-cy="assertion-header"]`).should('exist')
// cy.wait('@fooBarBaz')
// })

cy.shouldWithTimeout(() => {
const xhrLogFromSecondaryOrigin = findLog(logs, 'xhr', 'http://localhost:3500/foo.bar.baz.json')?.get()
// cy.shouldWithTimeout(() => {
// const xhrLogFromSecondaryOrigin = findLog(logs, 'xhr', 'http://localhost:3500/foo.bar.baz.json')?.get()

expect(xhrLogFromSecondaryOrigin).to.exist
// expect(xhrLogFromSecondaryOrigin).to.exist

const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0])
// const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0])

expect(snapshots.length).to.equal(2)
// expect(snapshots.length).to.equal(2)

// TODO: Since we have two events, one of them does not have a request snapshot
// // TODO: Since we have two events, one of them does not have a request snapshot

expect(snapshots[1].querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!')
})
})
// expect(snapshots[1].querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!')
// })
// })

// TODO: fix failing test: https://github.com/cypress-io/cypress/issues/23840
it.skip('verifies fetch requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => {
cy.origin('http://www.foobar.com:3500', () => {
// need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js
// @ts-ignore
Cypress.config('isInteractive', true)
cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html')
cy.get(`[data-cy="assertion-header"]`).should('exist')
cy.wait('@fooBarBaz')
})
// // TODO: fix failing test: https://github.com/cypress-io/cypress/issues/23840
// it.skip('verifies fetch requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => {
// cy.origin('http://www.foobar.com:3500', () => {
// // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js
// // @ts-ignore
// Cypress.config('isInteractive', true)
// cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html')
// cy.get(`[data-cy="assertion-header"]`).should('exist')
// cy.wait('@fooBarBaz')
// })

cy.shouldWithTimeout(() => {
const xhrLogFromSecondaryOrigin = findLog(logs, 'fetch', 'http://localhost:3500/foo.bar.baz.json')?.get()
// cy.shouldWithTimeout(() => {
// const xhrLogFromSecondaryOrigin = findLog(logs, 'fetch', 'http://localhost:3500/foo.bar.baz.json')?.get()

expect(xhrLogFromSecondaryOrigin).to.exist
// expect(xhrLogFromSecondaryOrigin).to.exist

const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0])
// const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0])

snapshots.forEach((snapshot) => {
expect(snapshot.querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!')
})
})
})
// snapshots.forEach((snapshot) => {
// expect(snapshot.querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!')
// })
// })
// })

it('Does not take snapshots of XHR/fetch requests from secondary origin if the wrong origin is visited / origin mismatch, but instead the primary origin (existing behavior)', {
defaultCommandTimeout: 50,
Expand All @@ -142,16 +151,29 @@ describe('cy.origin - snapshots', { browser: '!webkit' }, () => {
done()
})

cy.task('log', 'test before visit')

cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html')

cy.task('log', 'test after visit')

cy.origin('http://www.barbaz.com:3500', () => {
// need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js
// @ts-ignore
Cypress.config('isInteractive', true)

cy.task('log', 'test before get')

cy.get(`[data-cy="assertion-header"]`).should('exist')

cy.task('log', 'test after get')

cy.wait('@fooBarBaz')

cy.task('log', 'test after wait')
})

cy.task('log', 'test after origin')
})
})
})
4 changes: 3 additions & 1 deletion packages/frontend-shared/cypress/support/e2e.ts
Expand Up @@ -369,7 +369,9 @@ function visitLaunchpad () {
return logInternal(`visitLaunchpad ${Cypress.env('e2e_launchpadPort')}`, () => {
return cy.visit(`/__launchpad/index.html`, { log: false }).then((val) => {
return cy.get('[data-e2e]', { timeout: 10000, log: false }).then(() => {
return val
return cy.get('.spinner', { timeout: 10000, log: false }).should('not.exist').then(() => {
return val
})
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/launchpad/cypress/e2e/project-setup.cy.ts
Expand Up @@ -615,7 +615,7 @@ describe('Launchpad: Setup Project', () => {

cy.visitLaunchpad()

cy.get('[data-cy-testingtype="component"]').click()
cy.get('[data-cy-testingtype="component"]', { timeout: 10000 }).click()
cy.get('[data-testid="select-framework"]').click()
cy.findByText('Vue.js 3').click()
cy.contains('button', 'Pick a bundler').click()
Expand Down
9 changes: 8 additions & 1 deletion packages/server/lib/browsers/browser-cri-client.ts
@@ -1,3 +1,4 @@
import _ from 'lodash'
import Bluebird from 'bluebird'
import CRI from 'chrome-remote-interface'
import Debug from 'debug'
Expand Down Expand Up @@ -376,9 +377,15 @@ export class BrowserCriClient {
// we mark extra targets with this header, so that the proxy can recognize
// where they came from and run only the minimal middleware necessary
extraTargetCriClient.on('Fetch.requestPaused', async (params: Protocol.Fetch.RequestPausedEvent) => {
// headers are received as an object but need to be an array to modify them
const headers = _.map(params.request.headers, (value, name) => ({ name, value }))

const details: Protocol.Fetch.ContinueRequestRequest = {
requestId: params.requestId,
headers: [{ name: 'X-Cypress-Is-From-Extra-Target', value: 'true' }],
headers: [
...headers,
{ name: 'X-Cypress-Is-From-Extra-Target', value: 'true' },
],
}

extraTargetCriClient.send('Fetch.continueRequest', details).catch((err) => {
Expand Down
10 changes: 8 additions & 2 deletions packages/server/test/unit/browsers/browser-cri-client_spec.ts
Expand Up @@ -287,11 +287,17 @@ describe('lib/browsers/cri-client', function () {
criClient.send.withArgs('Fetch.continueRequest').resolves()

await BrowserCriClient._onAttachToTarget(options as any)
await criClient.on.lastCall.args[1]({ requestId: 'request-id' })
await criClient.on.lastCall.args[1]({
requestId: 'request-id',
request: { headers: { 'X-Another-Custom-Header': 'value' } },
})

expect(criClient.send).to.be.calledWith('Fetch.continueRequest', {
requestId: 'request-id',
headers: [{ name: 'X-Cypress-Is-From-Extra-Target', value: 'true' }],
headers: [
{ name: 'X-Another-Custom-Header', value: 'value' },
{ name: 'X-Cypress-Is-From-Extra-Target', value: 'true' },
],
})
})

Expand Down
63 changes: 44 additions & 19 deletions scripts/semantic-commits/get-binary-release-data.js
Expand Up @@ -2,10 +2,12 @@ const Bluebird = require('bluebird')
const childProcess = require('child_process')
const _ = require('lodash')
const { Octokit } = require('@octokit/core')
const debugLib = require('debug')

const { getCurrentReleaseData } = require('./get-current-release-data')
const { getNextVersionForBinary } = require('../get-next-version')
const { getLinkedIssues } = require('./get-linked-issues')
const debug = debugLib('scripts:semantic-commits:get-binary-release-data')

const ensureAuth = () => {
if (!process.env.GH_TOKEN) {
Expand Down Expand Up @@ -80,8 +82,6 @@ const fetchPullRequest = async (octokit, pullNumber) => {

return pullRequest
} catch (err) {
console.log(`Error while fetching PR #${pullNumber}:`, err)

const { rateLimitHit, retryAfter } = parseRateLimit(err)

if (rateLimitHit) {
Expand Down Expand Up @@ -133,29 +133,54 @@ const getReleaseData = async (latestReleaseInfo) => {
return
}

const ref = references.find((r) => !r.raw.includes('revert #'))
const refs = references.filter((r) => !r.raw.includes('revert #'))

if (!ref) {
if (!refs.length) {
console.log('Commit does not have an associated pull request number...')

return
}

const pullRequest = await fetchPullRequest(octokit, ref.issue)
const associatedIssues = pullRequest.body ? getLinkedIssues(pullRequest.body) : []

commits.push({
commitMessage: semanticResult.header,
semanticType,
prNumber: ref.issue,
associatedIssues,
})

prsInRelease.push(`https://github.com/cypress-io/cypress/pull/${ref.issue}`)

associatedIssues.forEach((issueNumber) => {
issuesInRelease.push(`https://github.com/cypress-io/cypress/issues/${issueNumber}`)
})
for (const [idx, ref] of refs.entries()) {
let pullRequest

try {
pullRequest = await fetchPullRequest(octokit, ref.issue)
debug(`Pull request #${ref.issue} found!`)
} catch (err) {
debug(`Error while fetching PR #${ ref.issue}:`, err)
// If we have tried to fetch all other references and all of them failed,
// print the failure of the last reference and exit
if (idx === refs.length) {
debug(`all references exhausted and no PR could be found!`)
console.log(`Error while fetching PR #${ ref.issue}:`, err)
throw err
} else {
// otherwise, we still might be able to link a PR to the commit
debug(`Other references need to be tried. Continuing to see if we can find a corresponding pull request.`)
}

continue
}

const associatedIssues = pullRequest.body ? getLinkedIssues(pullRequest.body) : []

commits.push({
commitMessage: semanticResult.header,
semanticType,
prNumber: ref.issue,
associatedIssues,
})

prsInRelease.push(`https://github.com/cypress-io/cypress/pull/${ref.issue}`)

associatedIssues.forEach((issueNumber) => {
issuesInRelease.push(`https://github.com/cypress-io/cypress/issues/${issueNumber}`)
})

// since we found our pull request, we don't need to check the rest of the references
break
}
}))

console.log('Next release version is', nextVersion)
Expand Down

5 comments on commit 7d295fa

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7d295fa Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-x64/fix/set_module_resolution_with_commonjs-7d295fa1427b2243b62d5fec46b9c17095954e39/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7d295fa Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-arm64/fix/set_module_resolution_with_commonjs-7d295fa1427b2243b62d5fec46b9c17095954e39/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7d295fa Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/darwin-x64/fix/set_module_resolution_with_commonjs-7d295fa1427b2243b62d5fec46b9c17095954e39/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7d295fa Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/darwin-arm64/fix/set_module_resolution_with_commonjs-7d295fa1427b2243b62d5fec46b9c17095954e39/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7d295fa Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/win32-x64/fix/set_module_resolution_with_commonjs-7d295fa1427b2243b62d5fec46b9c17095954e39/cypress.tgz

Please sign in to comment.