Skip to content

Commit

Permalink
Merge branch 'develop' into retry-flake
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Dec 6, 2022
2 parents 28a9efe + 166bf8e commit 5e86b55
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 42 deletions.
2 changes: 2 additions & 0 deletions packages/app/cypress/e2e/runner/sessions.ui.cy.ts
Expand Up @@ -106,6 +106,7 @@ describe('runner/cypress sessions.ui.spec', {
validateSessionsInstrumentPanel(['blank_session'])

cy.get('.command-name-session')
.first()
.within(() => {
cy.contains('blank_session')
cy.contains('failed')
Expand Down Expand Up @@ -301,6 +302,7 @@ describe('runner/cypress sessions.ui.spec', {
validateSessionsInstrumentPanel(['user1'])

cy.get('.command-name-session')
.first()
.within(() => {
cy.contains('failed')

Expand Down
5 changes: 4 additions & 1 deletion packages/app/cypress/e2e/runs.cy.ts
Expand Up @@ -941,7 +941,10 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
cy.get('[data-cy="run-card-icon-RUNNING"]').should('have.length', 3).should('be.visible')
cy.wrap(obj).invoke('toCall')

cy.get('[data-cy="run-card-icon-PASSED"]').should('have.length', 3).should('be.visible').within(() => {
cy.get('[data-cy="run-card-icon-PASSED"]')
.should('have.length', 3)
.should('be.visible')
.first().within(() => {
cy.get('[data-cy="runResults-passed-count"]').should('contain', 100)
})

Expand Down
4 changes: 2 additions & 2 deletions packages/driver/cypress/e2e/commands/querying/root.cy.js
Expand Up @@ -17,7 +17,7 @@ describe('src/cy/commands/querying', () => {
it('returns withinSubject if exists', () => {
const form = cy.$$('form')

cy.get('form').within(() => {
cy.get('form').first().within(() => {
cy
.get('input')
.root().then(($root) => {
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('src/cy/commands/querying', () => {
it('sets $el to withinSubject', () => {
const form = cy.$$('form')

cy.get('form').within(() => {
cy.get('form').first().within(() => {
cy
.get('input')
.root().then(function ($root) {
Expand Down
13 changes: 11 additions & 2 deletions packages/driver/cypress/e2e/commands/querying/within.cy.js
Expand Up @@ -228,7 +228,7 @@ describe('src/cy/commands/querying/within', () => {
})

it('provides additional information in console prop', () => {
cy.get('div').within(() => {})
cy.get('div').first().within(() => {})
cy.then(function () {
const { lastLog } = this

Expand All @@ -237,7 +237,6 @@ describe('src/cy/commands/querying/within', () => {
expect(consoleProps).to.be.an('object')
expect(consoleProps.Command).to.eq('within')
expect(consoleProps.Yielded).to.not.be.null
expect(consoleProps.Yielded).to.have.length(55)
})
})
})
Expand Down Expand Up @@ -304,6 +303,16 @@ describe('src/cy/commands/querying/within', () => {

cy.get('#list').within(() => {})
})

it('throws when given multiple subjects', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.include('`cy.within()` can only be called on a single element. Your subject contained 9 elements.')

done()
})

cy.get('ul').within(() => {})
})
})
})

Expand Down
4 changes: 4 additions & 0 deletions packages/driver/src/cy/commands/querying/within.ts
Expand Up @@ -107,6 +107,10 @@ export default (Commands, Cypress, cy, state) => {
$errUtils.throwErrByPath('within.invalid_argument', { onFail: log })
}

if (subject.length > 1) {
$errUtils.throwErrByPath('within.multiple_elements', { args: { num: subject.length }, onFail: log })
}

return withinFn(subject, fn)
})
},
Expand Down
14 changes: 14 additions & 0 deletions packages/driver/src/cypress/error_messages.ts
Expand Up @@ -2404,6 +2404,20 @@ export default {
message: `${cmd('within')} must be called with a function.`,
docsUrl: 'https://on.cypress.io/within',
},
multiple_elements (args) {
return {
message: stripIndent`
${cmd('within')} can only be called on a single element. Your subject contained {{num}} elements. Narrow down your subject to a single element (using \`.first()\`, for example) before calling \`.within()\`.
To run \`.within()\` over multiple subjects, use \`.each()\`.
\`cy.get('div').each($div => {\`
\` cy.wrap($div).within(() => { ... })\`
\`})\`
`,
docsUrl: 'https://on.cypress.io/within',
}
},
},

wrap: {
Expand Down
60 changes: 24 additions & 36 deletions packages/launchpad/cypress/e2e/project-setup.cy.ts
Expand Up @@ -87,12 +87,10 @@ describe('Launchpad: Setup Project', () => {
cy.contains('h1', 'Configuration files')
cy.findByText('We added the following files to your project:')

cy.get('[data-cy=valid]').within(() => {
cy.contains('cypress.config.js')
cy.containsPath('cypress/support/e2e.js')
cy.containsPath('cypress/support/commands.js')
cy.containsPath('cypress/fixtures/example.json')
})
cy.get('[data-cy=valid]').as('valid').contains('cypress.config.js')
cy.get('@valid').containsPath('cypress/support/e2e.js')
cy.get('@valid').containsPath('cypress/support/commands.js')
cy.get('@valid').containsPath('cypress/fixtures/example.json')

cy.get('[data-cy=valid] [data-cy=collapsible-header]').each((element) => {
cy.wrap(element).should('have.attr', 'aria-expanded', 'false')
Expand Down Expand Up @@ -247,12 +245,10 @@ describe('Launchpad: Setup Project', () => {
cy.contains('h1', 'Configuration files')
cy.findByText('We added the following files to your project:')

cy.get('[data-cy=valid]').within(() => {
cy.contains('cypress.config.js')
cy.containsPath('cypress/support/e2e.js')
cy.containsPath('cypress/support/commands.js')
cy.containsPath('cypress/fixtures/example.json')
})
cy.get('[data-cy=valid]').as('valid').contains('cypress.config.js')
cy.get('@valid').containsPath('cypress/support/e2e.js')
cy.get('@valid').containsPath('cypress/support/commands.js')
cy.get('@valid').containsPath('cypress/fixtures/example.json')

cy.get('[data-cy=valid] [data-cy=collapsible-header]').each((element) => {
cy.wrap(element).should('have.attr', 'aria-expanded', 'false')
Expand All @@ -278,12 +274,10 @@ describe('Launchpad: Setup Project', () => {
cy.contains('h1', 'Configuration files')
cy.findByText('We added the following files to your project:')

cy.get('[data-cy=valid]').within(() => {
cy.contains('cypress.config.js')
cy.containsPath('cypress/support/e2e.js')
cy.containsPath('cypress/support/commands.js')
cy.containsPath('cypress/fixtures/example.json')
})
cy.get('[data-cy=valid]').as('valid').contains('cypress.config.js')
cy.get('@valid').containsPath('cypress/support/e2e.js')
cy.get('@valid').containsPath('cypress/support/commands.js')
cy.get('@valid').containsPath('cypress/fixtures/example.json')

verifyScaffoldedFiles('e2e')

Expand Down Expand Up @@ -317,12 +311,10 @@ describe('Launchpad: Setup Project', () => {
cy.contains('h1', 'Configuration files')
cy.findByText('We added the following files to your project:')

cy.get('[data-cy=valid]').within(() => {
cy.contains('cypress.config.js')
cy.containsPath('cypress/support/e2e.js')
cy.containsPath('cypress/support/commands.js')
cy.containsPath('cypress/fixtures/example.json')
})
cy.get('[data-cy=valid]').as('valid').contains('cypress.config.js')
cy.get('@valid').containsPath('cypress/support/e2e.js')
cy.get('@valid').containsPath('cypress/support/commands.js')
cy.get('@valid').containsPath('cypress/fixtures/example.json')

cy.get('[data-cy=valid] [data-cy=collapsible-header]').each((element) => {
cy.wrap(element).should('have.attr', 'aria-expanded', 'false')
Expand Down Expand Up @@ -353,12 +345,10 @@ describe('Launchpad: Setup Project', () => {
cy.contains('h1', 'Configuration files')
cy.findByText('We added the following files to your project:')

cy.get('[data-cy=valid]').within(() => {
cy.contains('cypress.config.ts')
cy.containsPath('cypress/support/e2e.ts')
cy.containsPath('cypress/support/commands.ts')
cy.containsPath('cypress/fixtures/example.json')
})
cy.get('[data-cy=valid]').as('valid').contains('cypress.config.ts')
cy.get('@valid').containsPath('cypress/support/e2e.ts')
cy.get('@valid').containsPath('cypress/support/commands.ts')
cy.get('@valid').containsPath('cypress/fixtures/example.json')

cy.get('[data-cy=valid] [data-cy=collapsible-header]').each((element) => {
cy.wrap(element).should('have.attr', 'aria-expanded', 'false')
Expand Down Expand Up @@ -410,12 +400,10 @@ describe('Launchpad: Setup Project', () => {

cy.findByRole('button', { name: 'Skip' }).click()

cy.get('[data-cy=valid]').within(() => {
cy.contains('cypress.config.js')
cy.containsPath('cypress/support/component-index.html')
cy.containsPath('cypress/support/component.js')
cy.containsPath('cypress/support/commands.js')
})
cy.get('[data-cy=valid]').as('valid').contains('cypress.config.js')
cy.get('@valid').containsPath('cypress/support/component-index.html')
cy.get('@valid').containsPath('cypress/support/component.js')
cy.get('@valid').containsPath('cypress/support/commands.js')

verifyScaffoldedFiles('component')
})
Expand Down
2 changes: 1 addition & 1 deletion packages/launchpad/src/migration/MajorVersionWelcome.vue
Expand Up @@ -54,7 +54,7 @@
</h2>

<p>
Cypress now has full support for testing multiple domains of different origins in a single test with the <ExternalLink href="https://on.cypress.io/origin">
Cypress now has full support for testing multiple origins in a single test with the <ExternalLink href="https://on.cypress.io/origin">
<code>cy.origin()</code>
</ExternalLink> command! To take a deep-dive into how this works, read our

Expand Down

4 comments on commit 5e86b55

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5e86b55 Dec 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/linux-arm64/retry-flake-5e86b554a2e0717cef96ea29906dc15199e2449c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5e86b55 Dec 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/linux-x64/retry-flake-5e86b554a2e0717cef96ea29906dc15199e2449c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5e86b55 Dec 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/darwin-x64/retry-flake-5e86b554a2e0717cef96ea29906dc15199e2449c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 5e86b55 Dec 6, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/win32-x64/retry-flake-5e86b554a2e0717cef96ea29906dc15199e2449c/cypress.tgz

Please sign in to comment.