Skip to content

Commit

Permalink
chore: change ct -> component, projectType -> testingType everywhere …
Browse files Browse the repository at this point in the history
…for consistency (#17461)

Co-authored-by: Barthélémy Ledoux <[email protected]>
  • Loading branch information
lmiller1990 and Barthélémy Ledoux authored Jul 26, 2021
1 parent faf1d58 commit 257ff95
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 83 deletions.
6 changes: 3 additions & 3 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2717,13 +2717,13 @@ declare namespace Cypress {
* Override default config options for Component Testing runner.
* @default {}
*/
component: Omit<ResolvedConfigOptions, 'e2e' | 'component'>
component: Omit<ResolvedConfigOptions, TestingType>

/**
* Override default config options for E2E Testing runner.
* @default {}
*/
e2e: Omit<ResolvedConfigOptions, 'e2e' | 'component'>
e2e: Omit<ResolvedConfigOptions, TestingType>
}

/**
Expand Down Expand Up @@ -2809,7 +2809,7 @@ declare namespace Cypress {
/**
* All configuration items are optional.
*/
type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, 'e2e' | 'component'>>
type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, TestingType>>
type ConfigOptions = CoreConfigOptions & {e2e?: CoreConfigOptions, component?: CoreConfigOptions }

interface PluginConfigOptions extends ResolvedConfigOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/runner-ct/src/app/SpecContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const SpecContent = namedObserver('SpecContent', (props: SpecContentProps
},
)}
>
<Header {...props} runner='ct' />
<Header {...props} runner='component' />
{props.state.spec
? <Iframes {...props} />
: (
Expand Down
2 changes: 1 addition & 1 deletion packages/runner-ct/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Runner = {
const container = (
<Container
config={config}
runner='ct'
runner='component'
state={state}
App={App}
hasSpecFile={util.hasSpecFile}
Expand Down
4 changes: 2 additions & 2 deletions packages/runner-shared/src/container/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export class Container extends Component {
: this._noSpec()
}

if (this.props.runner === 'ct') {
if (this.props.runner === 'component') {
return this._app()
}

throw Error(`runner prop is required and must be 'e2e' or 'ct'. You passed: ${this.props.runner}.`)
throw Error(`runner prop is required and must be 'e2e' or 'component'. You passed: ${this.props.runner}.`)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/runner-shared/src/event-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export const eventManager = {
rerun()
})

ws.on('specs:changed', ({ specs, projectType }) => {
ws.on('specs:changed', ({ specs, testingType }) => {
// do not emit the event if e2e runner is not displaying an inline spec list.
if (projectType === 'e2e' && state.useInlineSpecList === false) {
if (testingType === 'e2e' && state.useInlineSpecList === false) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions packages/runner-shared/src/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface BaseState {
}

interface StateCT {
runner: 'ct'
runner: 'component'
state: {
screenshotting: boolean
} & BaseState
Expand Down Expand Up @@ -117,7 +117,7 @@ export class Header extends Component<HeaderProps> {
className={cs({
'showing-selector-playground': selectorPlaygroundModel.isOpen,
'showing-studio': studioRecorder.isOpen,
'display-none': this.props.runner === 'ct' && this.props.state.screenshotting,
'display-none': this.props.runner === 'component' && this.props.state.screenshotting,
})}
>
<div className='sel-url-wrap'>
Expand Down
2 changes: 1 addition & 1 deletion packages/server-ct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const registerCheckForUpdates = () => {
const checkForUpdates = (initialLaunch) => {
Updater.check({
initialLaunch,
testingType: 'ct',
testingType: 'component',
onNewVersion: _.noop,
onNoNewVersion: _.noop,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/server-ct/src/server-ct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type WarningErr = Record<string, any>

export class ServerCt extends ServerBase<SocketCt> {
open (config: Cfg, options: OpenServerOptions) {
return super.open(config, { ...options, projectType: 'ct' })
return super.open(config, { ...options, testingType: 'component' })
}

createServer (app, config, onWarning): Bluebird<[number, WarningErr?]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/server-ct/test/unit/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('index.spec', () => {
expect(stub_setInterval.firstCall.args[1]).eq(1000 * 60 * 60)
expect(Updater.check.callCount).eq(1)
expect(Updater.check.firstCall.args[0]).includes({
testingType: 'ct',
testingType: 'component',
initialLaunch: true,
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/open_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ const moduleFactory = () => {

// store the currently open project
openProject = new Project.ProjectBase({
projectType: args.testingType === 'component' ? 'ct' : 'e2e',
testingType: args.testingType === 'component' ? 'component' : 'e2e',
projectRoot: path,
options: {
...options,
Expand Down
44 changes: 22 additions & 22 deletions packages/server/lib/project-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import specsUtil from './util/specs'
import Watchers from './watchers'
import devServer from './plugins/dev-server'
import preprocessor from './plugins/preprocessor'
import { RunnerType, SpecsStore } from './specs-store'
import { SpecsStore } from './specs-store'
import { createRoutes as createE2ERoutes } from './routes'
import { createRoutes as createCTRoutes } from '@packages/server-ct/src/routes-ct'
import { checkSupportFile } from './project_utils'
Expand Down Expand Up @@ -83,18 +83,18 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
private _recordTests?: any = null

public browser: any
public projectType: RunnerType
public testingType: Cypress.TestingType
public spec: Cypress.Cypress['spec'] | null
private generatedProjectIdTimestamp: any
projectRoot: string

constructor ({
projectRoot,
projectType,
testingType,
options,
}: {
projectRoot: string
projectType: RunnerType
testingType: Cypress.TestingType
options: Options
}) {
super()
Expand All @@ -107,14 +107,14 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
throw new Error(`Expected project root path, not ${projectRoot}`)
}

this.projectType = projectType
this.testingType = testingType
this.projectRoot = path.resolve(projectRoot)
this.watchers = new Watchers()
this.spec = null
this.browser = null

debug('Project created %o', {
projectType: this.projectType,
testingType: this.testingType,
projectRoot: this.projectRoot,
})

Expand Down Expand Up @@ -168,8 +168,8 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
}
}

createServer (projectType: RunnerType) {
return projectType === 'e2e'
createServer (testingType: Cypress.TestingType) {
return testingType === 'e2e'
? new ServerE2E() as TServer
: new ServerCt() as TServer
}
Expand All @@ -192,7 +192,7 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
await scaffold.plugins(path.dirname(cfg.pluginsFile), cfg)
}

this._server = this.createServer(this.projectType)
this._server = this.createServer(this.testingType)

cfg = await this.initializePlugins(cfg, this.options)

Expand All @@ -202,7 +202,7 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
ctDevServerPort,
} = await this.initializeSpecStore(cfg)

if (this.projectType === 'ct') {
if (this.testingType === 'component') {
cfg.baseUrl = `http://localhost:${ctDevServerPort}`
}

Expand All @@ -212,9 +212,9 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
onError: this.options.onError,
onWarning: this.options.onWarning,
shouldCorrelatePreRequests: this.shouldCorrelatePreRequests,
projectType: this.projectType as 'ct' | 'e2e',
SocketCtor: this.projectType === 'e2e' ? SocketE2E : SocketCt,
createRoutes: this.projectType === 'e2e' ? createE2ERoutes : createCTRoutes,
testingType: this.testingType,
SocketCtor: this.testingType === 'e2e' ? SocketE2E : SocketCt,
createRoutes: this.testingType === 'e2e' ? createE2ERoutes : createCTRoutes,
specsStore,
})

Expand Down Expand Up @@ -333,7 +333,7 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
this.spec = null
this.browser = null

const closePreprocessor = (this.projectType === 'e2e' && preprocessor.close) ?? undefined
const closePreprocessor = (this.testingType === 'e2e' && preprocessor.close) ?? undefined

await Promise.all([
this.server?.close(),
Expand Down Expand Up @@ -365,15 +365,15 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
}> {
const allSpecs = await specsUtil.find(updatedConfig)
const specs = allSpecs.filter((spec: Cypress.Cypress['spec']) => {
if (this.projectType === 'ct') {
if (this.testingType === 'component') {
return spec.specType === 'component'
}

if (this.projectType === 'e2e') {
if (this.testingType === 'e2e') {
return spec.specType === 'integration'
}

throw Error(`Cannot return specType for projectType: ${this.projectType}`)
throw Error(`Cannot return specType for testingType: ${this.testingType}`)
})

return this.initSpecStore({ specs, config: updatedConfig })
Expand Down Expand Up @@ -422,16 +422,16 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
specs: Cypress.Cypress['spec'][]
config: any
}) {
const specsStore = new SpecsStore(config, this.projectType as RunnerType)
const specsStore = new SpecsStore(config, this.testingType)

const startSpecWatcher = () => {
return specsStore.watch({
onSpecsChanged: (specs) => {
// both e2e and CT watch the specs and send them to the
// client to be shown in the SpecList.
this.server.sendSpecList(specs, this.projectType as RunnerType)
this.server.sendSpecList(specs, this.testingType)

if (this.projectType === 'ct') {
if (this.testingType === 'component') {
// ct uses the dev-server to build and bundle the speces.
// send new files to dev server
devServer.updateSpecs(specs)
Expand All @@ -442,7 +442,7 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {

let ctDevServerPort: number | undefined

if (this.projectType === 'ct') {
if (this.testingType === 'component') {
const { port } = await this.startCtDevServer(specs, config)

ctDevServerPort = port
Expand Down Expand Up @@ -677,7 +677,7 @@ export class ProjectBase<TServer extends ServerE2E | ServerCt> extends EE {
})
}

theCfg = this.projectType === 'e2e'
theCfg = this.testingType === 'e2e'
? theCfg
: this.injectCtSpecificConfig(theCfg)

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/project_static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function add (path, options) {
}

export function getId (path) {
return new ProjectBase({ projectRoot: path, projectType: 'e2e', options: {} }).getProjectId()
return new ProjectBase({ projectRoot: path, testingType: 'e2e', options: {} }).getProjectId()
}

export function ensureExists (path, options) {
Expand Down
14 changes: 7 additions & 7 deletions packages/server/lib/server-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import origin from './util/origin'
import { allowDestroy, DestroyableHttpServer } from './util/server_destroy'
import { SocketAllowed } from './util/socket_allowed'
import { createInitialWorkers } from '@packages/rewriter'
import { RunnerType, SpecsStore } from './specs-store'
import { SpecsStore } from './specs-store'
import { InitializeRoutes } from '../../server-ct/src/routes-ct'
import { Cfg } from './project-base'
import { Browser } from '@packages/server/lib/browsers/types'
Expand Down Expand Up @@ -94,7 +94,7 @@ export type WarningErr = Record<string, any>
export interface OpenServerOptions {
SocketCtor: typeof SocketE2E | typeof SocketCt
specsStore: SpecsStore
projectType: 'ct' | 'e2e'
testingType: Cypress.TestingType
onError: any
onWarning: any
getCurrentBrowser: () => Browser
Expand Down Expand Up @@ -175,15 +175,15 @@ export abstract class ServerBase<TSocket extends SocketE2E | SocketCt> {
shouldCorrelatePreRequests,
specsStore,
createRoutes,
projectType,
testingType,
SocketCtor,
}: OpenServerOptions) {
debug('server open')

la(_.isPlainObject(config), 'expected plain config object', config)

return Bluebird.try(() => {
if (!config.baseUrl && projectType === 'ct') {
if (!config.baseUrl && testingType === 'component') {
throw new Error('ServerCt#open called without config.baseUrl.')
}

Expand All @@ -192,7 +192,7 @@ export abstract class ServerBase<TSocket extends SocketE2E | SocketCt> {
logger.setSettings(config)

this._nodeProxy = httpProxy.createProxyServer({
target: config.baseUrl && projectType === 'ct' ? config.baseUrl : undefined,
target: config.baseUrl && testingType === 'component' ? config.baseUrl : undefined,
})

this._socket = new SocketCtor(config) as TSocket
Expand Down Expand Up @@ -604,7 +604,7 @@ export abstract class ServerBase<TSocket extends SocketE2E | SocketCt> {
return this.httpsProxy.connect(req, socket, head)
}

sendSpecList (specs: Cypress.Cypress['spec'][], projectType: RunnerType) {
return this.socket.sendSpecList(specs, projectType)
sendSpecList (specs: Cypress.Cypress['spec'][], testingType: Cypress.TestingType) {
return this.socket.sendSpecList(specs, testingType)
}
}
2 changes: 1 addition & 1 deletion packages/server/lib/server-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ServerE2E extends ServerBase<SocketE2E> {
}

open (config: Cfg, options: OpenServerOptions) {
return super.open(config, { ...options, projectType: 'e2e' })
return super.open(config, { ...options, testingType: 'e2e' })
}

createServer (app, config, onWarning): Bluebird<[number, WarningErr?]> {
Expand Down
5 changes: 2 additions & 3 deletions packages/server/lib/socket-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { getUserEditor, setUserEditor } from './util/editors'
import { openFile } from './util/file-opener'
import open from './util/open'
import { DestroyableHttpServer } from './util/server_destroy'
import { RunnerType } from './specs-store'

type StartListeningCallbacks = {
onSocketConnection: (socket: any) => void
Expand Down Expand Up @@ -484,7 +483,7 @@ export class SocketBase {
return this.io.close()
}

sendSpecList (specs, projectType: RunnerType) {
this.toRunner('specs:changed', { specs, projectType })
sendSpecList (specs, testingType: Cypress.TestingType) {
this.toRunner('specs:changed', { specs, testingType })
}
}
6 changes: 2 additions & 4 deletions packages/server/lib/specs-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@ const COMMON_SEARCH_OPTIONS = ['fixturesFolder', 'supportFile', 'projectRoot', '
// TODO: shouldn't this be on the trailing edge, not leading?
const debounce = (fn) => _.debounce(fn, 250, { leading: true })

export type RunnerType = 'ct' | 'e2e'

export class SpecsStore {
watcher: FSWatcher | null = null
specFiles: SpecFiles = []

constructor (
private cypressConfig: Record<string, any>,
private runner: RunnerType,
private runner: Cypress.TestingType,
) {}

get specDirectory () {
if (this.runner === 'e2e') {
return this.cypressConfig.resolved.integrationFolder.value
}

if (this.runner === 'ct') {
if (this.runner === 'component') {
return this.cypressConfig.resolved.componentFolder.value
}
}
Expand Down
Loading

6 comments on commit 257ff95

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 257ff95 Jul 26, 2021

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:

npm install https://cdn.cypress.io/beta/npm/8.0.0/circle-develop-257ff95dcbe3678913799dfbbb1196d2ebce036b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 257ff95 Jul 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor 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:

npm install https://cdn.cypress.io/beta/npm/8.0.0/appveyor-develop-257ff95dcbe3678913799dfbbb1196d2ebce036b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 257ff95 Jul 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 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:

npm install https://cdn.cypress.io/beta/npm/8.0.0/appveyor-develop-257ff95dcbe3678913799dfbbb1196d2ebce036b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 257ff95 Jul 26, 2021

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:

npm install https://cdn.cypress.io/beta/npm/8.0.0/circle-develop-257ff95dcbe3678913799dfbbb1196d2ebce036b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 257ff95 Jul 27, 2021

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:

npm install https://cdn.cypress.io/beta/npm/8.0.0/circle-develop-257ff95dcbe3678913799dfbbb1196d2ebce036b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 257ff95 Jul 27, 2021

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:

npm install https://cdn.cypress.io/beta/npm/8.0.0/circle-develop-257ff95dcbe3678913799dfbbb1196d2ebce036b/cypress.tgz

Please sign in to comment.