Skip to content

Commit

Permalink
Merge branch 'develop' into cacie/fix-hook-test-stack-analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
cacieprins authored Jan 14, 2025
2 parents 15ed6aa + 249cfde commit b5490b3
Show file tree
Hide file tree
Showing 27 changed files with 208 additions and 45 deletions.
4 changes: 2 additions & 2 deletions browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chrome:beta": "132.0.6834.57",
"chrome:stable": "131.0.6778.204",
"chrome:beta": "132.0.6834.83",
"chrome:stable": "131.0.6778.264",
"chrome:minimum": "64.0.3282.0"
}
2 changes: 2 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ in this [GitHub issue](https://github.com/cypress-io/cypress/issues/30447). Addr
- Elements whose parent elements has `overflow: clip` and no height/width will now correctly show as hidden. Fixed in [#29778](https://github.com/cypress-io/cypress/pull/29778). Fixes [#23852](https://github.com/cypress-io/cypress/issues/23852).
- The CSS pseudo-class `:dir()` is now supported when testing in Electron. Addresses [#29766](https://github.com/cypress-io/cypress/issues/29766).
- The Open in IDE button next to blocks and hooks in the runner UI will now properly open the IDE. This bug was introduced in a prerelease version of Cypress 14.0.0. Fixed in [#30859](https://github.com/cypress-io/cypress/pull/30859). Fixes [#30847](https://github.com/cypress-io/cypress/issues/30847).
- Fixed an issue where the spec filename was not updating correctly when changing specs in `open` mode. Fixes [#30852](https://github.com/cypress-io/cypress/issues/30852).
- `cy.origin()` now correctly errors when the [`cy.window()`](https://docs.cypress.io/api/commands/window), [`cy.document()`](https://docs.cypress.io/api/commands/document), [`cy.title()`](https://docs.cypress.io/api/commands/title), [`cy.url()`](https://docs.cypress.io/api/commands/url), [`cy.location()`](https://docs.cypress.io/api/commands/location) ,[`cy.hash()`](https://docs.cypress.io/api/commands/hash), [`cy.go()`](https://docs.cypress.io/api/commands/go), [`cy.reload()`](https://docs.cypress.io/api/commands/reload), and [`cy.scrollTo()`](https://docs.cypress.io/api/commands/scrollTo) commands are used outside of the `cy.origin()` command after the AUT has navigated away from the primary origin. Fixes [#30848](https://github.com/cypress-io/cypress/issues/30848). Fixed in [#30858](https://github.com/cypress-io/cypress/pull/30858).

**Misc:**

Expand Down
3 changes: 3 additions & 0 deletions npm/webpack-dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"webpack-4": "npm:webpack@^4",
"webpack-dev-server-4": "npm:webpack-dev-server@^4"
},
"peerDependencies": {
"cypress": ">=14.0.0"
},
"files": [
"dist"
],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,6 @@
"devtools-protocol": "0.0.1346313",
"sharp": "0.29.3",
"vue-template-compiler": "2.6.12"
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
20 changes: 20 additions & 0 deletions packages/app/cypress/e2e/specs_list_e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ describe('App: Spec List (E2E)', () => {
cy.findByTestId('runnable-header').should('be.visible')
})

it('updates the spec filename when a new spec is selected', () => {
// load the first spec
cy.findAllByTestId('spec-item-link').contains('accounts_list.spec.js').click()

// ensure the tests are loaded
cy.contains('[aria-controls=reporter-inline-specs-list]', 'Specs')
cy.findByText('Your tests are loading...').should('not.be.visible')

// open the inline spec list
cy.get('body').type('f')

// verify the first spec filename
cy.findByTestId('runnable-header').contains('accounts_list.spec.js')

// select the second spec from the inline spec list
cy.findAllByTestId('spec-file-item').contains('accounts_new.spec.js').click()
// verify the spec filename was updated
cy.findByTestId('runnable-header').contains('accounts_new.spec.js')
})

it('cannot open the Spec File Row link in a new tab with "cmd + click"', (done) => {
let numTargets
let newNumTargets
Expand Down
2 changes: 2 additions & 0 deletions packages/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
],
"compilerOptions": {
"noImplicitThis": true,
"useDefineForClassFields": true,
"paths": {
"@cy/i18n": ["../frontend-shared/src/locales/i18n"],
"@cy/components/*": ["../frontend-shared/src/components/*"],
"@cy/gql-components/*": ["../frontend-shared/src/gql-components/*"],
"@cy/store/*": ["../frontend-shared/src/store/*"],
"@packages/*": ["../*"]
},
"allowJs": true,
"types": [
"cypress",
"cypress-real-events",
Expand Down
3 changes: 2 additions & 1 deletion packages/config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"allowJs": false,
"rootDir": "src",
"noImplicitAny": true,
"noUncheckedIndexedAccess": true,
"types": ["node"],
"typeRoots": [
"../../node_modules/@types"
],
}
}
}
3 changes: 2 additions & 1 deletion packages/data-context/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lib": ["esnext"],
"allowJs": false,
"noImplicitAny": true,
"noUncheckedIndexedAccess": true,
"types": ["cypress"],
}
}
}
104 changes: 95 additions & 9 deletions packages/driver/cypress/e2e/e2e/origin/commands/actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,109 @@ context('cy.origin actions', { browser: '!webkit' }, () => {

context('cross-origin AUT errors', () => {
// We only need to check .get here because the other commands are chained off of it.
// the exceptions are window(), document(), title(), url(), hash(), location(), go(), reload(), and scrollTo()
const assertOriginFailure = (err: Error, done: () => void) => {
expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`)
expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`)
expect(err.message).to.include(`Using \`cy.origin()\` to wrap the commands run on \`http://www.foobar.com:3500\` will likely fix this issue.`)
expect(err.message).to.include(`cy.origin('http://www.foobar.com:3500', () => {\`\n\` <commands targeting http://www.foobar.com:3500 go here>\`\n\`})`)

// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
done()
}

it('.get()', { defaultCommandTimeout: 50 }, (done) => {
cy.on('fail', (err) => {
expect(err.message).to.include(`Timed out retrying after 50ms:`)
expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`)
expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`)
expect(err.message).to.include(`Using \`cy.origin()\` to wrap the commands run on \`http://www.foobar.com:3500\` will likely fix this issue.`)
expect(err.message).to.include(`cy.origin('http://www.foobar.com:3500', () => {\`\n\` <commands targeting http://www.foobar.com:3500 go here>\`\n\`})`)

// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
done()
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.get('#button')
})

it('.window()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.window()
})

it('.document()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.document()
})

it('.title()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.title()
})

it('.url()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.url()
})

it('.hash()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.hash()
})

it('.location()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.location()
})

