Skip to content

Commit

Permalink
Merge branch 'feature-multidomain' into md-pr-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Apr 22, 2022
2 parents 0569c91 + ebaaf18 commit 5e71789
Show file tree
Hide file tree
Showing 117 changed files with 5,286 additions and 2,867 deletions.
4 changes: 2 additions & 2 deletions browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "101.0.4951.26",
"chrome:stable": "100.0.4896.88"
"chrome:beta": "101.0.4951.41",
"chrome:stable": "100.0.4896.127"
}
77 changes: 74 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ commands:
description: chrome channel to install
type: string
default: ''
experimentalSessionAndOrigin:
description: experimental flag to apply
type: boolean
default: false
steps:
- restore_cached_workspace
- when:
Expand All @@ -423,8 +427,13 @@ commands:
if [[ -v MAIN_RECORD_KEY ]]; then
# internal PR
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
yarn cypress:run --record --parallel --group 5x-driver-<<parameters.browser>> --browser <<parameters.browser>>
if <<parameters.experimentalSessionAndOrigin>>; then
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<<parameters.browser>>-experimentalSessionAndOrigin --browser <<parameters.browser>>
else
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
yarn cypress:run --record --parallel --group 5x-driver-<<parameters.browser>> --browser <<parameters.browser>>
fi
else
# external PR
TESTFILES=$(circleci tests glob "cypress/integration/**/*spec.*" | circleci tests split --total=$CIRCLE_NODE_TOTAL)
Expand All @@ -433,7 +442,11 @@ commands:
if [[ -z "$TESTFILES" ]]; then
echo "Empty list of test files"
fi
yarn cypress:run --browser <<parameters.browser>> --spec $TESTFILES
if <<parameters.experimentalSessionAndOrigin>>; then
yarn cypress:run-experimentalSessionAndOrigin --browser <<parameters.browser>> --spec $TESTFILES
else
yarn cypress:run --browser <<parameters.browser>> --spec $TESTFILES
fi
fi
working_directory: packages/driver
- verify-mocha-results
Expand Down Expand Up @@ -1294,6 +1307,44 @@ jobs:
- run-driver-integration-tests:
browser: electron

driver-integration-tests-chrome-experimentalSessionAndOrigin:
<<: *defaults
resource_class: medium
parallelism: 5
steps:
- run-driver-integration-tests:
browser: chrome
install-chrome-channel: stable
experimentalSessionAndOrigin: true

driver-integration-tests-chrome-beta-experimentalSessionAndOrigin:
<<: *defaults
resource_class: medium
parallelism: 5
steps:
- run-driver-integration-tests:
browser: chrome:beta
install-chrome-channel: beta
experimentalSessionAndOrigin: true

driver-integration-tests-firefox-experimentalSessionAndOrigin:
<<: *defaults
resource_class: medium
parallelism: 5
steps:
- run-driver-integration-tests:
browser: firefox
experimentalSessionAndOrigin: true

driver-integration-tests-electron-experimentalSessionAndOrigin:
<<: *defaults
resource_class: medium
parallelism: 5
steps:
- run-driver-integration-tests:
browser: electron
experimentalSessionAndOrigin: true

