Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 14 additions & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ declare namespace Cypress {
interface ObjectLike {
[key: string]: any
}
interface PromptOptions {
excludeFromAI?: Record<string, string>
}
interface Auth {
username: string
password: string
Expand Down Expand Up @@ -1848,7 +1851,12 @@ declare namespace Cypress {
* @see https://on.cypress.io/prevuntil
*/
prevUntil<E extends Node = HTMLElement>(element: E | JQuery<E>, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>

/**
* An AI-powered command that generates Cypress commands from natural language test steps.
*
* @see https://on.cypress.io/prompt
*/
prompt(steps: string[], options?: PromptOptions): Chainable<null>
/**
* Read a file and yield its contents.
*
Expand Down Expand Up @@ -3271,6 +3279,11 @@ declare namespace Cypress {
* @default false
*/
experimentalOriginDependencies?: boolean
/**
* Enables support for the prompt command.
* @default false
*/
experimentalPromptCommand?: boolean
}

/**
Expand Down
2 changes: 1 addition & 1 deletion guides/cy-prompt-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Regardless of running against local or deployed `cy.prompt`:
- Run `yarn`
- Run `yarn cypress:open`
- Log In to the Cloud via the App
- Open a project that has `experimentalPromptCommand: true` set in the config of the `cypress.config.js|ts` file. Ensure the project has the feature flag `cy-prompt` enabled.
- 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.

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

Expand Down
11 changes: 11 additions & 0 deletions packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,12 @@ export const breakingRootOptions: Array<BreakingOption> = [
isWarning: false,
testingTypes: ['e2e'],
},
{
name: 'experimentalPromptCommand',
errorKey: 'EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY',
isWarning: false,
testingTypes: ['e2e'],
},
{
name: 'justInTimeCompile',
errorKey: 'JIT_COMPONENT_TESTING',
Expand Down Expand Up @@ -735,6 +741,11 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
errorKey: 'EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY',
isWarning: false,
},
{
name: 'experimentalPromptCommand',
errorKey: 'EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY',
isWarning: false,
},
{
name: 'injectDocumentDomain',
errorKey: 'INJECT_DOCUMENT_DOMAIN_E2E_ONLY',
Expand Down
3 changes: 1 addition & 2 deletions packages/driver/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export const baseConfig: Cypress.ConfigOptions = {
experimentalStudio: true,
experimentalMemoryManagement: true,
experimentalWebKitSupport: true,
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
experimentalPromptCommand: true,
hosts: {
'foobar.com': '127.0.0.1',
'*.foobar.com': '127.0.0.1',
Expand All @@ -22,6 +20,7 @@ export const baseConfig: Cypress.ConfigOptions = {
configFile: '../../mocha-reporter-config.json',
},
e2e: {
experimentalPromptCommand: true,
experimentalOriginDependencies: true,
experimentalModifyObstructiveThirdPartyCode: true,
setupNodeEvents: (on, config) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('src/cy/commands/prompt', () => {
cy.visit('http://www.foobar.com:3500/fixtures/dom.html')

cy['commandFns']['prompt'].__resetPrompt()
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
cy.prompt(['Hello, world!'])
})

Expand All @@ -43,7 +42,6 @@ describe('src/cy/commands/prompt', () => {
cy.visit('http://www.foobar.com:3500/fixtures/dom.html')

cy['commandFns']['prompt'].__resetPrompt()
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
cy.prompt(['Hello, world!'])
})
})
1 change: 0 additions & 1 deletion packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('src/cy/commands/prompt', () => {

// TODO: add more tests when cy.prompt is built out, but for now this just
// verifies that the command executes without throwing an error
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
cy.prompt(['Click the "click me" button'])

cy.get('#log').should('contain', 'clicked')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,19 @@ export const AllCypressErrors = {

${fmt.code(code)}`
},
EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY: () => {
const code = errPartial`
{
e2e: {
experimentalPromptCommand: true
},
}`

return errTemplate`\
The ${fmt.highlight(`experimentalPromptCommand`)} experiment is currently only supported for End to End Testing and must be configured as an e2e testing type property: ${fmt.highlightSecondary(`e2e.experimentalPromptCommand`)}.

${fmt.code(code)}`
},
JIT_COMPONENT_TESTING: () => {
return errTemplate`\
The ${fmt.highlight(`justInTimeCompile`)} configuration is only supported for Component Testing.`
Expand Down
6 changes: 6 additions & 0 deletions packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,12 @@ describe('visual error templates', () => {
}
},

EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY: () => {
return {
default: [],
}
},

PROXY_ENCOUNTERED_INVALID_HEADER_NAME: () => {
const err = makeErr()

Expand Down
1 change: 1 addition & 0 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ enum ErrorTypeEnum {
ERROR_WRITING_FILE
EXPERIMENTAL_JIT_COMPILE_REMOVED
EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY
EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY
EXPERIMENTAL_RUN_ALL_SPECS_E2E_ONLY
EXPERIMENTAL_SESSION_AND_ORIGIN_REMOVED
EXPERIMENTAL_SINGLE_TAB_RUN_MODE
Expand Down
22 changes: 22 additions & 0 deletions packages/launchpad/cypress/e2e/config-warning.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,25 @@ describe('component testing dependency warnings', () => {
cy.get('[data-cy="warning-alert"]').should('not.exist')
})
})

describe('experimentalPromptCommand', () => {
it('is not a valid config for component testing', () => {
cy.scaffoldProject('experimentalPromptCommand')
cy.openProject('experimentalPromptCommand', ['--config-file', 'cypress-invalid-prompt-experiment.config.js'])

cy.visitLaunchpad()
cy.get('[data-cy-testingtype="component"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalPromptCommand experiment is currently only supported for End to End Testing')
})

it('is not a valid config when specified at root', () => {
cy.scaffoldProject('experimentalPromptCommand')
cy.openProject('experimentalPromptCommand', ['--config-file', 'cypress-invalid-prompt-experiment-root.config.js'])

cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalPromptCommand experiment is currently only supported for End to End Testing')
})
})
1 change: 0 additions & 1 deletion packages/server/lib/project-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export class ProjectBase extends EE {
process.chdir(this.projectRoot)

this._server = new ServerBase(cfg)
// @ts-expect-error - this will not error when we actually release the experimentalPromptCommand flag
if (cfg.experimentalPromptCommand) {
const cyPromptLifecycleManager = new CyPromptLifecycleManager()

Expand Down
3 changes: 2 additions & 1 deletion packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export interface FullConfig extends Partial<Cypress.RuntimeConfigOptions & Cypre
// and are required when creating a project.
export type ReceivedCypressOptions =
Pick<Cypress.RuntimeConfigOptions, 'hosts' | 'projectName' | 'clientRoute' | 'devServerPublicPathRoute' | 'namespace' | 'report' | 'socketIoCookie' | 'configFile' | 'isTextTerminal' | 'isNewProject' | 'proxyUrl' | 'browsers' | 'browserUrl' | 'socketIoRoute' | 'arch' | 'platform' | 'spec' | 'specs' | 'browser' | 'version' | 'remote'>
& Pick<Cypress.ResolvedConfigOptions, 'chromeWebSecurity' | 'supportFolder' | 'experimentalSourceRewriting' | 'fixturesFolder' | 'reporter' | 'reporterOptions' | 'screenshotsFolder' | 'supportFile' | 'baseUrl' | 'viewportHeight' | 'viewportWidth' | 'port' | 'experimentalInteractiveRunEvents' | 'userAgent' | 'downloadsFolder' | 'env' | 'excludeSpecPattern' | 'specPattern' | 'experimentalModifyObstructiveThirdPartyCode' | 'injectDocumentDomain' | 'video' | 'videoCompression' | 'videosFolder' | 'resolvedNodeVersion' | 'resolvedNodePath' | 'trashAssetsBeforeRuns' | 'experimentalWebKitSupport' | 'justInTimeCompile'> // TODO: Figure out how to type this better.
& Pick<Cypress.ResolvedConfigOptions, 'chromeWebSecurity' | 'supportFolder' | 'experimentalSourceRewriting' | 'fixturesFolder' | 'reporter' | 'reporterOptions' | 'screenshotsFolder' | 'supportFile' | 'baseUrl' | 'viewportHeight' | 'viewportWidth' | 'port' | 'experimentalInteractiveRunEvents' | 'userAgent' | 'downloadsFolder' | 'env' | 'excludeSpecPattern' | 'specPattern' | 'experimentalModifyObstructiveThirdPartyCode' | 'injectDocumentDomain' | 'video' | 'videoCompression' | 'videosFolder' | 'resolvedNodeVersion' | 'resolvedNodePath' | 'trashAssetsBeforeRuns' | 'experimentalWebKitSupport' | 'justInTimeCompile'>
& Pick<Cypress.ResolvedConfigOptions['e2e'], 'experimentalPromptCommand'> // TODO: Figure out how to type this better.

export interface SettingsOptions {
testingType?: 'component' |'e2e'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
// This property is invalid as `experimentalPromptCommand` is only available for e2e
experimentalPromptCommand: true,
e2e: {},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
component: {
// This property is invalid as `experimentalPromptCommand` is only available for e2e
experimentalPromptCommand: true,
devServer () {
// This test doesn't need to actually run any component tests
// so we create a fake dev server to make it run faster and
// avoid flake on CI.
return {
port: 1234,
close: () => {},
}
},
},
})
Empty file.
Empty file.