set remote to primary domain when app is reserved in e2e testing mode

This commit is contained in:
Bill Glesias
2022-05-04 10:38:48 -04:00
parent 577edc698e
commit c8331fc54f
7 changed files with 40 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import { codeGenerator, SpecOptions } from '../codegen'
import templates from '../codegen/templates'
import { insertValuesInConfigFile } from '../util'
import { getError } from '@packages/errors'
import type { RemoteStates } from '@packages/server/lib/remote_states'
export interface ProjectApiShape {
/**
@@ -30,6 +31,7 @@ export interface ProjectApiShape {
clearAllProjectPreferences(): Promise<unknown>
closeActiveProject(shouldCloseBrowser?: boolean): Promise<unknown>
getConfig(): ReceivedCypressOptions | undefined
getRemoteStates(): RemoteStates | undefined
getCurrentBrowser: () => Cypress.Browser | undefined
getCurrentProjectSavedState(): {} | undefined
setPromptShown(slug: string): void

View File

@@ -67,6 +67,16 @@ export class HtmlDataSource {
...fieldsFromLegacyCfg,
}
// for project-base config, the remote state we wish to convey should be whatever top is set to, also known as the primary domain
// whenever the app is served/re-served
if (this.ctx.coreData.currentTestingType === 'e2e') {
const remoteStates = this.ctx._apis.projectApi.getRemoteStates()
if (remoteStates) {
cfg.remote = remoteStates.getPrimary()
}
}
cfg.browser = this.ctx._apis.projectApi.getCurrentBrowser()
return {

View File

@@ -469,6 +469,16 @@ type Query {
id: ID!
): Node
"""
Returns a list of cloud nodes, by ID. Max 100 nodes per batch
"""
cloudNodesByIds(
"""
A list of IDs for a Node, conforming to the Relay spec
"""
ids: [ID!]!
): [Node]
"""
Lookup an individual project by the slug
"""

View File

@@ -1157,6 +1157,12 @@ type Query {
id: ID!
): Node
"""Returns a list of cloud nodes, by ID. Max 100 nodes per batch"""
cloudNodesByIds(
"""A list of IDs for a Node, conforming to the Relay spec"""
ids: [ID!]!
): [Node]
"""Lookup an individual project by the slug"""
cloudProjectBySlug(slug: String!): CloudProjectResult

View File

@@ -133,6 +133,9 @@ export function makeDataContext (options: MakeDataContextOptions): DataContext {
getConfig () {
return openProject.getConfig()
},
getRemoteStates () {
return openProject.getRemoteStates()
},
getCurrentProjectSavedState () {
// TODO: See if this is the best way we should be getting this config,
// shouldn't we have this already in the DataContext?

View File

@@ -39,6 +39,10 @@ export class OpenProject {
return this.projectBase?.getConfig()
}
getRemoteStates () {
return this.projectBase?.remoteStates
}
getProject () {
return this.projectBase
}

View File

@@ -130,6 +130,10 @@ export class ProjectBase<TServer extends Server> extends EE {
return this.cfg.state
}
get remoteStates () {
return this._server?.remoteStates
}
injectCtSpecificConfig (cfg) {
cfg.resolved.testingType = { value: 'component' }
@@ -484,8 +488,7 @@ export class ProjectBase<TServer extends Server> extends EE {
return {
...this._cfg,
// for project-base config, the remote state we wish to convey should be whatever top is set to, also known as the primary domain
remote: this._server?.remoteStates.getPrimary() ?? {} as Cypress.RemoteState,
remote: this.remoteStates?.current() ?? {} as Cypress.RemoteState,
browser: this.browser,
testingType: this.ctx.coreData.currentTestingType ?? 'e2e',
specs: [],