Skip to content

Commit

Permalink
Merge branch 'develop' into jordanpowell88/angular-mount-ngOnChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanpowell88 authored Oct 3, 2022
2 parents 045f59e + 0976034 commit f093cbe
Show file tree
Hide file tree
Showing 70 changed files with 9,480 additions and 417 deletions.
14 changes: 14 additions & 0 deletions npm/cypress-schematic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [@cypress/schematic-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/schematic-v2.0.3...@cypress/schematic-v2.1.0) (2022-10-03)


### Bug Fixes

* angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4))
* Detect user-configured browsers ([#23446](https://github.com/cypress-io/cypress/issues/23446)) ([a75d3ec](https://github.com/cypress-io/cypress/commit/a75d3ec81f3405db6721a89875d89cdca0109013))


### Features

* _addQuery() ([#23665](https://github.com/cypress-io/cypress/issues/23665)) ([41fc535](https://github.com/cypress-io/cypress/commit/41fc535dca51cda4e40b5d9fc827d8bff534f3d1))
* **cypress/schematic:** add support for component testing ([#23385](https://github.com/cypress-io/cypress/issues/23385)) ([99562af](https://github.com/cypress-io/cypress/commit/99562af65a10abb0fab211fd97b13f98e2b0f959))

# [@cypress/schematic-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/schematic-v2.0.3...@cypress/schematic-v2.1.0) (2022-10-01)


Expand Down
7 changes: 7 additions & 0 deletions npm/mount-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/mount-utils-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v2.0.1...@cypress/mount-utils-v2.1.0) (2022-10-03)


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))

# [@cypress/mount-utils-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v2.0.1...@cypress/mount-utils-v2.1.0) (2022-10-01)


Expand Down
7 changes: 7 additions & 0 deletions npm/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-10-03)


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))

# [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-10-01)


Expand Down
12 changes: 12 additions & 0 deletions npm/react18/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [@cypress/react18-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/react18-v1.0.1...@cypress/react18-v1.1.0) (2022-10-03)


### Bug Fixes

* cypress/react18 rerender ([#23360](https://github.com/cypress-io/cypress/issues/23360)) ([8b8f20e](https://github.com/cypress-io/cypress/commit/8b8f20eec77d4c0a704aee7f7077dc92dbafb93f))


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))

# [@cypress/react18-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/react18-v1.0.1...@cypress/react18-v1.1.0) (2022-10-01)


Expand Down
13 changes: 13 additions & 0 deletions npm/vue/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# [@cypress/vue-v4.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vue-v4.1.0...@cypress/vue-v4.2.0) (2022-10-03)


### Bug Fixes

* fix regression in npm/vue ([#23954](https://github.com/cypress-io/cypress/issues/23954)) ([78779a2](https://github.com/cypress-io/cypress/commit/78779a2db13ca6555a6b830dbabeefd3d37bbfe5))
* **npm/vue:** update types ([#23890](https://github.com/cypress-io/cypress/issues/23890)) ([eb8ae02](https://github.com/cypress-io/cypress/commit/eb8ae02b61304d034136f7627da1ab23537e3ba4))


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))

# [@cypress/vue-v4.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vue-v4.1.0...@cypress/vue-v4.2.0) (2022-10-01)


Expand Down
7 changes: 7 additions & 0 deletions npm/vue2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-03)


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))

# [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-01)


Expand Down
17 changes: 17 additions & 0 deletions npm/webpack-dev-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# [@cypress/webpack-dev-server-v2.3.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v2.2.0...@cypress/webpack-dev-server-v2.3.0) (2022-10-03)


### Bug Fixes

