Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update the protocol to be able to flex logic based on project config #30594

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->

## 13.16.0
ryanthemanuel marked this conversation as resolved.
Show resolved Hide resolved

_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_
Expand Down
3 changes: 3 additions & 0 deletions packages/server/lib/cloud/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -435,6 +437,7 @@ export default {
retryWithBackoff: this.retryWithBackoff,
requestPromise: this.rp,
},
projectConfig: _.pick(config, ['devServerPublicPathRoute', 'port', 'proxyUrl', 'namespace']),
mountVersion: runnerCapabilities.protocolMountVersion,
})
}
Expand Down
28 changes: 28 additions & 0 deletions packages/server/test/unit/cloud/api/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
},
},
)
})
Expand Down Expand Up @@ -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({
Expand All @@ -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',
},
},
)
})
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { IncomingHttpHeaders } from 'http'
import type { Readable } from 'stream'
import type { ProxyTimings } from './proxy'
import type { SpecWithRelativeRoot } from './spec'
import { FullConfig } from './config'
ryanthemanuel marked this conversation as resolved.
Show resolved Hide resolved

type Commands = ProtocolMapping.Commands
type Command<T extends keyof Commands> = Commands[T]
Expand Down Expand Up @@ -85,6 +86,8 @@ export type CaptureArtifact = {
filePath: string
}

type ProjectConfig = Pick<FullConfig, 'devServerPublicPathRoute' | 'port' | 'proxyUrl' | 'namespace'>

export type ProtocolManagerOptions = {
runId: string
testingType: 'e2e' | 'component'
Expand All @@ -96,6 +99,7 @@ export type ProtocolManagerOptions = {
get (options: any): Promise<any>
}
}
projectConfig: ProjectConfig
mountVersion?: number
}

Expand Down
Loading