Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:cypress-io/cypress into feature/…
Browse files Browse the repository at this point in the history
…create-from-react-component
  • Loading branch information
astone123 committed Dec 16, 2022
2 parents ca6be7a + 331c1dc commit 7f14a32
Show file tree
Hide file tree
Showing 42 changed files with 5,966 additions and 44 deletions.
12 changes: 6 additions & 6 deletions cli/types/cypress.d.ts
Expand Up @@ -1589,19 +1589,19 @@ declare namespace Cypress {
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
nextUntil<K extends keyof HTMLElementTagNameMap>(selector: K, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<E extends HTMLElement = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
nextUntil<E extends Node = HTMLElement>(selector: string, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<E extends HTMLElement = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
nextUntil<E extends Node = HTMLElement>(element: E | JQuery<E>, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>

/**
* Filter DOM element(s) from a set of DOM elements. Opposite of `.filter()`
Expand Down Expand Up @@ -1774,21 +1774,21 @@ declare namespace Cypress {
* Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
* > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery.
*
* @see https://on.cypress.io/prevall
* @see https://on.cypress.io/prevuntil
*/
prevUntil<K extends keyof HTMLElementTagNameMap>(selector: K, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
* > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery.
*
* @see https://on.cypress.io/prevall
* @see https://on.cypress.io/prevuntil
*/
prevUntil<E extends Node = HTMLElement>(selector: string, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
* > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery.
*
* @see https://on.cypress.io/prevall
* @see https://on.cypress.io/prevuntil
*/
prevUntil<E extends Node = HTMLElement>(element: E | JQuery<E>, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>

Expand Down
26 changes: 26 additions & 0 deletions cli/types/tests/cypress-tests.ts
Expand Up @@ -1136,3 +1136,29 @@ namespace CypressLocalStorageTests {
cy.clearAllSessionStorage({ log: false })
cy.clearAllSessionStorage({ log: 'true' }) // $ExpectError
}

namespace CypressTraversalTests {
cy.wrap({}).prevUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).prevUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).prevUntil('span', 'a') // $ExpectType Chainable<JQuery<HTMLSpanElement>>
cy.wrap({}).prevUntil('#myItem', 'a') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).prevUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLDivElement>>
cy.wrap({}).prevUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).prevUntil('#myItem', 'a', { log: 'true' }) // $ExpectError

cy.wrap({}).nextUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).nextUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).nextUntil('span', 'a') // $ExpectType Chainable<JQuery<HTMLSpanElement>>
cy.wrap({}).nextUntil('#myItem', 'a') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).nextUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLDivElement>>
cy.wrap({}).nextUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).nextUntil('#myItem', 'a', { log: 'true' }) // $ExpectError

cy.wrap({}).parentsUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).parentsUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).parentsUntil('span', 'a') // $ExpectType Chainable<JQuery<HTMLSpanElement>>
cy.wrap({}).parentsUntil('#myItem', 'a') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).parentsUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLDivElement>>
cy.wrap({}).parentsUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).parentsUntil('#myItem', 'a', { log: 'true' }) // $ExpectError
}
7 changes: 7 additions & 0 deletions npm/webpack-dev-server/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/webpack-dev-server-v3.1.2](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v3.1.1...@cypress/webpack-dev-server-v3.1.2) (2022-12-16)


### Bug Fixes

