-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove dead code -- lives in data-context/src/sources/HtmlData…
…Source.ts now (#23542)
- Loading branch information
1 parent
f6eaad4
commit b08bc27
Showing
4 changed files
with
4 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,11 @@ | ||
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' | 'remoteStates' | '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) | ||
|
||
// Chrome plans to make document.domain immutable in Chrome 106, with the default value | ||
// of the Origin-Agent-Cluster header becoming 'true'. We explicitly disable this header | ||
// so that we can continue to support tests that visit multiple subdomains in a single spec. | ||
// https://github.com/cypress-io/cypress/issues/20147 | ||
res.setHeader('Origin-Agent-Cluster', '?0') | ||
|
||
return res.render(runnerPath, { | ||
base64Config, | ||
projectName: config.projectName, | ||
namespace: config.namespace, | ||
}) | ||
} | ||
import { getPathToDist } from '@packages/resolve-dist' | ||
|
||
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, remoteStates, 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 = remoteStates.getPrimary() | ||
} | ||
|
||
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 | ||
// coerce type to allow string to be cast to BrowserFamily | ||
config.browser = getCurrentBrowser() as Cypress.Browser | ||
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 (testingType, req: Request, res: Response) { | ||
handle (req: Request, res: Response) { | ||
const pathToFile = getPathToDist('runner', req.params[0]) | ||
|
||
return send(req, pathToFile) | ||
.pipe(res) | ||
return send(req, pathToFile).pipe(res) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
b08bc27
There was a problem hiding this comment.
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:
b08bc27
There was a problem hiding this comment.
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:
b08bc27
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
b08bc27
There was a problem hiding this comment.
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:
b08bc27
There was a problem hiding this comment.
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: