Skip to content

Commit

Permalink
fix: sync currentRetry state with secondary origin (#28651)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough authored Jan 10, 2024
1 parent 765b859 commit c9592bf
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 45 deletions.
3 changes: 2 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ _Released 1/16/2024 (PENDING)_

**Bugfixes:**

- Now 'node_modules' will not be ignored if a project path or a provided path to spec files contains it. Fixes [#23616](https://github.com/cypress-io/cypress/issues/23616).
- Now `node_modules` will not be ignored if a project path or a provided path to spec files contains it. Fixes [#23616](https://github.com/cypress-io/cypress/issues/23616).
- Updated display of assertions and commands with a URL argument to escape markdown formatting so that values are displayed as is and assertion values display as bold. Fixes [#24960](https://github.com/cypress-io/cypress/issues/24960) and [#28100](https://github.com/cypress-io/cypress/issues/28100).
- When generating assertions via Cypress Studio, the preview of the generated assertions now correctly displays the past tense of 'expected' instead of 'expect'. Fixed in [#28593](https://github.com/cypress-io/cypress/pull/28593).
- Fixed a regression in [`13.6.2`](https://docs.cypress.io/guides/references/changelog/13.6.2) where the `body` element was not highlighted correctly in Test Replay. Fixed in [#28627](https://github.com/cypress-io/cypress/pull/28627).
- Correctly sync `Cypress.currentRetry` with secondary origin so test retries that leverage `cy.origin()` render logs as expected. Fixes [#28574](https://github.com/cypress-io/cypress/issues/28574).
- 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).
Expand Down
95 changes: 52 additions & 43 deletions packages/driver/cypress/e2e/e2e/origin/origin.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,57 +154,66 @@ describe('cy.origin', { browser: '!webkit' }, () => {
cy.log('after cy.origin')
})

it('passes runnable state to the secondary origin', () => {
const runnable = cy.state('runnable')
const expectedRunnable = {
clearTimeout: null,
isPending: null,
resetTimeout: null,
timeout: null,
id: runnable.id,
_currentRetry: runnable._currentRetry,
_timeout: 4000,
type: 'test',
title: 'passes runnable state to the secondary origin',
titlePath: [
'cy.origin',
'withBeforeEach',
'passes runnable state to the secondary origin',
],
parent: {
id: runnable.parent.id,
type: 'suite',
title: 'withBeforeEach',
;[{
title: 'first attempt',
retries: 0,
}, {
title: 'on retry',
retries: 1,
}].forEach(({ title, retries }) => {
it(`passes runnable state to the secondary origin ${title}`, { retries }, () => {
const runnable = cy.state('runnable')
const expectedRunnable = {
clearTimeout: null,
isPending: null,
resetTimeout: null,
timeout: null,
id: runnable.id,
_currentRetry: retries,
_timeout: 4000,
type: 'test',
title: `passes runnable state to the secondary origin ${title}`,
titlePath: [
'cy.origin',
'withBeforeEach',
`passes runnable state to the secondary origin ${title}`,
],
parent: {
id: runnable.parent.parent.id,
id: runnable.parent.id,
type: 'suite',
title: '',
titlePath: undefined,
title: 'withBeforeEach',
titlePath: [
'withBeforeEach',
],
parent: {
id: runnable.parent.parent.id,
type: 'suite',
title: '',
titlePath: undefined,
ctx: {},
},
ctx: {},
},
ctx: {},
},
ctx: {},
}

cy.origin('http://www.foobar.com:3500', { args: expectedRunnable }, (expectedRunnable) => {
const actualRunnable = cy.state('runnable')

expect(actualRunnable.titlePath()).to.deep.equal(expectedRunnable.titlePath)
expectedRunnable.titlePath = actualRunnable.titlePath

expect(actualRunnable.title).to.equal(expectedRunnable.title)
expect(actualRunnable.id).to.equal(expectedRunnable.id)
expect(actualRunnable.ctx).to.deep.equal(expectedRunnable.ctx)
expect(actualRunnable._timeout).to.equal(expectedRunnable._timeout)
expect(actualRunnable.type).to.equal(expectedRunnable.type)
expect(actualRunnable.callback).to.exist
expect(actualRunnable.timeout).to.exist
expect(actualRunnable.parent.title).to.equal(expectedRunnable.parent.title)
expect(actualRunnable.parent.type).to.equal(expectedRunnable.parent.type)
}

cy.origin('http://www.foobar.com:3500', { args: expectedRunnable }, (expectedRunnable) => {
const actualRunnable = cy.state('runnable')

expect(actualRunnable.titlePath()).to.deep.equal(expectedRunnable.titlePath)
expectedRunnable.titlePath = actualRunnable.titlePath

expect(actualRunnable.title).to.equal(expectedRunnable.title)
expect(actualRunnable.id).to.equal(expectedRunnable.id)
expect(actualRunnable.ctx).to.deep.equal(expectedRunnable.ctx)
expect(actualRunnable._currentRetry).to.equal(expectedRunnable._currentRetry)
expect(actualRunnable._timeout).to.equal(expectedRunnable._timeout)
expect(actualRunnable.type).to.equal(expectedRunnable.type)
expect(actualRunnable.callback).to.exist
expect(actualRunnable.timeout).to.exist
expect(actualRunnable.parent.title).to.equal(expectedRunnable.parent.title)
expect(actualRunnable.parent.type).to.equal(expectedRunnable.parent.type)
})
})
})

Expand Down
2 changes: 2 additions & 0 deletions packages/driver/src/cross-origin/origin_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface serializedRunnable {
title: string
parent: serializedRunnable
ctx: {}
_currentRetry: number
_timeout: number
titlePath: string
}
Expand All @@ -44,6 +45,7 @@ const rehydrateRunnable = (data: serializedRunnable): Runnable|Test => {

runnable.ctx = data.ctx
runnable.id = data.id
runnable._currentRetry = data._currentRetry
runnable._timeout = data._timeout
// Short circuit title path to avoid implementing it up the parent chain.
runnable.titlePath = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/origin/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import _ from 'lodash'
export const serializeRunnable = (runnable) => {
if (!runnable) return undefined

const fields = _.pick(runnable, ['id', 'type', 'title', 'parent', 'ctx', 'titlePath', '_timeout'])
const fields = _.pick(runnable, ['id', 'type', 'title', 'parent', 'ctx', 'titlePath', '_currentRetry', '_timeout'])

fields.ctx = _.pick(runnable.ctx, ['currentTest.id', 'currentTest._currentRetry', 'currentTest.type', 'currentTest.title'])

Expand Down

4 comments on commit c9592bf

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c9592bf Jan 10, 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/develop-c9592bf400e2b2c5c8073abbe9191f87a1de09ec/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c9592bf Jan 10, 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/develop-c9592bf400e2b2c5c8073abbe9191f87a1de09ec/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c9592bf Jan 10, 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/develop-c9592bf400e2b2c5c8073abbe9191f87a1de09ec/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c9592bf Jan 10, 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/develop-c9592bf400e2b2c5c8073abbe9191f87a1de09ec/cypress.tgz

Please sign in to comment.