* allow asynchronous vue cli init phase ([#23936](https://github.com/cypress-io/cypress/issues/23936)) ([6a40936](https://github.com/cypress-io/cypress/commit/6a40936604ae24b0b40996692c4a03e5a3c1c9a2))
* force Webpack to emit assets on error ([#23844](https://github.com/cypress-io/cypress/issues/23844)) ([466be9f](https://github.com/cypress-io/cypress/commit/466be9f1f0cbb843684361a9900832814353e3c0))
* support type: module in Node.js 16.17.0+ and 18.6.0+ ([#23637](https://github.com/cypress-io/cypress/issues/23637)) ([b6dad0a](https://github.com/cypress-io/cypress/commit/b6dad0a674279936a9816939963bbf129647cee7))
* **webpack-dev-server:** add custom project config to handler ([a07a2a1](https://github.com/cypress-io/cypress/commit/a07a2a118d7b62b90e790ef475c86959ae894b3b))


### Features

* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
* allow vite/webpack config to be an async function ([#23605](https://github.com/cypress-io/cypress/issues/23605)) ([4c647f6](https://github.com/cypress-io/cypress/commit/4c647f6d5b0f58a797b50436e63c645418bc07ac))
* CT stack traces ([#23916](https://github.com/cypress-io/cypress/issues/23916)) ([bf590eb](https://github.com/cypress-io/cypress/commit/bf590eba3f1cf46b04f6a1252e51da5c5a3dc7c2))

# [@cypress/webpack-dev-server-v2.3.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v2.2.0...@cypress/webpack-dev-server-v2.3.0) (2022-10-01)


Expand Down
2 changes: 1 addition & 1 deletion npm/webpack-dev-server/cypress/e2e/angular.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="../support/e2e.ts" />
import type { ProjectFixtureDir } from '@tooling/system-tests/lib/fixtureDirs'

const WEBPACK_REACT: ProjectFixtureDir[] = ['angular-13', 'angular-14']
const WEBPACK_REACT: ProjectFixtureDir[] = ['angular-13', 'angular-14', 'angular-15']

// Add to this list to focus on a particular permutation
const ONLY_PROJECTS: ProjectFixtureDir[] = []
Expand Down
12 changes: 9 additions & 3 deletions npm/webpack-dev-server/src/helpers/angularHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ export async function generateTsConfig (devServerConfig: AngularWebpackDevServer
}

if (buildOptions.polyfills) {
const polyfills = getProjectFilePath(buildOptions.polyfills)
const polyfills = Array.isArray(buildOptions.polyfills)
? buildOptions.polyfills.filter((p: string) => devServerConfig.options?.projectConfig.sourceRoot && p.startsWith(devServerConfig.options?.projectConfig.sourceRoot))
: [buildOptions.polyfills]

includePaths.push(polyfills)
includePaths.push(...polyfills.map((p: string) => getProjectFilePath(p)))
}

const cypressTypes = getProjectFilePath('node_modules', 'cypress', 'types', 'index.d.ts')
Expand Down Expand Up @@ -202,7 +204,11 @@ export async function getAngularJson (projectRoot: string): Promise<AngularJson>

function createFakeContext (projectRoot: string, defaultProjectConfig: Cypress.AngularDevServerProjectConfig) {
const logger = {
createChild: () => ({}),
createChild: () => {
return {
warn: () => {},
}
},
}

const context = {
Expand Down
27 changes: 27 additions & 0 deletions npm/webpack-dev-server/test/handlers/angularHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,33 @@ describe('angularHandler', function () {
expectLoadsAngularBuildOptions(buildOptions)
})

it('sources the config from angular-15', async () => {
const projectRoot = await scaffoldMigrationProject('angular-15')

process.chdir(projectRoot)

const devServerConfig = {
cypressConfig: {
projectRoot,
specPattern: 'src/**/*.cy.ts',
} as Cypress.PluginConfigOptions,
framework: 'angular',
} as AngularWebpackDevServerConfig

const { frameworkConfig: webpackConfig, sourceWebpackModulesResult } = await angularHandler(devServerConfig)

expect(webpackConfig).to.exist
expect((webpackConfig?.entry as any).main).to.be.undefined
expect(sourceWebpackModulesResult.framework?.importPath).to.include(path.join('@angular-devkit', 'build-angular'))

const { buildOptions } = await expectNormalizeProjectConfig(projectRoot)

await expectLoadsAngularJson(projectRoot)
await expectLoadsAngularCLiModules(projectRoot)
await expectGeneratesTsConfig(devServerConfig, buildOptions)
expectLoadsAngularBuildOptions(buildOptions)
})

it('allows custom project config', async () => {
const customProjectConfig = {
root: '',
Expand Down
9 changes: 5 additions & 4 deletions packages/app/src/runner/aut-iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class AutIframe {
* Otherwise, if top and the AUT match origins, the method returns true.
* If the AUT origin is "about://blank", that means the src attribute has been stripped off the iframe and is adhering to same origin policy
*/
doesAUTMatchTopOriginPolicy = () => {
doesAUTMatchTopSuperDomainOrigin = () => {
const Cypress = this.eventManager.getCypress()

if (!Cypress) return true
Expand All @@ -107,7 +107,7 @@ export class AutIframe {
const locationTop = Cypress.Location.create(window.location.href)
const locationAUT = Cypress.Location.create(currentHref)

return locationTop.originPolicy === locationAUT.originPolicy || locationAUT.originPolicy === 'about://blank'
return locationTop.superDomainOrigin === locationAUT.superDomainOrigin || locationAUT.superDomainOrigin === 'about://blank'
} catch (err) {
if (err.name === 'SecurityError') {
return false
Expand Down Expand Up @@ -151,7 +151,7 @@ export class AutIframe {
}

restoreDom = (snapshot) => {
if (!this.doesAUTMatchTopOriginPolicy()) {
if (!this.doesAUTMatchTopSuperDomainOrigin()) {
/**
* A load event fires here when the src is removed (as does an unload event).
* This is equivalent to loading about:blank (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-src).
Expand All @@ -162,7 +162,8 @@ export class AutIframe {
this.restoreDom(snapshot)
})

// The iframe is in a cross origin state. Remove the src attribute to adhere to same origin policy. NOTE: This should only be done ONCE.
// The iframe is in a cross origin state.
// Remove the src attribute to adhere to same super domain origin policy so we can interact with the frame. NOTE: This should only be done ONCE.
this.removeSrcAttribute()

return
Expand Down
20 changes: 10 additions & 10 deletions packages/app/src/runner/event-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ export class EventManager {
})

// Reflect back to the requesting origin the status of the 'duringUserTestExecution' state
Cypress.primaryOriginCommunicator.on('sync:during:user:test:execution', ({ specBridgeResponseEvent }, originPolicy) => {
Cypress.primaryOriginCommunicator.toSpecBridge(originPolicy, specBridgeResponseEvent, cy.state('duringUserTestExecution'))
Cypress.primaryOriginCommunicator.on('sync:during:user:test:execution', ({ specBridgeResponseEvent }, superDomainOrigin) => {
Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, specBridgeResponseEvent, cy.state('duringUserTestExecution'))
})

Cypress.on('request:snapshot:from:spec:bridge', ({ log, name, options, specBridge, addSnapshot }: {
Expand Down Expand Up @@ -653,22 +653,22 @@ export class EventManager {
Cypress.primaryOriginCommunicator.toAllSpecBridges('before:unload', origin)
})

Cypress.primaryOriginCommunicator.on('expect:origin', (originPolicy) => {
this.localBus.emit('expect:origin', originPolicy)
Cypress.primaryOriginCommunicator.on('expect:origin', (superDomainOrigin) => {
this.localBus.emit('expect:origin', superDomainOrigin)
})

Cypress.primaryOriginCommunicator.on('viewport:changed', (viewport, originPolicy) => {
Cypress.primaryOriginCommunicator.on('viewport:changed', (viewport, superDomainOrigin) => {
const callback = () => {
Cypress.primaryOriginCommunicator.toSpecBridge(originPolicy, 'viewport:changed:end')
Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, 'viewport:changed:end')
}

Cypress.primaryOriginCommunicator.emit('sync:viewport', viewport)
this.localBus.emit('viewport:changed', viewport, callback)
})

Cypress.primaryOriginCommunicator.on('before:screenshot', (config, originPolicy) => {
Cypress.primaryOriginCommunicator.on('before:screenshot', (config, superDomainOrigin) => {
const callback = () => {
Cypress.primaryOriginCommunicator.toSpecBridge(originPolicy, 'before:screenshot:end')
Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, 'before:screenshot:end')
}

handleBeforeScreenshot(config, callback)
Expand Down Expand Up @@ -861,9 +861,9 @@ export class EventManager {
this.ws.emit('spec:changed', specFile)
}

notifyCrossOriginBridgeReady (originPolicy) {
notifyCrossOriginBridgeReady (superDomainOrigin) {
// Any multi-origin event appends the origin as the third parameter and we do the same here for this short circuit
Cypress.primaryOriginCommunicator.emit('bridge:ready', undefined, originPolicy)
Cypress.primaryOriginCommunicator.emit('bridge:ready', undefined, superDomainOrigin)
}

snapshotUnpinned () {
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function createIframeModel () {
autIframe.detachDom,
autIframe.restoreDom,
autIframe.highlightEl,
autIframe.doesAUTMatchTopOriginPolicy,
autIframe.doesAUTMatchTopSuperDomainOrigin,
getEventManager(),
{
selectorPlaygroundModel: getEventManager().selectorPlaygroundModel,
Expand Down Expand Up @@ -194,11 +194,11 @@ export async function teardown () {
* Add a cross origin iframe for cy.origin support
*/
export function addCrossOriginIframe (location) {
const id = `Spec Bridge: ${location.originPolicy}`
const id = `Spec Bridge: ${location.superDomainOrigin}`

// if it already exists, don't add another one
if (document.getElementById(id)) {
getEventManager().notifyCrossOriginBridgeReady(location.originPolicy)
getEventManager().notifyCrossOriginBridgeReady(location.superDomainOrigin)

return
}
Expand All @@ -209,7 +209,7 @@ export function addCrossOriginIframe (location) {
// container since it needs to match the size of the top window for screenshots
$container: document.body,
className: 'spec-bridge-iframe',
src: `${location.originPolicy}/${getRunnerConfigFromWindow().namespace}/spec-bridge-iframes`,
src: `${location.superDomainOrigin}/${getRunnerConfigFromWindow().namespace}/spec-bridge-iframes`,
})
}

Expand Down
4 changes: 2 additions & 2 deletions packages/driver/cypress/e2e/commands/location.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe('src/cy/commands/location', () => {
context('#location', () => {
it('returns the location object', () => {
cy.location().then((loc) => {
expect(loc).to.have.keys(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'originPolicy', 'superDomain', 'toString'])
expect(loc).to.have.keys(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'pathname', 'port', 'protocol', 'search', 'origin', 'superDomainOrigin', 'superDomain', 'toString'])
})
})

Expand Down Expand Up @@ -529,7 +529,7 @@ describe('src/cy/commands/location', () => {

expect(_.keys(consoleProps)).to.deep.eq(['Command', 'Yielded'])
expect(consoleProps.Command).to.eq('location')
expect(_.keys(consoleProps.Yielded)).to.deep.eq(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'originPolicy', 'superDomain', 'toString'])
expect(_.keys(consoleProps.Yielded)).to.deep.eq(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'superDomainOrigin', 'superDomain', 'toString'])
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/cypress/e2e/commands/navigation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ describe('src/cy/commands/navigation', () => {
})
}

it('can visit pages on the same originPolicy', () => {
it('can visit pages on the same origin', () => {
cy
.visit('http://localhost:3500/fixtures/jquery.html')
.visit('http://localhost:3500/fixtures/generic.html')
Expand Down Expand Up @@ -690,7 +690,7 @@ describe('src/cy/commands/navigation', () => {
})
})

it('can visit relative pages on the same originPolicy', () => {
it('can visit relative pages on the same origin', () => {
// as long as we are already on the localhost:3500
// domain this will work
cy
Expand Down
Loading

0 comments on commit f093cbe

Please sign in to comment.