* use srcRoot for angular build context ([#25090](https://github.com/cypress-io/cypress/issues/25090)) ([7c36118](https://github.com/cypress-io/cypress/commit/7c361187e31c3681f415da8a9073221d807987f6))

# [@cypress/webpack-dev-server-v3.1.1](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v3.1.0...@cypress/webpack-dev-server-v3.1.1) (2022-12-08)


Expand Down
35 changes: 32 additions & 3 deletions npm/webpack-dev-server/src/helpers/angularHandler.ts
@@ -1,10 +1,13 @@
import * as fs from 'fs-extra'
import { tmpdir } from 'os'
import * as path from 'path'
import type { Configuration } from 'webpack'
import type { Configuration, RuleSetRule } from 'webpack'
import type { PresetHandlerResult, WebpackDevServerConfig } from '../devServer'
import { dynamicAbsoluteImport, dynamicImport } from '../dynamic-import'
import { sourceDefaultWebpackDependencies } from './sourceRelativeWebpackModules'
import debugLib from 'debug'

const debug = debugLib('cypress:webpack-dev-server:angularHandler')

export type BuildOptions = Record<string, any>

Expand Down Expand Up @@ -217,7 +220,7 @@ function createFakeContext (projectRoot: string, defaultProjectConfig: Cypress.A
getProjectMetadata: () => {
return {
root: defaultProjectConfig.root,
sourceRoot: defaultProjectConfig.root,
sourceRoot: defaultProjectConfig.sourceRoot,
projectType: 'application',
}
},
Expand Down Expand Up @@ -250,7 +253,33 @@ async function getAngularCliWebpackConfig (devServerConfig: AngularWebpackDevSer
const { config } = await generateBrowserWebpackConfigFromContext(
buildOptions,
context,
(wco: any) => [getCommonConfig(wco), getStylesConfig(wco)],
(wco: any) => {
const stylesConfig = getStylesConfig(wco)

// We modify resolve-url-loader and set `root` to be `projectRoot` + `sourceRoot` to ensure
// imports in scss, sass, etc are correctly resolved.
// https://github.com/cypress-io/cypress/issues/24272
stylesConfig.module.rules.forEach((rule: RuleSetRule) => {
rule.rules?.forEach((ruleSet) => {
if (!Array.isArray(ruleSet.use)) {
return
}

ruleSet.use.map((loader) => {
if (typeof loader !== 'object' || typeof loader.options !== 'object' || !loader.loader?.includes('resolve-url-loader')) {
return
}

const root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot)

debug('Adding root %s to resolve-url-loader options', root)
loader.options.root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot)
})
})
})

return [getCommonConfig(wco), stylesConfig]
},
)

delete config.entry.main
Expand Down
8 changes: 8 additions & 0 deletions packages/app/cypress/e2e/runner/support/snapshot-reporter.ts
Expand Up @@ -13,6 +13,14 @@ export const snapshotReporter = () => {
'[data-cy=reporter-panel]': ($el) => {
$el.attr('style', 'width: 450px !important')
},
'[data-cy=reporter-running-icon]': ($el) => {
// remove 'fa-spin' class so that the icon is not animated
$el.attr('class', '')
},
'.command-progress': ($el) => {
// don't display command progress bar in snapshot
$el.attr('style', 'display: none !important')
},
},
})
}
13 changes: 11 additions & 2 deletions packages/data-context/src/actions/MigrationActions.ts
Expand Up @@ -189,8 +189,17 @@ export class MigrationActions {
return this.ctx.onError(getError('MIGRATION_CYPRESS_NOT_FOUND'))
}

if (!semver.satisfies(version, '^10.0.0')) {
return this.ctx.onError(getError('MIGRATION_MISMATCHED_CYPRESS_VERSIONS', version))
const currentVersion = (await this.ctx.versions.versionData()).current.version

// Validate that the project being migrated has a version of Cypress compatible with the version being executed.
// This handles situations where Cypress is launched in global mode to migrate a project with an older version of
// Cypress as a dependency which could break the project when launched directly.
// For example:
// Local: 9.6.0 Global: 10.0.0 FAIL
// Local: 10.0.1 Global: 10.0.0 PASS
// Local: 12.0.0 Global: 12.0.1 FAIL
if (!semver.satisfies(version, `^${currentVersion}`)) {
return this.ctx.onError(getError('MIGRATION_MISMATCHED_CYPRESS_VERSIONS', version, currentVersion))
}
}

