Skip to content

Commit 1bf3ff8

Browse files
authored
chore: remove experimentalPromptCommand config (#33497)
* chore: remove experimentalPromptCommand config * Update with code review * feat: add projectId handling in CyPromptLifecycleManager and ProjectBase - Enhanced ProjectBase to include projectId in the context. - Updated CyPromptLifecycleManager to utilize projectId, with fallback handling when project configuration fails. - Added tests to verify behavior when project configuration is unavailable, ensuring fallback projectId is used correctly. * Update with code review * Update with code review
1 parent b21fa13 commit 1bf3ff8

37 files changed

Lines changed: 197 additions & 349 deletions

cli/types/cypress.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3355,11 +3355,6 @@ declare namespace Cypress {
33553355
* @default false
33563356
*/
33573357
experimentalOriginDependencies?: boolean
3358-
/**
3359-
* Enables support for `cy.prompt`, an AI-powered command that turns natural language steps into executable Cypress test code.
3360-
* @default false
3361-
*/
3362-
experimentalPromptCommand?: boolean
33633358
}
33643359

33653360
/**

guides/cy-prompt-development.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Regardless of running against local or deployed `cy.prompt`:
2222
- Run `yarn`
2323
- Run `yarn cypress:open`
2424
- Log In to the Cloud via the App
25-
- Open a project that has `experimentalPromptCommand: true` set in the config of the `cypress.config.js|ts` file within `e2e`. Ensure the project has the feature flag `cy-prompt` enabled.
2625

2726
To run against a deployed version of `cy.prompt`:
2827

packages/app/src/runner/event-manager.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,9 @@ export class EventManager {
453453

454454
this._addListeners()
455455

456-
if (Cypress.config('experimentalPromptCommand')) {
457-
await new Promise((resolve) => {
458-
this.ws.emit('prompt:reset', resolve)
459-
})
460-
}
456+
await new Promise((resolve) => {
457+
this.ws.emit('prompt:reset', resolve)
458+
})
461459
}
462460

463461
isBrowserFamily (family: string) {

packages/config/src/options.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const BREAKING_OPTION_ERROR_KEY: Readonly<AllCypressErrorNames[]> = [
2828
'VIDEO_UPLOAD_ON_PASSES_REMOVED',
2929
'RENAMED_CONFIG_OPTION',
3030
'EXPERIMENTAL_STUDIO_REMOVED',
31+
'EXPERIMENTAL_PROMPT_COMMAND_REMOVED',
3132
'CYPRESS_ENV_DEPRECATION',
3233
] as const
3334

@@ -256,12 +257,6 @@ const driverConfigOptions: Array<DriverConfigOption> = [
256257
isExperimental: true,
257258
overrideLevel: 'any',
258259
requireRestartOnChange: 'browser',
259-
}, {
260-
name: 'experimentalPromptCommand',
261-
defaultValue: false,
262-
validation: validate.isBoolean,
263-
isExperimental: true,
264-
requireRestartOnChange: 'server',
265260
}, {
266261
name: 'experimentalSourceRewriting',
267262
defaultValue: false,
@@ -659,6 +654,11 @@ export const breakingOptions: Readonly<BreakingOption[]> = [
659654
errorKey: 'EXPERIMENTAL_STUDIO_REMOVED',
660655
isWarning: true,
661656
},
657+
{
658+
name: 'experimentalPromptCommand',
659+
errorKey: 'EXPERIMENTAL_PROMPT_COMMAND_REMOVED',
660+
isWarning: true,
661+
},
662662
{
663663
name: 'allowCypressEnv',
664664
errorKey: 'CYPRESS_ENV_DEPRECATION',
@@ -711,12 +711,6 @@ export const breakingRootOptions: Array<BreakingOption> = [
711711
isWarning: false,
712712
testingTypes: ['e2e'],
713713
},
714-
{
715-
name: 'experimentalPromptCommand',
716-
errorKey: 'EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY',
717-
isWarning: false,
718-
testingTypes: ['e2e'],
719-
},
720714
{
721715
name: 'justInTimeCompile',
722716
errorKey: 'JIT_COMPONENT_TESTING',
@@ -764,11 +758,6 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
764758
errorKey: 'EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY',
765759
isWarning: false,
766760
},
767-
{
768-
name: 'experimentalPromptCommand',
769-
errorKey: 'EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY',
770-
isWarning: false,
771-
},
772761
{
773762
name: 'injectDocumentDomain',
774763
errorKey: 'INJECT_DOCUMENT_DOMAIN_E2E_ONLY',

packages/config/test/__snapshots__/index.spec.ts.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`config/src/index > .getBreakingKeys > returns list of breaking config k
77
"experimentalSkipDomainInjection",
88
"videoUploadOnPasses",
99
"experimentalStudio",
10+
"experimentalPromptCommand",
1011
"allowCypressEnv",
1112
]
1213
`;
@@ -45,7 +46,6 @@ exports[`config/src/index > .getDefaultValues > returns list of public config ke
4546
"experimentalMemoryManagement": false,
4647
"experimentalModifyObstructiveThirdPartyCode": false,
4748
"experimentalOriginDependencies": false,
48-
"experimentalPromptCommand": false,
4949
"experimentalRunAllSpecs": false,
5050
"experimentalSingleTabRunMode": false,
5151
"experimentalSourceRewriting": false,
@@ -143,7 +143,6 @@ exports[`config/src/index > .getDefaultValues > returns list of public config ke
143143
"experimentalMemoryManagement": false,
144144
"experimentalModifyObstructiveThirdPartyCode": false,
145145
"experimentalOriginDependencies": false,
146-
"experimentalPromptCommand": false,
147146
"experimentalRunAllSpecs": false,
148147
"experimentalSingleTabRunMode": false,
149148
"experimentalSourceRewriting": false,
@@ -231,7 +230,6 @@ exports[`config/src/index > .getPublicConfigKeys > returns list of public config
231230
"experimentalModifyObstructiveThirdPartyCode",
232231
"injectDocumentDomain",
233232
"experimentalOriginDependencies",
234-
"experimentalPromptCommand",
235233
"experimentalSourceRewriting",
236234
"experimentalSingleTabRunMode",
237235
"experimentalWebKitSupport",

packages/config/test/index.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ describe('config/src/index', () => {
162162
expect(errorFn).toHaveBeenCalledTimes(0)
163163
})
164164

165+
it('calls warning callback if config contains experimentalPromptCommand', () => {
166+
const warningFn = vi.fn()
167+
const errorFn = vi.fn()
168+
169+
configUtil.validateNoBreakingConfig({
170+
experimentalPromptCommand: true,
171+
configFile: 'config.js',
172+
}, warningFn, errorFn, 'e2e')
173+
174+
expect(warningFn).toHaveBeenCalledExactlyOnceWith('EXPERIMENTAL_PROMPT_COMMAND_REMOVED', {
175+
name: 'experimentalPromptCommand',
176+
newName: undefined,
177+
value: undefined,
178+
testingType: 'e2e',
179+
configFile: 'config.js',
180+
})
181+
182+
expect(errorFn).toHaveBeenCalledTimes(0)
183+
})
184+
165185
it('calls error callback if config contains breaking option that should throw an error', () => {
166186
const warningFn = vi.fn()
167187
const errorFn = vi.fn()

packages/config/test/project/utils.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,6 @@ describe('config/src/project/utils', () => {
11931193
experimentalInteractiveRunEvents: { value: false, from: 'default' },
11941194
experimentalMemoryManagement: { value: false, from: 'default' },
11951195
experimentalOriginDependencies: { value: false, from: 'default' },
1196-
experimentalPromptCommand: { value: false, from: 'default' },
11971196
experimentalRunAllSpecs: { value: false, from: 'default' },
11981197
experimentalSingleTabRunMode: { value: false, from: 'default' },
11991198
experimentalSourceRewriting: { value: false, from: 'default' },
@@ -1318,7 +1317,6 @@ describe('config/src/project/utils', () => {
13181317
experimentalInteractiveRunEvents: { value: false, from: 'default' },
13191318
experimentalMemoryManagement: { value: false, from: 'default' },
13201319
experimentalOriginDependencies: { value: false, from: 'default' },
1321-
experimentalPromptCommand: { value: false, from: 'default' },
13221320
experimentalRunAllSpecs: { value: false, from: 'default' },
13231321
experimentalSingleTabRunMode: { value: false, from: 'default' },
13241322
experimentalSourceRewriting: { value: false, from: 'default' },

packages/data-context/schemas/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ enum ErrorTypeEnum {
11821182
ERROR_WRITING_FILE
11831183
EXPERIMENTAL_JIT_COMPILE_REMOVED
11841184
EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY
1185-
EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY
1185+
EXPERIMENTAL_PROMPT_COMMAND_REMOVED
11861186
EXPERIMENTAL_SESSION_AND_ORIGIN_REMOVED
11871187
EXPERIMENTAL_SINGLE_TAB_RUN_MODE
11881188
EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED

packages/driver/cypress.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const baseConfig: Cypress.ConfigOptions = {
2525
configFile: '../../mocha-reporter-config.json',
2626
},
2727
e2e: {
28-
experimentalPromptCommand: true,
2928
experimentalOriginDependencies: true,
3029
experimentalModifyObstructiveThirdPartyCode: true,
3130
setupNodeEvents: (on, config) => {

packages/driver/src/cy/commands/prompt/index.ts

Lines changed: 47 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -163,90 +163,61 @@ const initializeCloudCyPrompt = async (Cypress: Cypress.Cypress, cy: Cypress.Cyp
163163
}
164164

165165
export default (Commands: Cypress.Cypress['Commands'], Cypress: Cypress.Cypress, cy: Cypress.Cypress['cy']) => {
166-
// @ts-expect-error - these types are not yet implemented until the prompt command is rolled out
167-
if (Cypress.config('experimentalPromptCommand')) {
168-
let initializeCloudCyPromptPromise = initializeCloudCyPrompt(Cypress, cy)
169-
170-
const commands = {
171-
prompt (steps: string[], commandOptions: object = {}) {
172-
const promptCmd = cy.state('current')
173-
174-
const downloadTimeout = '_downloadTimeout' in commandOptions ? commandOptions._downloadTimeout as number : 45000
175-
176-
let timeoutId: NodeJS.Timeout
177-
const timeoutPromise = new Promise((resolve) => {
178-
timeoutId = setTimeout(() => {
179-
resolve({
180-
error: undefined,
181-
timedOut: true,
182-
})
183-
}, downloadTimeout)
184-
})
185-
const raceBundleResult = Promise.race([
186-
initializeCloudCyPromptPromise,
187-
timeoutPromise,
188-
]).finally(() => {
189-
clearTimeout(timeoutId)
190-
}) as Promise<BundleResult>
191-
192-
return cy.wrap(raceBundleResult, { log: false, timeout: 1e9 }).then((bundleResult: BundleResult) => {
193-
if (bundleResult.timedOut) {
194-
cy.state('current', promptCmd)
195-
196-
return $errUtils.throwErrByPath('prompt.promptDownloadTimedOut', {
197-
args: {
198-
error: new Error('cy.prompt bundle download timed out'),
199-
},
200-
})
201-
}
166+
let initializeCloudCyPromptPromise = initializeCloudCyPrompt(Cypress, cy)
202167

203-
if (bundleResult.error) {
204-
cy.state('current', promptCmd)
205-
throw bundleResult.error
206-
}
168+
const commands = {
169+
prompt (steps: string[], commandOptions: object = {}) {
170+
const promptCmd = cy.state('current')
207171

208-
const cyPrompt = bundleResult.bundle
172+
const downloadTimeout = '_downloadTimeout' in commandOptions ? commandOptions._downloadTimeout as number : 45000
209173

210-
return cyPrompt({
211-
steps,
212-
commandOptions,
213-
promptCmd,
174+
let timeoutId: NodeJS.Timeout
175+
const timeoutPromise = new Promise((resolve) => {
176+
timeoutId = setTimeout(() => {
177+
resolve({
178+
error: undefined,
179+
timedOut: true,
214180
})
215-
})
216-
},
217-
}
218-
219-
commands.prompt['__resetPrompt'] = async (delay: number = 0) => {
220-
initializedModule = null
221-
initializeCloudCyPromptPromise = new Promise((resolve) => setTimeout(resolve, delay)).then(() => initializeCloudCyPrompt(Cypress, cy))
222-
}
223-
224-
Commands.addAll(commands)
225-
} else {
226-
Commands.addAll({
227-
prompt () {
228-
const stack = cy.state('current').get('userInvocationStack')
229-
230-
if (Cypress.testingType === 'component') {
231-
$errUtils.throwErrByPath('prompt.promptTestingTypeError', {
232-
errProps: {
233-
name: 'PromptTestingTypeError',
234-
},
235-
onFail: (err) => {
236-
err.stack = stack
181+
}, downloadTimeout)
182+
})
183+
const raceBundleResult = Promise.race([
184+
initializeCloudCyPromptPromise,
185+
timeoutPromise,
186+
]).finally(() => {
187+
clearTimeout(timeoutId)
188+
}) as Promise<BundleResult>
189+
190+
return cy.wrap(raceBundleResult, { log: false, timeout: 1e9 }).then((bundleResult: BundleResult) => {
191+
if (bundleResult.timedOut) {
192+
cy.state('current', promptCmd)
193+
194+
return $errUtils.throwErrByPath('prompt.promptDownloadTimedOut', {
195+
args: {
196+
error: new Error('cy.prompt bundle download timed out'),
237197
},
238198
})
239199
}
240200

241-
$errUtils.throwErrByPath('prompt.experimentalPromptCommandError', {
242-
errProps: {
243-
name: 'PromptNotEnabledError',
244-
},
245-
onFail: (err) => {
246-
err.stack = stack
247-
},
201+
if (bundleResult.error) {
202+
cy.state('current', promptCmd)
203+
throw bundleResult.error
204+
}
205+
206+
const cyPrompt = bundleResult.bundle
207+
208+
return cyPrompt({
209+
steps,
210+
commandOptions,
211+
promptCmd,
248212
})
249-
},
250-
})
213+
})
214+
},
251215
}
216+
217+
commands.prompt['__resetPrompt'] = async (delay: number = 0) => {
218+
initializedModule = null
219+
initializeCloudCyPromptPromise = new Promise((resolve) => setTimeout(resolve, delay)).then(() => initializeCloudCyPrompt(Cypress, cy))
220+
}
221+
222+
Commands.addAll(commands)
252223
}

0 commit comments

Comments
 (0)