it('.go()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.go('back')
})

it('.reload()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.reload()
})

it('.scrollTo()', (done) => {
cy.on('fail', (err) => {
assertOriginFailure(err, done)
})

cy.get('a[data-cy="dom-link"]').click()
cy.scrollTo('bottom')
})
})

context('#consoleProps', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ context('cy.origin viewport', { browser: '!webkit' }, () => {

cy.window().its('innerHeight').should('eq', 480)
cy.window().its('innerWidth').should('eq', 320)
})

cy.window().then((win) => {
win.location.href = 'http://www.idp.com:3500/fixtures/primary-origin.html'
cy.window().then((win) => {
win.location.href = 'http://www.idp.com:3500/fixtures/primary-origin.html'
})
})

cy.origin('http://www.idp.com:3500', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/driver/cypress/e2e/e2e/origin/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ describe('event timing', { browser: '!webkit' }, () => {

cy.origin('http://www.foobar.com:3500', () => {
cy.log('inside cy.origin foobar')
})

// This command is run from localhost against the cross-origin aut. Updating href is one of the few allowed commands. See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#location
cy.window().then((win) => {
win.location.href = 'http://www.idp.com:3500/fixtures/primary-origin.html'
// Updating href is one of the few allowed commands. See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#location
// However, not everything on the window is accessible. Therefore, we force window() to only run on the same origin as the AUT context
cy.window().then((win) => {
win.location.href = 'http://www.idp.com:3500/fixtures/primary-origin.html'
})
})

cy.origin('http://www.idp.com:3500', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/driver/src/cy/commands/actions/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ export default (Commands, Cypress, cy, state) => {
const subjectChain = cy.subjectChain()

const ensureScrollability = () => {
// Make sure the scroll command can communicate with the AUT
Cypress.ensure.commandCanCommunicateWithAUT(cy)

try {
subject = cy.getSubjectFromChain(subjectChain)

Expand Down
9 changes: 9 additions & 0 deletions packages/driver/src/cy/commands/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import $errUtils from '../../cypress/error_utils'

export default (Commands, Cypress, cy) => {
Commands.addQuery('url', function url (options: Partial<Cypress.UrlOptions> = {}) {
// Make sure the url command can communicate with the AUT.
// otherwise, it yields an empty string
Cypress.ensure.commandCanCommunicateWithAUT(cy)
this.set('timeout', options.timeout)

Cypress.log({ message: '', hidden: options.log === false, timeout: options.timeout })
Expand All @@ -16,6 +19,8 @@ export default (Commands, Cypress, cy) => {
})

Commands.addQuery('hash', function url (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
// Make sure the hash command can communicate with the AUT.
Cypress.ensure.commandCanCommunicateWithAUT(cy)
this.set('timeout', options.timeout)

Cypress.log({ message: '', hidden: options.log === false, timeout: options.timeout })
Expand All @@ -26,6 +31,10 @@ export default (Commands, Cypress, cy) => {
Commands.addQuery('location', function location (key, options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
// normalize arguments allowing key + options to be undefined
// key can represent the options

// Make sure the location command can communicate with the AUT.
// otherwise the command just yields 'null' and the reason may be unclear to the user.
Cypress.ensure.commandCanCommunicateWithAUT(cy)
if (_.isObject(key)) {
options = key
}
Expand Down
7 changes: 7 additions & 0 deletions packages/driver/src/cy/commands/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ export default (Commands, Cypress, cy, state, config) => {
cleanup()
}

// Make sure the reload command can communicate with the AUT.
// if we failed for any other reason, we need to display the correct error to the user.
Cypress.ensure.commandCanCommunicateWithAUT(cy)

return null
})
},
Expand Down Expand Up @@ -700,6 +704,9 @@ export default (Commands, Cypress, cy, state, config) => {
cleanup()
}

// Make sure the go command can communicate with the AUT.
Cypress.ensure.commandCanCommunicateWithAUT(cy)

return null
})
}
Expand Down
7 changes: 7 additions & 0 deletions packages/driver/src/cy/commands/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ export default (Commands, Cypress, cy, state) => {
}

Commands.addQuery('title', function title (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
// Make sure the window command can communicate with the AUT.
// otherwise, it yields an empty string
Cypress.ensure.commandCanCommunicateWithAUT(cy)
this.set('timeout', options.timeout)
Cypress.log({ timeout: options.timeout, hidden: options.log === false })

return () => (state('document')?.title || '')
})

Commands.addQuery('window', function windowFn (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
// Make sure the window command can communicate with the AUT.
Cypress.ensure.commandCanCommunicateWithAUT(cy)
this.set('timeout', options.timeout)
Cypress.log({
hidden: options.log === false,
Expand All @@ -114,6 +119,8 @@ export default (Commands, Cypress, cy, state) => {
})

Commands.addQuery('document', function documentFn (options: Partial<Cypress.Loggable & Cypress.Timeoutable> = {}) {
// Make sure the document command can communicate with the AUT.
Cypress.ensure.commandCanCommunicateWithAUT(cy)
this.set('timeout', options.timeout)
Cypress.log({
hidden: options.log === false,
Expand Down
1 change: 0 additions & 1 deletion packages/driver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"preserveWatchOutput": true,
"sourceMap": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"outDir": "dist",
"noErrorTruncation": true,
Expand Down
3 changes: 2 additions & 1 deletion packages/errors/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"allowJs": false,
"noImplicitAny": true,
"noImplicitReturns": false,
"noUncheckedIndexedAccess": true,
}
}
}
1 change: 1 addition & 0 deletions packages/extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../ts/tsconfig.json",
"compilerOptions": {
"target": "es2015",
"allowJs": true,
"strict": false
}
}
6 changes: 3 additions & 3 deletions packages/graphql/schemas/cloud.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ type CloudProjectNotFound {
}

union CloudProjectResult =
CloudProject
| CloudProject
| CloudProjectNotFound
| CloudProjectUnauthorized

Expand Down Expand Up @@ -456,7 +456,7 @@ type CloudProjectSpec implements Node {
}

union CloudProjectSpecFlakyResult =
CloudFeatureNotEnabled
| CloudFeatureNotEnabled
| CloudProjectSpecFlakyStatus

type CloudProjectSpecFlakyStatus {
Expand Down Expand Up @@ -500,7 +500,7 @@ type CloudProjectSpecNotFound {
}

union CloudProjectSpecResult =
CloudProjectSpec
| CloudProjectSpec
| CloudProjectSpecNotFound
| CloudProjectUnauthorized

Expand Down
Loading

4 comments on commit b5490b3

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b5490b3 Jan 14, 2025

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/14.0.0/linux-arm64/cacie/fix-hook-test-stack-analysis-b5490b30b82a3b1453c5f76df3192a845708331f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b5490b3 Jan 14, 2025

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/14.0.0/linux-x64/cacie/fix-hook-test-stack-analysis-b5490b30b82a3b1453c5f76df3192a845708331f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b5490b3 Jan 14, 2025

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/14.0.0/darwin-arm64/cacie/fix-hook-test-stack-analysis-b5490b30b82a3b1453c5f76df3192a845708331f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b5490b3 Jan 14, 2025

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/14.0.0/win32-x64/cacie/fix-hook-test-stack-analysis-b5490b30b82a3b1453c5f76df3192a845708331f/cypress.tgz

Please sign in to comment.