From 0975b2f07fed1802081a87ea5df5d5fa67a84965 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 13 Nov 2024 15:42:11 -0600 Subject: [PATCH] feat: update the protocol to be able to flex logic based on project config (#30594) * feat: update the protocol to be able to flex logic based on project config * slight refactor * Update cli/CHANGELOG.md * Update packages/types/src/protocol.ts * fix ts --- cli/CHANGELOG.md | 8 ++++++ packages/server/lib/cloud/api/index.ts | 3 ++ .../server/test/unit/cloud/api/api_spec.js | 28 +++++++++++++++++++ packages/types/src/protocol.ts | 8 ++++++ 4 files changed, 47 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index e0583405be4b..51b0e3d745b5 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,4 +1,12 @@ +## 13.16.0 + +_Released 11/19/2024 (PENDING)_ + +**Features:** + +- Updated the protocol to be able to flex logic based on project config. Addresses [#30560](https://github.com/cypress-io/cypress/issues/30560). + ## 13.15.2 _Released 11/5/2024_ diff --git a/packages/server/lib/cloud/api/index.ts b/packages/server/lib/cloud/api/index.ts index 96e3feff4e9b..9f999bbd9f46 100644 --- a/packages/server/lib/cloud/api/index.ts +++ b/packages/server/lib/cloud/api/index.ts @@ -426,6 +426,8 @@ export default { } if (script) { + const config = options.project.getConfig() + await options.project.protocolManager.setupProtocol(script, { runId: result.runId, projectId: options.projectId, @@ -435,6 +437,7 @@ export default { retryWithBackoff: this.retryWithBackoff, requestPromise: this.rp, }, + projectConfig: _.pick(config, ['devServerPublicPathRoute', 'port', 'proxyUrl', 'namespace']), mountVersion: runnerCapabilities.protocolMountVersion, }) } diff --git a/packages/server/test/unit/cloud/api/api_spec.js b/packages/server/test/unit/cloud/api/api_spec.js index 41f4b1da5fb1..26c73e160580 100644 --- a/packages/server/test/unit/cloud/api/api_spec.js +++ b/packages/server/test/unit/cloud/api/api_spec.js @@ -591,6 +591,14 @@ describe('lib/cloud/api', () => { get protocolManager () { return protocolManager }, + getConfig: () => { + return { + port: 1234, + devServerPublicPathRoute: '/dev-server', + proxyUrl: 'http://localhost:1234', + namespace: '__cypress', + } + }, } return api.createRun({ @@ -617,6 +625,12 @@ describe('lib/cloud/api', () => { retryWithBackoff: api.retryWithBackoff, requestPromise: api.rp, }, + projectConfig: { + port: 1234, + devServerPublicPathRoute: '/dev-server', + proxyUrl: 'http://localhost:1234', + namespace: '__cypress', + }, }, ) }) @@ -666,6 +680,14 @@ describe('lib/cloud/api', () => { get protocolManager () { return protocolManager }, + getConfig: () => { + return { + port: 1234, + devServerPublicPathRoute: '/dev-server', + proxyUrl: 'http://localhost:1234', + namespace: '__cypress', + } + }, } return api.createRun({ @@ -692,6 +714,12 @@ describe('lib/cloud/api', () => { retryWithBackoff: api.retryWithBackoff, requestPromise: api.rp, }, + projectConfig: { + port: 1234, + devServerPublicPathRoute: '/dev-server', + proxyUrl: 'http://localhost:1234', + namespace: '__cypress', + }, }, ) }) diff --git a/packages/types/src/protocol.ts b/packages/types/src/protocol.ts index 85948e9296c7..6830421033f1 100644 --- a/packages/types/src/protocol.ts +++ b/packages/types/src/protocol.ts @@ -85,6 +85,13 @@ export type CaptureArtifact = { filePath: string } +type ProjectConfig = { + devServerPublicPathRoute: string + namespace: string + port: number + proxyUrl: string +} + export type ProtocolManagerOptions = { runId: string testingType: 'e2e' | 'component' @@ -96,6 +103,7 @@ export type ProtocolManagerOptions = { get (options: any): Promise } } + projectConfig: ProjectConfig mountVersion?: number }