mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-13 02:30:09 -06:00
* start graphql server in run mode * update url logic * use correct mobx instance * expose util method for testing selector playground * add __Cypress__ global * correctly order aut lifecycle methods * correct spec url in tests * fix server integration tests * add title to html * update url encoding * uni test * encoding * encode ssr data as base64 * set correct cypress.spec.name * set arch and os options * add version to options * update config test * update encoding * temp skip * more skips * try to fix launchpad tests * update test * update runner * feat: automation * ignore error * remove unused runner steps * try remove error * config * Ensuring a provided testId gets rendered on a consistent element reference within HeaderBar. * better conditionals * automation connection * try applying firefox cdp automation * skip spec * skip for now * skips * respond to failed visit event correctly * chore: fix screenshot system tests (#19686) * set fake __CYPRESS_MODE__ on window * vue logic for screenshot + run-mode checks * Restore AUT wrapper div, make the name more clear * switch to await for `before:screenshot` event send * remove skipped tests * add CYPRESS_INTERNAL_MODE to env * move logic into component Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> * do not run runner-shared tests anymore * dont care about runner unit test * add reference screenshots confirmed to be good * fix rerun spec * do not hardcode http protocol, remove old code * revert protocol and add missing pre-fetch gql query * correctly pass ssr data, update request policy * automation element updates * do not apply CDP automation for firefox * make assertions more debug-friendly * up timeout, make firefox pixels slightly looser on CI * Fix TS * Try to fix tests * Try to fix tests * do not require urql for run mode * wip: request policy changes * use separate component for run mode and open mode * expose selector playground function globally for testing purposes * fix typescript * fixing unit tests * encode ssr data to match production * fix test * fix test * readme * fix: Run mode for unified runner resolve conflicts (#19743) * merge in 10.0-release * Fix merge conflict with client route * Fail earlier when trying to run cypress in cypress in a browser other than chrome * Fix some tests * Set empty obj if config is not set * Update tests Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: Ryan Manuel <ryanm@cypress.io> * update automation namespace, remove old code * remove skipped test * handle non proxied case * clean up code * revert png * do not start graphql server in run mode * Fix ts error * revert type.cy.js to original test * revert change in driver screenshot * remove unused async * remove unused env var * remove old todo comment * remove needless console.log * unskip test * use pause: true to avoid gql request * remove unused automation element * remove unused setAutomationStatus method * change pane -> panel * reimplement 1px flake fix for firefox type.cy.js * chore: remove launchpad environment variable (#19778) * remove LAUNCHPAD conditionals * add timeout to test * revert file * correctly normalize url Co-authored-by: Tyler Biethman <tbiethman@gmail.com> Co-authored-by: Mark Noonan <oddlyaromatic@gmail.com> Co-authored-by: Mark Noonan <mark@cypress.io> Co-authored-by: Alejandro Estrada <estrada9166@gmail.com> Co-authored-by: estrada9166 <estrada9166@hotmail.com> Co-authored-by: Ryan Manuel <ryanm@cypress.io>
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
import _ from 'lodash'
|
|
import type { Request, Response } from 'express'
|
|
import send from 'send'
|
|
import os from 'os'
|
|
import { fs } from '../util/fs'
|
|
import path from 'path'
|
|
import Debug from 'debug'
|
|
import pkg from '@packages/root'
|
|
import { getPathToDist, getPathToIndex, RunnerPkg } from '@packages/resolve-dist'
|
|
import type { InitializeRoutes } from '../routes'
|
|
import type { PlatformName } from '@packages/types'
|
|
import type { Cfg } from '../project-base'
|
|
|
|
const debug = Debug('cypress:server:runner')
|
|
|
|
const PATH_TO_NON_PROXIED_ERROR = path.join(__dirname, '..', 'html', 'non_proxied_error.html')
|
|
|
|
const _serveNonProxiedError = (res: Response) => {
|
|
return fs.readFile(PATH_TO_NON_PROXIED_ERROR)
|
|
.then((html) => {
|
|
return res.type('html').end(html)
|
|
})
|
|
}
|
|
|
|
export interface ServeOptions extends Pick<InitializeRoutes, 'getSpec' | 'config' | 'getCurrentBrowser' | 'getRemoteState' | 'exit'> {
|
|
testingType: Cypress.TestingType
|
|
}
|
|
|
|
export const serveRunner = (runnerPkg: RunnerPkg, config: Cfg, res: Response) => {
|
|
// base64 before embedding so user-supplied contents can't break out of <script>
|
|
// https://github.com/cypress-io/cypress/issues/4952
|
|
const base64Config = Buffer.from(JSON.stringify(config)).toString('base64')
|
|
|
|
const runnerPath = process.env.CYPRESS_INTERNAL_RUNNER_PATH || getPathToIndex(runnerPkg)
|
|
|
|
return res.render(runnerPath, {
|
|
base64Config,
|
|
projectName: config.projectName,
|
|
namespace: config.namespace,
|
|
})
|
|
}
|
|
|
|
export const runner = {
|
|
serve (req, res, runnerPkg: RunnerPkg, options: ServeOptions) {
|
|
if (req.proxiedUrl.startsWith('/')) {
|
|
debug('request was not proxied via Cypress, erroring %o', _.pick(req, 'proxiedUrl'))
|
|
|
|
return _serveNonProxiedError(res)
|
|
}
|
|
|
|
let { config, getRemoteState, getCurrentBrowser, getSpec, exit } = options
|
|
|
|
config = _.clone(config)
|
|
// at any given point, rather than just arbitrarily modifying it.
|
|
// @ts-ignore
|
|
config.testingType = options.testingType
|
|
|
|
// TODO #1: bug. Passing `remote.domainName` breaks CT for unknown reasons.
|
|
// If you pass a remote object with a domainName key, we get cross-origin
|
|
// iframe access errors.
|
|
// repro:
|
|
// {
|
|
// "domainName": "localhost"
|
|
// }
|
|
// TODO: Find out what the problem.
|
|
if (options.testingType === 'e2e') {
|
|
config.remote = getRemoteState()
|
|
}
|
|
|
|
const spec = getSpec()
|
|
|
|
config.version = pkg.version
|
|
config.platform = os.platform() as PlatformName
|
|
config.arch = os.arch()
|
|
config.spec = spec ? { ...spec, name: spec.baseName } : null
|
|
config.browser = getCurrentBrowser()
|
|
config.exit = exit ?? true
|
|
|
|
debug('serving runner index.html with config %o',
|
|
_.pick(config, 'version', 'platform', 'arch', 'projectName'))
|
|
|
|
// log the env object's keys without values to avoid leaking sensitive info
|
|
debug('env object has the following keys: %s', _.keys(config.env).join(', '))
|
|
|
|
return serveRunner(runnerPkg, config, res)
|
|
},
|
|
|
|
handle (req: Request, res: Response) {
|
|
const pathToFile = getPathToDist('runner-ct', req.params[0])
|
|
|
|
return send(req, pathToFile)
|
|
.pipe(res)
|
|
},
|
|
}
|