Expand Down
Expand Up @@ -67,7 +67,7 @@ describe('MigrationActions', () => {
fs.writeJsonSync(path.join(mockCypressDir, 'package.json'), mockPkgJson)
}

it('errors when local cypress version is <10', () => {
it('errors when local cypress version is <10', async () => {
mockLocallyInstalledCypress(currentProject, '9.5.0')
const ctx = createTestDataContext()

Expand All @@ -77,9 +77,11 @@ describe('MigrationActions', () => {
coreData.app.isGlobalMode = true
})

const currentVersion = (await ctx.versions.versionData()).current.version

return (
expect(ctx.actions.migration.initialize({})).to.eventually.be.rejectedWith(
'You are running Cypress version 10 in global mode, but you are attempting to migrate a project where Cypress version 9.5.0 is installed',
`You are running Cypress version ${currentVersion} in global mode, but you are attempting to migrate a project where Cypress version 9.5.0 is installed`,
)
)
})
Expand Down
6 changes: 6 additions & 0 deletions packages/driver/cypress/e2e/commands/querying/querying.cy.js
Expand Up @@ -82,6 +82,12 @@ describe('src/cy/commands/querying', () => {
cy.get('doesNotExist')
})

it('respects null withinSubject', () => {
cy.get('#list').within(() => {
cy.get('#upper', { withinSubject: null })
})
})

describe('custom elements', () => {
// <foobarbazquux>custom element</foobarbazquux>

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/querying/querying.ts
Expand Up @@ -172,7 +172,7 @@ export default (Commands, Cypress, cy, state) => {
let $el

try {
let scope = userOptions.withinSubject || cy.getSubjectFromChain(withinSubject)
let scope = userOptions.withinSubject !== undefined ? userOptions.withinSubject : cy.getSubjectFromChain(withinSubject)

if (includeShadowDom) {
const root = scope?.get(0) || cy.state('document')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/errors/src/errors.ts
Expand Up @@ -1616,11 +1616,11 @@ export const AllCypressErrors = {
`
},

MIGRATION_MISMATCHED_CYPRESS_VERSIONS: (version: string) => {
MIGRATION_MISMATCHED_CYPRESS_VERSIONS: (version: string, currentVersion: string) => {
return errTemplate`
You are running Cypress version 10 in global mode, but you are attempting to migrate a project where ${fmt.cypressVersion(version)} is installed.
You are running ${fmt.cypressVersion(currentVersion)} in global mode, but you are attempting to migrate a project where ${fmt.cypressVersion(version)} is installed.
Ensure the project you are migrating has Cypress version 10 installed.
Ensure the project you are migrating has Cypress version ${fmt.cypressVersion(currentVersion)} installed.
https://on.cypress.io/migration-guide
`
Expand Down
2 changes: 1 addition & 1 deletion packages/errors/test/unit/visualSnapshotErrors_spec.ts
Expand Up @@ -1198,7 +1198,7 @@ describe('visual error templates', () => {
},
MIGRATION_MISMATCHED_CYPRESS_VERSIONS: () => {
return {
default: ['9.6.0'],
default: ['9.6.0', '10.0.0'],
}
},
MIGRATION_CYPRESS_NOT_FOUND: () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend-shared/src/locales/en-US.json
Expand Up @@ -706,7 +706,7 @@
"line4": "In the next screen, you'll be able to reconfigure component testing in a new guided configuration wizard."
},
"wizard": {
"title": "Migrating to Cypress 11",
"title": "Migrating to Cypress {version}",
"description": "Your project requires updates to work with this version.",
"typicalMigrationLabel": "Typical migration:",
"typicalMigrationTime": "5-10 minutes",
Expand Down
@@ -1,4 +1,5 @@
import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
import pkg from '../../../../package.json'

const expectStackToBe = (mode: 'open' | 'closed') => {
cy.get(`[data-cy="stack-open-${mode === 'open' ? 'true' : 'false'}"]`)
Expand Down Expand Up @@ -45,7 +46,7 @@ describe('Config files error handling', () => {
cy.visitLaunchpad()
cy.skipWelcome()

cy.get('body').should('contain.text', defaultMessages.migration.wizard.title)
cy.get('body').should('contain.text', defaultMessages.migration.wizard.title.replace('{version}', pkg.version.split('.')[0]))
cy.get('body').should('contain.text', defaultMessages.migration.wizard.description)
})

Expand Down
9 changes: 6 additions & 3 deletions packages/launchpad/cypress/e2e/migration.cy.ts
Expand Up @@ -86,8 +86,8 @@ describe('global mode', () => {
cy.addProject('migration-e2e-custom-integration-with-projectId')
cy.visitLaunchpad()

cy.withCtx((ctx, o) => {
o.sinon.stub(ctx.actions.migration, 'locallyInstalledCypressVersion').resolves('10.0.0')
cy.withCtx(async (ctx, o) => {
o.sinon.stub(ctx.actions.migration, 'locallyInstalledCypressVersion').resolves((await ctx.versions.versionData()).current.version)
})

cy.contains('button', cy.i18n.majorVersionWelcome.actionContinue).click()
Expand Down Expand Up @@ -168,7 +168,10 @@ describe('Opening unmigrated project', () => {

cy.contains('button', cy.i18n.majorVersionWelcome.actionContinue).click()
cy.contains(cy.i18n.majorVersionWelcome.title).should('not.exist')
cy.contains('h1', 'Migrating to Cypress 11').should('be.visible')
cy.contains('h1', `Migrating to Cypress ${Cypress.version.split('.')[0]}`).should('be.visible')

// Wait for migration prompt to load before taking a snapshot
cy.get('.spinner').should('not.exist')

cy.percySnapshot()
})
Expand Down
10 changes: 9 additions & 1 deletion packages/launchpad/src/migration/MigrationWizard.vue
@@ -1,7 +1,7 @@
<template>
<div class="pb-8px">
<h1 class="font-medium text-center pt-20px text-32px text-body-gray-900">
{{ t('migration.wizard.title') }}
{{ t('migration.wizard.title', { version: cypressMajorVersion }) }}
</h1>
<p
class="mx-42px mt-12px text-center text-body-gray-600 text-18px"
Expand Down Expand Up @@ -183,6 +183,12 @@ fragment MigrationBaseError on Query {
gql`
fragment MigrationWizardData on Query {
versions {
current {
id
version
}
}
migration {
filteredSteps {
id
Expand Down Expand Up @@ -404,4 +410,6 @@ const buttonTitle = computed(() => {
return t('migration.wizard.step1.button')
})
const cypressMajorVersion = computed(() => query.data.value?.versions?.current.version.split('.')[0] ?? '')
</script>
2 changes: 1 addition & 1 deletion packages/reporter/src/commands/command.tsx
Expand Up @@ -79,7 +79,7 @@ const shouldShowCount = (aliasesWithDuplicates: Array<Alias> | null, aliasName:
const NavColumns = observer(({ model, isPinned, toggleColumnPin }) => (
<>
<div className='command-number-column' onClick={toggleColumnPin}>
{model._isPending() && <RunningIcon className='fa-spin' />}
{model._isPending() && <RunningIcon data-cy="reporter-running-icon" className='fa-spin' />}
{(!model._isPending() && isPinned) && <PinIcon className='command-pin' />}
{(!model._isPending() && !isPinned) && model.number}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/cdp_automation.ts
Expand Up @@ -158,7 +158,7 @@ export class CdpAutomation {
onFn('Network.responseReceived', this.onResponseReceived)
}

async startVideoRecording (writeVideoFrame: WriteVideoFrame, screencastOpts?) {
async startVideoRecording (writeVideoFrame: WriteVideoFrame, screencastOpts) {
this.onFn('Page.screencastFrame', async (e) => {
writeVideoFrame(Buffer.from(e.data, 'base64'))
await this.sendDebuggerCommandFn('Page.screencastFrameAck', { sessionId: e.sessionId })
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/electron.ts
Expand Up @@ -112,7 +112,7 @@ function _installExtensions (win: BrowserWindow, extensionPaths: string[], optio
async function recordVideo (cdpAutomation: CdpAutomation, videoApi: RunModeVideoApi) {
const { writeVideoFrame } = await videoApi.useFfmpegVideoController()

await cdpAutomation.startVideoRecording(writeVideoFrame)
await cdpAutomation.startVideoRecording(writeVideoFrame, screencastOpts())
}

export = {
Expand Down
@@ -1,3 +1,4 @@
// Keep this test very simple as "@cypress/schematic" relies on it to run smoke tests
import { AppComponent } from './app.component'

it('should', () => {
Expand Down
@@ -1 +1 @@
<h1>Hello World your app is running!</h1>
<h1>Hello World your app is running!</h1>
@@ -1,3 +1,3 @@
h1 {
color: red
}
}
@@ -0,0 +1,6 @@
.test-img {
background-image: url("/assets/test.png");
background-size: contain;
height: 100px;
width: 100px;
}
@@ -0,0 +1,8 @@
import { Component } from '@angular/core'

@Component({
selector: 'app-url-image',
template: `<div class="test-img"></div>`,
styleUrls: ['./url-image.component.scss'],
})
export class UrlImageComponent {}

5 comments on commit 7f14a32

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7f14a32 Dec 16, 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 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/12.2.0/linux-arm64/feature/create-from-react-component-7f14a32c58f1f6566b5b0a975a71d9cf41111865/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7f14a32 Dec 16, 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 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/12.2.0/linux-x64/feature/create-from-react-component-7f14a32c58f1f6566b5b0a975a71d9cf41111865/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7f14a32 Dec 16, 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 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/12.2.0/darwin-arm64/feature/create-from-react-component-7f14a32c58f1f6566b5b0a975a71d9cf41111865/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7f14a32 Dec 16, 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 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/12.2.0/darwin-x64/feature/create-from-react-component-7f14a32c58f1f6566b5b0a975a71d9cf41111865/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7f14a32 Dec 16, 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 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/12.2.0/win32-x64/feature/create-from-react-component-7f14a32c58f1f6566b5b0a975a71d9cf41111865/cypress.tgz

Please sign in to comment.