desktop-gui-integration-tests-7x:
<<: *defaults
parallelism: 7
Expand Down Expand Up @@ -2084,6 +2135,22 @@ linux-workflow: &linux-workflow
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-chrome-experimentalSessionAndOrigin:
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-chrome-beta-experimentalSessionAndOrigin:
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-firefox-experimentalSessionAndOrigin:
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-electron-experimentalSessionAndOrigin:
context: test-runner:cypress-record-key
requires:
- build
- runner-integration-tests-chrome:
context: [test-runner:cypress-record-key, test-runner:percy]
requires:
Expand Down Expand Up @@ -2180,6 +2247,10 @@ linux-workflow: &linux-workflow
- driver-integration-tests-chrome
- driver-integration-tests-chrome-beta
- driver-integration-tests-electron
- driver-integration-tests-firefox-experimentalSessionAndOrigin
- driver-integration-tests-chrome-experimentalSessionAndOrigin
- driver-integration-tests-chrome-beta-experimentalSessionAndOrigin
- driver-integration-tests-electron-experimentalSessionAndOrigin
- system-tests-non-root
- system-tests-firefox
- system-tests-electron
Expand Down
1 change: 1 addition & 0 deletions cli/__snapshots__/errors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exports['errors individual has the following errors 1'] = [
"childProcessKilled",
"failedDownload",
"failedUnzip",
"failedUnzipWindowsMaxPathLength",
"incompatibleHeadlessFlags",
"invalidCacheDirectory",
"invalidCypressEnv",
Expand Down
20 changes: 19 additions & 1 deletion cli/__snapshots__/unzip_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports['unzip error 1'] = `
exports['lib/tasks/unzip throws when cannot unzip 1'] = `
Error: The Cypress App could not be unzipped.
Search for an existing issue or open a GitHub issue at
Expand All @@ -15,3 +15,21 @@ Platform: darwin-x64 (Foo-OsVersion)
Cypress Version: 1.2.3
`

exports['lib/tasks/unzip throws max path length error when cannot unzip due to realpath ENOENT on windows 1'] = `
Error: The Cypress App could not be unzipped.
This is most likely because the maximum path length is being exceeded on your system.
Read here for solutions to this problem: https://on.cypress.io/win-max-path-length-error
----------
Error: failed
----------
Platform: win32-x64 (Foo-OsVersion)
Cypress Version: 1.2.3
`
8 changes: 8 additions & 0 deletions cli/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ const failedUnzip = {
solution: genericErrorSolution,
}

const failedUnzipWindowsMaxPathLength = {
description: 'The Cypress App could not be unzipped.',
solution: `This is most likely because the maximum path length is being exceeded on your system.
Read here for solutions to this problem: https://on.cypress.io/win-max-path-length-error`,
}

