mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-20 06:01:12 -06:00
* use new specPattern API * remove projectApi.findSpecs * do not require integration folder * support --spec * support --spec * remove old code * remove old code * nuke old code * no appvetor * update * correct url for ct * work on migrating launchpad * update ct spec url * types * types * dead code * remove old endpiont * revert back circle.yml * update missing config * delete spec util * update config * update config * config again * update spec pattern * updated vue config * update spec pattern for ui components * update config for vite dev server * update snapshots * update config * update design system config * fix spec pattern in reporter * update default * update deprecated spec snapshots * update system tests * update run mode output * revert changes * lint * remove scaffold tests * update angular * fix CT * update circle yml * fix system tests for ct * fix tests * work on server unit tests * patch package * patch package again * update test * try not to rely on config async loading too much * normalize specPattern to array * update snapshot * use base name * deal with react-scripts later * update snapshot * hacky way to update snapshots * new hack to update snapshots * trying again * hacky fix * ci: snapshots * ci: snapshots * snapshots * mas updates * update spec API * fix test * fix test * update * update test * fix test * update plugin * update spec * webpack optinos * Update launchpad tests * fix screenshot paths * updated snapshot * change pattern * guard * fix smoke test * patch code coverage * update percy config * fix specs * try updating example project * update snapshots * remove old test * remove snapshot hack * add back appveyor * remove old code * update snapshot * Fix tests * wip * revert snapshot * reverted all snaps * remove only * remove commnet * remove old code * reverted file * lint * revert video compression spec * update snapshot * update spec path logic * update snap * updated snap * snaps * snaps * fix spec * rename ignoreTestFiles to ignoreSpecPattern * update screenshot dir for runner-ct * update deprecations * update * upate * fix test * update snaps * update snap * updating snap * added missing snaps * updated cypress run mode integration spec * electron snapshot * ensure newly scaffold specs are cached * fix launchpad spec * types * update test * transpile based on spec pattern * add back example * remove unnecessary async and nodeVersion * removed old test * update spec pattern and add defensive check around platform * remove unused feature flag * added tests * fix react example * update test * update config * fix spec finding in run mode * fix tests * fixing specs * fix switching between specs * remove invalid test * increase timeout Co-authored-by: estrada9166 <estrada9166@hotmail.com>
147 lines
4.2 KiB
TypeScript
147 lines
4.2 KiB
TypeScript
import { DataContext, getCtx, clearCtx, setCtx } from '@packages/data-context'
|
|
import electron from 'electron'
|
|
import pkg from '@packages/root'
|
|
import configUtils from '@packages/config'
|
|
|
|
import type {
|
|
AllModeOptions,
|
|
AllowedState,
|
|
FoundBrowser,
|
|
InitializeProjectOptions,
|
|
LaunchOpts,
|
|
OpenProjectLaunchOptions,
|
|
Preferences,
|
|
} from '@packages/types'
|
|
|
|
import browserUtils from './browsers/utils'
|
|
import auth from './gui/auth'
|
|
import user from './user'
|
|
import * as config from './config'
|
|
import { openProject } from './open_project'
|
|
import cache from './cache'
|
|
import errors from './errors'
|
|
import findSystemNode from './util/find_system_node'
|
|
import { graphqlSchema } from '@packages/graphql/src/schema'
|
|
import { openExternal } from '@packages/server/lib/gui/links'
|
|
import { getUserEditor } from './util/editors'
|
|
import * as savedState from './saved_state'
|
|
import appData from './util/app_data'
|
|
import plugins from './plugins'
|
|
import browsers from './browsers'
|
|
|
|
const { getBrowsers, ensureAndGetByNameOrPath } = browserUtils
|
|
|
|
interface MakeDataContextOptions {
|
|
mode: 'run' | 'open'
|
|
modeOptions: Partial<AllModeOptions>
|
|
}
|
|
|
|
export { getCtx, setCtx, clearCtx }
|
|
|
|
export function makeDataContext (options: MakeDataContextOptions): DataContext {
|
|
const ctx = new DataContext({
|
|
schema: graphqlSchema,
|
|
...options,
|
|
browserApi: {
|
|
close: browsers.close,
|
|
getBrowsers,
|
|
async ensureAndGetByNameOrPath (nameOrPath: string) {
|
|
const browsers = await ctx.browser.machineBrowsers()
|
|
|
|
return await ensureAndGetByNameOrPath(nameOrPath, false, browsers)
|
|
},
|
|
},
|
|
errorApi: {
|
|
error: errors.get,
|
|
message: errors.getMsgByType,
|
|
},
|
|
configApi: {
|
|
getServerPluginHandlers: plugins.getServerPluginHandlers,
|
|
allowedConfig: configUtils.allowed,
|
|
cypressVersion: pkg.version,
|
|
validateConfig: configUtils.validate,
|
|
updateWithPluginValues: config.updateWithPluginValues,
|
|
setupFullConfigWithDefaults: config.setupFullConfigWithDefaults,
|
|
},
|
|
appApi: {
|
|
appData,
|
|
findNodePath () {
|
|
return findSystemNode.findNodeInFullPath()
|
|
},
|
|
},
|
|
authApi: {
|
|
getUser () {
|
|
return user.get()
|
|
},
|
|
logIn (onMessage) {
|
|
return auth.start(onMessage, 'launchpad')
|
|
},
|
|
logOut () {
|
|
return user.logOut()
|
|
},
|
|
},
|
|
projectApi: {
|
|
launchProject (browser: FoundBrowser, spec: Cypress.Spec, options?: LaunchOpts) {
|
|
return openProject.launch({ ...browser }, spec, options)
|
|
},
|
|
openProjectCreate (args: InitializeProjectOptions, options: OpenProjectLaunchOptions) {
|
|
return openProject.create(args.projectRoot, args, options)
|
|
},
|
|
insertProjectToCache (projectRoot: string) {
|
|
cache.insertProject(projectRoot)
|
|
},
|
|
getProjectRootsFromCache () {
|
|
return cache.getProjectRoots()
|
|
},
|
|
clearLatestProjectsCache () {
|
|
return cache.removeLatestProjects()
|
|
},
|
|
getProjectPreferencesFromCache () {
|
|
return cache.getProjectPreferences()
|
|
},
|
|
clearProjectPreferences (projectTitle: string) {
|
|
return cache.removeProjectPreferences(projectTitle)
|
|
},
|
|
clearAllProjectPreferences () {
|
|
return cache.removeAllProjectPreferences()
|
|
},
|
|
insertProjectPreferencesToCache (projectTitle: string, preferences: Preferences) {
|
|
cache.insertProjectPreferences(projectTitle, preferences)
|
|
},
|
|
removeProjectFromCache (path: string) {
|
|
return cache.removeProject(path)
|
|
},
|
|
closeActiveProject () {
|
|
return openProject.closeActiveProject()
|
|
},
|
|
},
|
|
electronApi: {
|
|
openExternal (url: string) {
|
|
openExternal(url).catch((e) => {
|
|
ctx.logTraceError(e)
|
|
})
|
|
},
|
|
showItemInFolder (folder: string) {
|
|
electron.shell.showItemInFolder(folder)
|
|
},
|
|
},
|
|
localSettingsApi: {
|
|
async setPreferences (object: AllowedState) {
|
|
const state = await savedState.create()
|
|
|
|
return state.set(object)
|
|
},
|
|
async getPreferences () {
|
|
return (await savedState.create()).get()
|
|
},
|
|
async getAvailableEditors () {
|
|
const { availableEditors } = await getUserEditor(true)
|
|
|
|
return availableEditors
|
|
},
|
|
},
|
|
})
|
|
|
|
return ctx
|
|
}
|