diff --git a/packages/data-context/src/actions/ProjectActions.ts b/packages/data-context/src/actions/ProjectActions.ts index 6854286eef..55cd52f457 100644 --- a/packages/data-context/src/actions/ProjectActions.ts +++ b/packages/data-context/src/actions/ProjectActions.ts @@ -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 closeActiveProject(shouldCloseBrowser?: boolean): Promise getConfig(): ReceivedCypressOptions | undefined + getRemoteStates(): RemoteStates | undefined getCurrentBrowser: () => Cypress.Browser | undefined getCurrentProjectSavedState(): {} | undefined setPromptShown(slug: string): void diff --git a/packages/data-context/src/sources/HtmlDataSource.ts b/packages/data-context/src/sources/HtmlDataSource.ts index 75375852d3..5ea733e801 100644 --- a/packages/data-context/src/sources/HtmlDataSource.ts +++ b/packages/data-context/src/sources/HtmlDataSource.ts @@ -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 { diff --git a/packages/graphql/schemas/cloud.graphql b/packages/graphql/schemas/cloud.graphql index 5bba7a93c4..8e484a1906 100644 --- a/packages/graphql/schemas/cloud.graphql +++ b/packages/graphql/schemas/cloud.graphql @@ -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 """ diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 0c0c511875..9368e242c4 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -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 diff --git a/packages/server/lib/makeDataContext.ts b/packages/server/lib/makeDataContext.ts index b33c1c284e..c4f08fdcbb 100644 --- a/packages/server/lib/makeDataContext.ts +++ b/packages/server/lib/makeDataContext.ts @@ -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? diff --git a/packages/server/lib/open_project.ts b/packages/server/lib/open_project.ts index bdd2ba03a0..c8bce88654 100644 --- a/packages/server/lib/open_project.ts +++ b/packages/server/lib/open_project.ts @@ -39,6 +39,10 @@ export class OpenProject { return this.projectBase?.getConfig() } + getRemoteStates () { + return this.projectBase?.remoteStates + } + getProject () { return this.projectBase } diff --git a/packages/server/lib/project-base.ts b/packages/server/lib/project-base.ts index ef7288122a..8b8c7e81b9 100644 --- a/packages/server/lib/project-base.ts +++ b/packages/server/lib/project-base.ts @@ -130,6 +130,10 @@ export class ProjectBase 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 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: [],