const missingApp = (binaryDir) => {
return {
description: `No version of Cypress is installed in: ${chalk.cyan(
Expand Down Expand Up @@ -404,6 +411,7 @@ module.exports = {
unexpected,
failedDownload,
failedUnzip,
failedUnzipWindowsMaxPathLength,
invalidCypressEnv,
invalidCacheDirectory,
CYPRESS_RUN_BINARY,
Expand Down
29 changes: 19 additions & 10 deletions cli/lib/tasks/unzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,26 +195,35 @@ const unzip = ({ zipFilePath, installDir, progress }) => {
})
}

const start = ({ zipFilePath, installDir, progress }) => {
function isMaybeWindowsMaxPathLengthError (err) {
return os.platform() === 'win32' && err.code === 'ENOENT' && err.syscall === 'realpath'
}

const start = async ({ zipFilePath, installDir, progress }) => {
la(is.unemptyString(installDir), 'missing installDir')
if (!progress) {
progress = { onProgress: () => {
return {}
} }
}

return fs.pathExists(installDir)
.then((exists) => {
if (exists) {
try {
const installDirExists = await fs.pathExists(installDir)

if (installDirExists) {
debug('removing existing unzipped binary', installDir)

return fs.removeAsync(installDir)
await fs.removeAsync(installDir)
}
})
.then(() => {
return unzip({ zipFilePath, installDir, progress })
})
.catch(throwFormErrorText(errors.failedUnzip))

await unzip({ zipFilePath, installDir, progress })
} catch (err) {
const errorTemplate = isMaybeWindowsMaxPathLengthError(err) ?
errors.failedUnzipWindowsMaxPathLength
: errors.failedUnzip

await throwFormErrorText(errorTemplate)(err)
}
}

module.exports = {
Expand Down
46 changes: 32 additions & 14 deletions cli/test/lib/tasks/unzip_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,44 @@ describe('lib/tasks/unzip', function () {

afterEach(function () {
stdout.restore()
})

it('throws when cannot unzip', async function () {
try {
await unzip.start({
zipFilePath: path.join('test', 'fixture', 'bad_example.zip'),
installDir,
})
} catch (err) {
logger.error(err)

// return fs.removeAsync(installationDir)
return snapshot(normalize(this.stdout.toString()))
}

throw new Error('should have failed')
})

it('throws when cannot unzip', function () {
const ctx = this
it('throws max path length error when cannot unzip due to realpath ENOENT on windows', async function () {
const err = new Error('failed')

return unzip
.start({
zipFilePath: path.join('test', 'fixture', 'bad_example.zip'),
installDir,
})
.then(() => {
throw new Error('should have failed')
})
.catch((err) => {
err.code = 'ENOENT'
err.syscall = 'realpath'

os.platform.returns('win32')
sinon.stub(fs, 'ensureDirAsync').rejects(err)

try {
await unzip.start({
zipFilePath: path.join('test', 'fixture', 'bad_example.zip'),
installDir,
})
} catch (err) {
logger.error(err)

snapshot('unzip error 1', normalize(ctx.stdout.toString()))
})
return snapshot(normalize(this.stdout.toString()))
}

throw new Error('should have failed')
})

it('can really unzip', function () {
Expand Down
13 changes: 9 additions & 4 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ declare namespace Cypress {
type PrevSubject = keyof PrevSubjectMap
type TestingType = 'e2e' | 'component'
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
interface JQueryWithSelector<TElement = HTMLElement> extends JQuery<TElement> {
selector?: string | null
}

interface PrevSubjectMap<O = unknown> {
optional: O
element: JQuery
element: JQueryWithSelector
document: Document
window: Window
}
Expand Down Expand Up @@ -454,16 +457,18 @@ declare namespace Cypress {
Commands: {
add<T extends keyof Chainable>(name: T, fn: CommandFn<T>): void
add<T extends keyof Chainable>(name: T, options: CommandOptions & {prevSubject: false}, fn: CommandFn<T>): void
add<T extends keyof Chainable, S = any>(name: T, options: CommandOptions & {prevSubject: true}, fn: CommandFnWithSubject<T, S>): void
add<T extends keyof Chainable, S extends PrevSubject>(
name: T, options: CommandOptions & { prevSubject: true | S | ['optional'] }, fn: CommandFnWithSubject<T, PrevSubjectMap[S]>,
name: T, options: CommandOptions & { prevSubject: S | ['optional'] }, fn: CommandFnWithSubject<T, PrevSubjectMap[S]>,
): void
add<T extends keyof Chainable, S extends PrevSubject>(
name: T, options: CommandOptions & { prevSubject: S[] }, fn: CommandFnWithSubject<T, PrevSubjectMap<void>[S]>,
): void
addAll<T extends keyof Chainable>(fns: CommandFns): void
addAll<T extends keyof Chainable>(options: CommandOptions & {prevSubject: false}, fns: CommandFns): void
addAll<T extends keyof Chainable, S = any>(options: CommandOptions & { prevSubject: true }, fns: CommandFnsWithSubject<S>): void
addAll<T extends keyof Chainable, S extends PrevSubject>(
options: CommandOptions & { prevSubject: true | S | ['optional'] }, fns: CommandFnsWithSubject<PrevSubjectMap[S]>,
options: CommandOptions & { prevSubject: S | ['optional'] }, fns: CommandFnsWithSubject<PrevSubjectMap[S]>,
): void
addAll<T extends keyof Chainable, S extends PrevSubject>(
options: CommandOptions & { prevSubject: S[] }, fns: CommandFnsWithSubject<PrevSubjectMap<void>[S]>,
Expand Down Expand Up @@ -2524,7 +2529,7 @@ declare namespace Cypress {
action: 'select' | 'drag-drop'
}

interface BlurOptions extends Loggable, Forceable { }
interface BlurOptions extends Loggable, Timeoutable, Forceable { }

interface CheckOptions extends Loggable, Timeoutable, ActionableOptions {
interval: number
Expand Down
Loading

0 comments on commit 5e71789

Please sign in to comment.