From df047b0a4290aa346392ca23afaca50aaa04cfc8 Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Sat, 4 Oct 2025 09:01:00 -0500 Subject: [PATCH] feat: cy.prompt experimental command [Feature Flagged] (#31752) * Create cy-prompt-development.md * chore: cy prompt infrastructure (#31748) * feat: cy prompt infrastructure * refactor and add tests * refactor * rename experimental config * prompt * fix test * Update cy-prompt-development.md * Update cy-prompt-development.md * PR comments * Update packages/server/lib/cloud/api/cy-prompt/get_cy_prompt_bundle.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * PR comments --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix test * Delete packages/server/lib/cloud/StudioLifecycleManager.ts * Delete packages/server/test/unit/cloud/StudioLifecycleManager_spec.ts * chore: add cdp connection to cy prompt (#31806) * chore: add cdp connection to cy prompt * minor fix * fix type build * try to fix build * Update packages/server/lib/browsers/browser-cri-client.ts Co-authored-by: Bill Glesias * Update packages/server/lib/browsers/browser-cri-client.ts Co-authored-by: Bill Glesias * do not support prompt in firefox or webkit * rework timing of lifecycle * refactor * fix tests * troubleshooting * troubleshooting * fix tests * additional troubleshooting * additional troubleshooting * additional troubleshooting * attempt to fix build * add back * debugging * debugging * debugging * debugging * clean up * fix unit tests * rework --------- Co-authored-by: Bill Glesias * chore: create infrastructure to support backend function in cy.prompt (#31803) * chore: add promptBackend as an additional Cypress-attached function * Update packages/app/src/runner/event-manager.ts * update types * fix types * fix spacing * refactor * additional refactor * fix type build * fix build * refactor * reword messages * fix * debugging * undo debugging * PR comment * fix tests * fix tests * fix tests * fix test * chore: add watcher for cy-prompt development (#31810) * chore: add watcher for cy-prompt development * test caching * fix types * chore: turn on beta deployments for cy-prompt * internal: (cy.prompt) handle errors better in the command definition (#31835) * internal: (cy.prompt) handle errors better in the command definition * internal: (cy.prompt) add timeout and handle loading errors more cleanly * add process environment variable * clean up test * update JSDoc * chore: handle errors (#31854) * chore: handle errors * Fix ts, add test * Fix error title * Fix ts * Fix ts * chores: (cy.prompt) refactor routing to support both app and driver (#31891) * chore: Share error utils with the cloud (#31887) * share error utils with cloud * additional rework * Fix command, add isOpenMode * Add / fix test * fix ts --------- Co-authored-by: Ryan Manuel * internal: (cy.prompt) add infrastructure to support a Get Code modal (#31904) * chore: (cy.prompt) add infrastructure to support a Get Code modal * fix tests * fix code paths * Update eject button styles * handle errors * update types * Update packages/server/lib/socket-base.ts * Fix cy test * update readme --------- Co-authored-by: estrada9166 * chore: (cy.prompt) refactor getTestsState to take a runnable id (#31965) * chore: (cy.prompt) refactor getTestsState to take a runnable id * fix tests * minor tweak * chore: (cy.prompt) add manifest for all of the cloud delivered files (#31922) * chore: (cy.prompt) add manifest for all of the cloud delivered files * fix tests and remove environment variables * update strategy * fix build * rework * require manifest * clean up * refactor * refactor * Update packages/server/lib/cloud/cy-prompt/CyPromptLifecycleManager.ts Co-authored-by: Matt Schile * fix test --------- Co-authored-by: Matt Schile * feat: add cy prompt more info needed modal (WIP) (#31970) * feat: add cy prompt more info needed modal * Reset promptStore * additional things exposed for more info * rework * fix tests * fix build * fix types * fix types * Update packages/app/src/runner/event-manager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * reefactor * chore: (cy.prompt) rework the file save lifecycle * rework types * add unit tests --------- Co-authored-by: estrada9166 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: (cy.prompt) ensure that we do not attach a vue ref to the react root in the cy.prompt modals (#32011) * fix: (studio) ensure that we do not attach a vue ref to the react root in the studio panel * fix test * chore: Handle cy-prompt error to the cloud (#32009) Co-authored-by: Ryan Manuel * chore: display prompt error message (#32016) * add createCloudRequest to cloudApi, handle errors during createCyPromptServer * render the get code button on failure * chore: update types * chore: move CT and browser error to cloud (#32077) * feat: (cy.prompt) give cy.prompt access to recording information (#32110) * feat: (cy.prompt) give cy.prompt access to recording information * undo bad refactor * undo bad refactor * undo bad refactor * rename * fix typo * Update packages/server/test/unit/modes/record_spec.js * Update packages/server/test/unit/modes/record_spec.js * Update packages/server/test/unit/modes/record_spec.js * Update packages/server/test/unit/modes/record_spec.js * Update packages/server/test/unit/modes/record_spec.js * Update cy-prompt-development.md * Update cy-prompt-development.md * Update cy-prompt-development.md * chore: add CYPRESS_INTERNAL_SIMULATE_OPEN_MODE to simulate running Cypress tests in open mode (#32114) * chore: (cy.prompt) ensure to strip out paths from all data when reporting errors in prompt (#32134) * fix: (cy.prompt) ensure to strip out paths from all data when reporting errors in prompt * refactor * update tests * fix logic error with protocol * add event manager to get code * Apply suggestions from code review * fix: (cy.prompt) improve the get project options performance by running promises in parallel (#32196) * fix: (cy.prompt) improve the get project options performance by running promises in parallel * add awaits in test * bump cache * Update packages/server/lib/cloud/studio/StudioLifecycleManager.ts * fix build * chore: cleanup * blank * Update trigger-publish-binary-pipeline.js * Update packages/server/test/unit/socket_spec.js * get rid of environment variable * fix: (cy.prompt) ensure to reset the prompt state when the event manager is torn down (indicating that we're no longer on the runner page) (#32301) * fix: (cy.prompt) ensure to reset the prompt state when the event manager is torn down (indicating that we're no longer on the runner page) * move test * fix lint issue * feat: (cy.prompt) introduce the concept of log collapse state being open/closed by default (#32262) * feat: (cy.prompt) introduce the concept of logs' collapse state being open/closed by default * update tests * rename * PR comments * fix test due to bad merge of develop * chore: Only allow experimentalPromptCommand within e2e config (#32435) * chore: Only allow experimentalPromptCommand within e2e config * Fix config * Update tests * Update test, update types * Fix test and types * fix tests * Add types * Update cli/types/cypress.d.ts Co-authored-by: Ryan Manuel --------- Co-authored-by: Ryan Manuel * Update workflows.yml * Add optional cyPromptManagerPromise property * Implement error handling in CyPromptManager Added a new method to handle errors uniformly in CyPromptManager. * Fix indentation in socket_spec.js * fix: (cy.prompt) handle when the prompt is executed by in CT or when the experiment is not enabled (#32470) * fix: (cy.prompt) handle when the prompt is executed by in CT or when the experiment is not enabled * Update packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts * Update packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts * update name of errors * Bump cache version to 9-15-2025 * update yarn.lock * fixes * fix snapshot * fix snapshot * internal: fix get code button to be purple with correct margin (#32504) * feat: (cy.prompt) update the types of prompt (#32529) * fix: move currentMoreInfoNeededModalInfo.onCancel to onClose (#32559) * internal: (cy.prompt) various improvements to error messages and time outs (#32582) * internal: (cy.prompt) various improvements to error messages and timeouts * fix test * remove dead code * Update packages/driver/src/cy/commands/prompt/index.ts * update prompt experiment description * fix build * fix tests * fix tests * fix test * update error message * Update packages/server/lib/experiments.ts Co-authored-by: Tim Griesser --------- Co-authored-by: Tim Griesser * internal: (cy.prompt) ensure that get code can properly work with prompts in cy.origin (#32596) * internal: (cy.prompt) ensure that get code can properly work with prompts in cy.origin * additional tests * additional tests * Apply suggestions from code review * code review comment * fix merge * fix merge * Update packages/data-context/graphql/schemaTypes/index.ts * update workflow * blank * persist binaries * chore: display custom link title (#32567) * chore: display custom link title * Add test * Pass docs as second argument of the error * Revert changes * Use openExternal for links --------- Co-authored-by: Jennifer Shehane * update * internal: (cy.prompt) do not retry on cert failures (#32624) * internal: (cy.prompt) do not retry on cert failures * tests and clean up * additional cleanup and add error message for prompt * fix unit tests * Update report_studio_error.ts * Update packages/network/lib/agent.ts * cursor comment * fix build * fix build * fix test * fix build * fix build * fix build * fix build * fix build * revert * Update packages/driver/src/cypress/error_messages.ts * Update packages/driver/cypress/e2e/commands/prompt/prompt-initialization-error.cy.ts * fix build * cursor comment * add changelog entry * clean up * Update packages/app/src/store/prompt-store.ts * Bump cache version to 10-3-2025 Updated cache version to trigger CI cache recreation. * Revise CHANGELOG for new features and fixes Updated changelog with new features and bug fixes. * index on feat/cy-prompt: 3cbcf6c336 Bump cache version to 10-3-2025 * index on feat/cy-prompt: 3cbcf6c336 Bump cache version to 10-3-2025 * index on feat/cy-prompt: 3cbcf6c336 Bump cache version to 10-3-2025 * blank * fix build --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Bill Glesias Co-authored-by: Alejandro Estrada Co-authored-by: Matt Schile Co-authored-by: Tim Griesser Co-authored-by: Jennifer Shehane Co-authored-by: Jennifer Shehane Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com> --- .circleci/cache-version.txt | 2 +- .circleci/src/pipeline/@pipeline.yml | 2 +- .circleci/src/pipeline/workflows/@main.yml | 4 +- cli/CHANGELOG.md | 1 + cli/types/cypress.d.ts | 68 +- guides/cy-prompt-development.md | 52 ++ .../cypress/e2e/runner/event-manager.cy.ts | 17 + .../app/src/prompt/PromptErrorMessage.vue | 55 ++ .../app/src/prompt/PromptGetCodeModal.vue | 145 ++++ .../src/prompt/PromptMoreInfoNeededModal.vue | 146 ++++ packages/app/src/prompt/prompt-app-types.ts | 50 ++ .../app/src/runner/SpecRunnerOpenMode.vue | 14 + packages/app/src/runner/event-manager.ts | 54 +- packages/app/src/runner/index.ts | 2 +- packages/app/src/store/prompt-store.ts | 59 ++ packages/config/src/options.ts | 17 + .../test/__snapshots__/index.spec.ts.snap | 3 + packages/config/test/project/utils.spec.ts | 2 + packages/data-context/schemas/schema.graphql | 1 + packages/data-context/src/DataActions.ts | 7 + .../src/actions/CurrentRecordingActions.ts | 17 + .../src/actions/ProjectActions.ts | 1 + packages/data-context/src/actions/index.ts | 1 + .../data-context/src/data/coreDataShape.ts | 10 +- .../src/sources/HtmlDataSource.ts | 2 +- .../actions/CurrentRecordingActions.spec.ts | 27 + packages/driver/cypress.config.ts | 3 +- .../cypress/e2e/commands/navigation.cy.js | 12 +- .../prompt/prompt-initialization-error.cy.ts | 58 ++ .../cypress/e2e/commands/prompt/prompt.cy.ts | 35 + .../cypress/e2e/cypress/error_utils.cy.ts | 21 + .../e2e/e2e/origin/commands/misc.cy.ts | 2 +- .../cypress/e2e/e2e/origin/patches.cy.ts | 62 +- packages/driver/cypress/fixtures/prompt.html | 11 + packages/driver/package.json | 2 + .../driver/src/cross-origin/communicator.ts | 2 +- packages/driver/src/cross-origin/cypress.ts | 9 +- .../driver/src/cross-origin/events/socket.ts | 36 +- packages/driver/src/cy/commands/files.ts | 3 +- packages/driver/src/cy/commands/index.ts | 3 + packages/driver/src/cy/commands/navigation.ts | 28 +- .../driver/src/cy/commands/prompt/index.ts | 246 ++++++ .../cy/commands/prompt/prompt-driver-types.ts | 113 +++ .../src/cy/commands/querying/querying.ts | 6 +- .../driver/src/cy/commands/sessions/index.ts | 4 + packages/driver/src/cy/logGroup.ts | 1 + packages/driver/src/cypress.ts | 62 +- packages/driver/src/cypress/error_messages.ts | 39 + packages/driver/src/cypress/error_utils.ts | 39 +- packages/driver/src/cypress/log.ts | 3 +- packages/driver/src/cypress/runner.ts | 4 +- packages/driver/src/cypress/stack_utils.ts | 5 + packages/driver/types/cy/logGroup.d.ts | 2 + packages/driver/types/cypress/log.d.ts | 4 + .../driver/types/internal-types-lite.d.ts | 5 +- packages/driver/types/internal-types.d.ts | 1 + packages/errors/src/errors.ts | 13 + .../EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY.ansi | 7 + .../errors/test/visualSnapshotErrors.spec.ts | 6 + .../frontend-shared/src/locales/en-US.json | 4 + .../cypress/e2e/config-warning.cy.ts | 22 + packages/reporter/cypress/e2e/commands.cy.ts | 8 + .../reporter/cypress/e2e/test_errors.cy.ts | 17 + packages/reporter/cypress/support/utils.ts | 1 + packages/reporter/package.json | 6 +- .../reporter/src/commands/command-model.ts | 14 +- packages/reporter/src/commands/command.cy.tsx | 120 +++ packages/reporter/src/commands/command.tsx | 58 +- packages/reporter/src/commands/commands.scss | 13 + packages/reporter/src/errors/err-model.ts | 4 + packages/reporter/src/errors/test-error.tsx | 7 +- .../src/instruments/instrument-model.ts | 7 + packages/reporter/src/lib/events.ts | 4 + .../server/lib/browsers/browser-cri-client.ts | 53 +- packages/server/lib/browsers/chrome.ts | 14 +- packages/server/lib/browsers/electron.ts | 15 +- packages/server/lib/browsers/firefox.ts | 4 + packages/server/lib/browsers/index.ts | 8 +- packages/server/lib/browsers/types.ts | 6 +- packages/server/lib/browsers/webkit.ts | 4 + .../api/cy-prompt/get_cy_prompt_bundle.ts | 91 +++ .../api/cy-prompt/post_cy_prompt_session.ts | 31 + .../api/cy-prompt/report_cy_prompt_error.ts | 117 +++ packages/server/lib/cloud/api/index.ts | 2 +- .../cloud/api/studio/post_studio_session.ts | 2 +- .../cy-prompt/CyPromptLifecycleManager.ts | 297 +++++++ .../lib/cloud/cy-prompt/CyPromptManager.ts | 152 ++++ .../cy-prompt/ensure_cy_prompt_bundle.ts | 54 ++ .../lib/cloud/network/is_retryable_error.ts | 2 +- .../network/non_retriable_cert_error_codes.ts | 16 + packages/server/lib/cloud/routes.ts | 2 + .../cloud/studio/StudioLifecycleManager.ts | 9 +- packages/server/lib/experiments.ts | 2 + packages/server/lib/modes/record.ts | 4 + packages/server/lib/modes/run.ts | 4 +- packages/server/lib/open_project.ts | 4 + packages/server/lib/project-base.ts | 23 +- packages/server/lib/routes.ts | 15 +- packages/server/lib/socket-base.ts | 69 +- packages/server/lib/socket-ct.ts | 21 + packages/server/lib/socket-e2e.ts | 2 +- .../cloud/cy-prompt/test-cy-prompt.ts | 32 + .../unit/browsers/browser-cri-client_spec.ts | 57 +- .../test/unit/browsers/browsers_spec.ts | 13 + .../server/test/unit/browsers/chrome_spec.js | 76 ++ .../test/unit/browsers/electron_spec.js | 47 +- .../cy-prompt/get_cy_prompt_bundle_spec.ts | 298 +++++++ .../cy-prompt/post_cy_prompt_session_spec.ts | 58 ++ .../cy-prompt/report_cy_prompt_error_spec.ts | 292 +++++++ .../cloud/api/put_protocol_artifact_spec.ts | 2 +- .../api/studio/get_studio_bundle_spec.ts | 7 +- .../api/studio/report_studio_error_spec.ts | 3 + .../CyPromptLifecycleManager_spec.ts | 741 ++++++++++++++++++ .../cloud/cy-prompt/CyPromptManager_spec.ts | 139 ++++ .../cy-prompt/ensure_cy_prompt_bundle_spec.ts | 104 +++ .../server/test/unit/modes/record_spec.js | 108 ++- .../server/test/unit/open_project_spec.js | 9 + packages/server/test/unit/project_spec.js | 74 ++ packages/server/test/unit/routes_spec.ts | 54 +- packages/server/test/unit/socket_spec.js | 721 +++++++++++------ packages/types/src/config.ts | 3 +- .../src/cy-prompt/cy-prompt-server-types.ts | 116 +++ packages/types/src/cy-prompt/index.ts | 19 + packages/types/src/index.ts | 2 + scripts/after-pack-hook.js | 15 + scripts/binary/binary-sources.js | 20 + .../binary/trigger-publish-binary-pipeline.js | 2 +- scripts/gulp/gulpfile.ts | 3 +- scripts/gulp/tasks/gulpCloudDeliveredTypes.ts | 136 +++- system-tests/__snapshots__/prompt_spec.ts.js | 70 ++ system-tests/__snapshots__/protocol_spec.js | 184 +++++ system-tests/__snapshots__/results_spec.ts.js | 1 + ...press-disabled-prompt-experiment.config.js | 7 + ...s-invalid-prompt-experiment-root.config.js | 7 + ...ypress-invalid-prompt-experiment.config.js | 17 + .../cypress/e2e/prompt.cy.js | 5 + .../cypress/plugins/.gitkeep | 0 .../cypress/support/.gitkeep | 0 system-tests/test/prompt_spec.ts | 14 + .../cache/darwin/snapshot-meta.json | 23 +- .../cache/linux/snapshot-meta.json | 23 +- .../cache/win32/snapshot-meta.json | 23 +- yarn.lock | 34 +- 143 files changed, 5857 insertions(+), 616 deletions(-) create mode 100644 guides/cy-prompt-development.md create mode 100644 packages/app/src/prompt/PromptErrorMessage.vue create mode 100644 packages/app/src/prompt/PromptGetCodeModal.vue create mode 100644 packages/app/src/prompt/PromptMoreInfoNeededModal.vue create mode 100644 packages/app/src/prompt/prompt-app-types.ts create mode 100644 packages/app/src/store/prompt-store.ts create mode 100644 packages/data-context/src/actions/CurrentRecordingActions.ts create mode 100644 packages/data-context/test/unit/actions/CurrentRecordingActions.spec.ts create mode 100644 packages/driver/cypress/e2e/commands/prompt/prompt-initialization-error.cy.ts create mode 100644 packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts create mode 100644 packages/driver/cypress/fixtures/prompt.html create mode 100644 packages/driver/src/cy/commands/prompt/index.ts create mode 100644 packages/driver/src/cy/commands/prompt/prompt-driver-types.ts create mode 100644 packages/errors/test/__snapshots__/EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY.ansi create mode 100644 packages/server/lib/cloud/api/cy-prompt/get_cy_prompt_bundle.ts create mode 100644 packages/server/lib/cloud/api/cy-prompt/post_cy_prompt_session.ts create mode 100644 packages/server/lib/cloud/api/cy-prompt/report_cy_prompt_error.ts create mode 100644 packages/server/lib/cloud/cy-prompt/CyPromptLifecycleManager.ts create mode 100644 packages/server/lib/cloud/cy-prompt/CyPromptManager.ts create mode 100644 packages/server/lib/cloud/cy-prompt/ensure_cy_prompt_bundle.ts create mode 100644 packages/server/lib/cloud/network/non_retriable_cert_error_codes.ts create mode 100644 packages/server/test/support/fixtures/cloud/cy-prompt/test-cy-prompt.ts create mode 100644 packages/server/test/unit/cloud/api/cy-prompt/get_cy_prompt_bundle_spec.ts create mode 100644 packages/server/test/unit/cloud/api/cy-prompt/post_cy_prompt_session_spec.ts create mode 100644 packages/server/test/unit/cloud/api/cy-prompt/report_cy_prompt_error_spec.ts create mode 100644 packages/server/test/unit/cloud/cy-prompt/CyPromptLifecycleManager_spec.ts create mode 100644 packages/server/test/unit/cloud/cy-prompt/CyPromptManager_spec.ts create mode 100644 packages/server/test/unit/cloud/cy-prompt/ensure_cy_prompt_bundle_spec.ts create mode 100644 packages/types/src/cy-prompt/cy-prompt-server-types.ts create mode 100644 packages/types/src/cy-prompt/index.ts create mode 100644 system-tests/__snapshots__/prompt_spec.ts.js create mode 100644 system-tests/projects/experimentalPromptCommand/cypress-disabled-prompt-experiment.config.js create mode 100644 system-tests/projects/experimentalPromptCommand/cypress-invalid-prompt-experiment-root.config.js create mode 100644 system-tests/projects/experimentalPromptCommand/cypress-invalid-prompt-experiment.config.js create mode 100644 system-tests/projects/experimentalPromptCommand/cypress/e2e/prompt.cy.js create mode 100644 system-tests/projects/experimentalPromptCommand/cypress/plugins/.gitkeep create mode 100644 system-tests/projects/experimentalPromptCommand/cypress/support/.gitkeep create mode 100644 system-tests/test/prompt_spec.ts diff --git a/.circleci/cache-version.txt b/.circleci/cache-version.txt index f23f4f6ae2..46785a31bf 100644 --- a/.circleci/cache-version.txt +++ b/.circleci/cache-version.txt @@ -1,2 +1,2 @@ # Bump this version to force CI to re-create the cache from scratch. -10-2-2025 +10-3-2025 diff --git a/.circleci/src/pipeline/@pipeline.yml b/.circleci/src/pipeline/@pipeline.yml index 17f4547441..94f58f9c05 100644 --- a/.circleci/src/pipeline/@pipeline.yml +++ b/.circleci/src/pipeline/@pipeline.yml @@ -118,7 +118,7 @@ commands: name: Set environment variable to determine whether or not to persist artifacts command: | echo "Setting SHOULD_PERSIST_ARTIFACTS variable" - echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "electron-37" ]]; then + echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "feat/cy-prompt" ]]; then export SHOULD_PERSIST_ARTIFACTS=true fi' >> "$BASH_ENV" # You must run `setup_should_persist_artifacts` command and be using bash before running this command diff --git a/.circleci/src/pipeline/workflows/@main.yml b/.circleci/src/pipeline/workflows/@main.yml index ed3dc7d9d1..a16e1189a9 100644 --- a/.circleci/src/pipeline/workflows/@main.yml +++ b/.circleci/src/pipeline/workflows/@main.yml @@ -5,7 +5,7 @@ linux-x64: - equal: [ develop, << pipeline.git.branch >> ] # use the following branch as well to ensure that v8 snapshot cache updates are fully tested - equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ] - - equal: [ 'electron-37', << pipeline.git.branch >> ] + - equal: [ 'feat/cy-prompt', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> @@ -309,7 +309,7 @@ linux-x64: - /^release\/\d+\.\d+\.\d+$/ # use the following branch as well to ensure that v8 snapshot cache updates are fully tested - 'update-v8-snapshot-cache-on-develop' - - 'chore/refactor_cli_to_ts' + - 'feat/cy-prompt' context: test-runner:npm-release requires: - ready-to-release diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index f008db8dcf..83ac1ec094 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,6 +7,7 @@ _Released 10/7/2025 (PENDING)_ - Cypress Studio is now available by default. You no longer have to set the `experimentalStudio` flag. Addresses [#30997](https://github.com/cypress-io/cypress/issues/30997). Addressed in [#32571](https://github.com/cypress-io/cypress/pull/32571). - Added the `--posix-exit-codes` flag for the `run` command. When this flag is passed, Cypress will exit with 1 if any tests fail, rather than the number of failed tests. Addresses [#32605](https://github.com/cypress-io/cypress/issues/32605) and [#24695](https://github.com/cypress-io/cypress/issues/24695). Addressed in [#32609](https://github.com/cypress-io/cypress/pull/32609). +- `cy.prompt` is now a reserved Cypress command, currently gated behind a feature flag that requires an invite from Cypress. This means any custom commands named 'prompt' will no longer work. Stay tuned for updates on when this feature will become more widely available. Addresses [#31826](https://github.com/cypress-io/cypress/issues/31826). **Bugfixes:** diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 15f4fa668f..84b0701d77 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ /// /// /// @@ -59,6 +58,9 @@ declare namespace Cypress { interface ObjectLike { [key: string]: any } + interface PromptOptions { + excludeFromAI?: Record + } interface Auth { username: string password: string @@ -684,22 +686,22 @@ declare namespace Cypress { Keyboard: { defaults(options: Partial): void Keys: { - DOWN: 'ArrowDown', - LEFT: 'ArrowLeft', - RIGHT: 'ArrowRight', - UP: 'ArrowUp', - END: 'End', - HOME: 'Home', - PAGEDOWN: 'PageDown', - PAGEUP: 'PageUp', - ENTER: 'Enter', - TAB: 'Tab', - BACKSPACE: 'Backspace', - SPACE: 'Space', - DELETE: 'Delete', - INSERT: 'Insert', - ESC: 'Escape', - }, + DOWN: 'ArrowDown' + LEFT: 'ArrowLeft' + RIGHT: 'ArrowRight' + UP: 'ArrowUp' + END: 'End' + HOME: 'Home' + PAGEDOWN: 'PageDown' + PAGEUP: 'PageUp' + ENTER: 'Enter' + TAB: 'Tab' + BACKSPACE: 'Backspace' + SPACE: 'Space' + DELETE: 'Delete' + INSERT: 'Insert' + ESC: 'Escape' + } } /** @@ -755,7 +757,7 @@ declare namespace Cypress { * Trigger action * @private */ - action: (action: string, ...args: any[]) => T + action: (action: string, ...args: any[]) => T /** * Load files @@ -1849,7 +1851,12 @@ declare namespace Cypress { * @see https://on.cypress.io/prevuntil */ prevUntil(element: E | JQuery, filter?: string, options?: Partial): Chainable> - + /** + * 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 /** * Read a file and yield its contents. * @@ -2898,8 +2905,8 @@ declare namespace Cypress { } type RetryStrategyWithModeSpecs = RetryStrategy & { - openMode: boolean; // defaults to false - runMode: boolean; // defaults to true + openMode: boolean // defaults to false + runMode: boolean // defaults to true } type RetryStrategy = @@ -2907,18 +2914,18 @@ declare namespace Cypress { | RetryStrategyDetectFlakeButAlwaysFailType interface RetryStrategyDetectFlakeAndPassOnThresholdType { - experimentalStrategy: "detect-flake-and-pass-on-threshold" + experimentalStrategy: 'detect-flake-and-pass-on-threshold' experimentalOptions?: { - maxRetries: number; // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 - passesRequired: number; // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 and <= maxRetries + maxRetries: number // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 + passesRequired: number // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 and <= maxRetries } } interface RetryStrategyDetectFlakeButAlwaysFailType { - experimentalStrategy: "detect-flake-but-always-fail" + experimentalStrategy: 'detect-flake-but-always-fail' experimentalOptions?: { - maxRetries: number; // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 - stopIfAnyPassed: boolean; // defaults to false if experimentalOptions is not provided + maxRetries: number // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 + stopIfAnyPassed: boolean // defaults to false if experimentalOptions is not provided } } interface ResolvedConfigOptions { @@ -3140,7 +3147,7 @@ declare namespace Cypress { * @see https://on.cypress.io/experiments#Experimental-CSP-Allow-List * @default false */ - experimentalCspAllowList: boolean | experimentalCspAllowedDirectives[], + experimentalCspAllowList: boolean | experimentalCspAllowedDirectives[] /** * Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode. * @default false @@ -3272,6 +3279,11 @@ declare namespace Cypress { * @default false */ experimentalOriginDependencies?: boolean + /** + * Enables support for `cy.prompt`, an AI-powered command that turns natural language steps into executable Cypress test code. + * @default false + */ + experimentalPromptCommand?: boolean } /** diff --git a/guides/cy-prompt-development.md b/guides/cy-prompt-development.md new file mode 100644 index 0000000000..b4c485edde --- /dev/null +++ b/guides/cy-prompt-development.md @@ -0,0 +1,52 @@ +# `cy.prompt` Development + +In production, the code used to facilitate the prompt command will be retrieved from the Cloud. + +To run against locally developed `cy.prompt`: + +- Clone the `cypress-services` repo + - Run `yarn && yarn all` + - Run `yarn watch` in `app/packages/cy-prompt` +- Set: + - `CYPRESS_INTERNAL_ENV=` (e.g. `staging` or `production` if you want to hit those deployments of `cypress-services` or `development` if you want to hit a locally running version of `cypress-services`) + - `CYPRESS_LOCAL_CY_PROMPT_PATH` to the path to the `cypress-services/app/packages/cy-prompt/dist/development` directory + +To run against a deployed version of `cy.prompt`: + +- Set: + - `CYPRESS_INTERNAL_ENV=` (e.g. `staging` or `production` if you want to hit those deployments of `cypress-services` or `development` if you want to hit a locally running version of `cypress-services`) + +Regardless of running against local or deployed `cy.prompt`: + +- Clone the `cypress` repo + - 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 within `e2e`. Ensure the project has the feature flag `cy-prompt` enabled. + +To run against a deployed version of `cy.prompt`: + +- Set: + - `CYPRESS_INTERNAL_ENV=` (e.g. `staging` or `production` if you want to hit those deployments of `cypress-services` or `development` if you want to hit a locally running version of `cypress-services`) + +## Types + +The prompt bundle provides the types for the `app`, `driver`, and `server` interfaces that are used within the Cypress code. To incorporate the types into the code base, run: + +```sh +yarn gulp downloadPromptTypes +``` + +or to reference a local `cypress_services` repo: + +```sh +CYPRESS_LOCAL_CY_PROMPT_PATH= yarn gulp downloadPromptTypes +``` + +## Testing + +### Unit/Component Testing + +The code that supports cloud `cy.prompt` and lives in the `cypress` monorepo is unit, integration, and e2e tested in a similar fashion to the rest of the code in the repo. See the [contributing guide](https://github.com/cypress-io/cypress/blob/ad353fcc0f7fdc51b8e624a2a1ef4e76ef9400a0/CONTRIBUTING.md?plain=1#L366) for more specifics. + +The code that supports cloud `cy.prompt` and lives in the `cypress-services` monorepo has unit tests that live alongside the code in that monorepo. diff --git a/packages/app/cypress/e2e/runner/event-manager.cy.ts b/packages/app/cypress/e2e/runner/event-manager.cy.ts index ad78320cac..a99c5d5907 100644 --- a/packages/app/cypress/e2e/runner/event-manager.cy.ts +++ b/packages/app/cypress/e2e/runner/event-manager.cy.ts @@ -50,4 +50,21 @@ describe('event-manager', () => { cy.wrap(() => eventManager.reporterBus.listeners('runner:next').length).invoke('call').should('equal', 1) }) }) + + it('should reset the prompt store', () => { + loadSpec({ + filePath: 'hooks/basic.cy.js', + passCount: 2, + }) + + cy.window().then((win) => { + const eventManager = win.getEventManager() + + cy.spy(eventManager['promptStore'], 'resetState').as('resetState') + }) + + cy.visitApp(`specs`) + + cy.get('@resetState').should('have.been.calledOnce') + }) }) diff --git a/packages/app/src/prompt/PromptErrorMessage.vue b/packages/app/src/prompt/PromptErrorMessage.vue new file mode 100644 index 0000000000..d8428dc84c --- /dev/null +++ b/packages/app/src/prompt/PromptErrorMessage.vue @@ -0,0 +1,55 @@ + + + diff --git a/packages/app/src/prompt/PromptGetCodeModal.vue b/packages/app/src/prompt/PromptGetCodeModal.vue new file mode 100644 index 0000000000..b34a7b94d1 --- /dev/null +++ b/packages/app/src/prompt/PromptGetCodeModal.vue @@ -0,0 +1,145 @@ + + + diff --git a/packages/app/src/prompt/PromptMoreInfoNeededModal.vue b/packages/app/src/prompt/PromptMoreInfoNeededModal.vue new file mode 100644 index 0000000000..1336d9dca1 --- /dev/null +++ b/packages/app/src/prompt/PromptMoreInfoNeededModal.vue @@ -0,0 +1,146 @@ + + + diff --git a/packages/app/src/prompt/prompt-app-types.ts b/packages/app/src/prompt/prompt-app-types.ts new file mode 100644 index 0000000000..2839d75491 --- /dev/null +++ b/packages/app/src/prompt/prompt-app-types.ts @@ -0,0 +1,50 @@ +// Note: This file is owned by the cloud delivered +// `cy-prompt` bundle. It is downloaded and copied to the app. +// It should not be modified directly in the app. + +import type Emitter from 'component-emitter' + +export interface CypressInternal extends Cypress.Cypress { + backendRequestHandler: ( + backendRequestNamespace: string, + eventName: string, + ...args: any[] + ) => Promise + preserveRunState: (testId: string) => Promise +} + +export interface GetCodeModalContentsProps { + Cypress: CypressInternal + testId: string + logId: string + onClose: () => void +} + +export type GetCodeModalContentsShape = ( + props: GetCodeModalContentsProps +) => JSX.Element + +export interface CyPromptEventManager { + ws: Emitter + localBus: Emitter + rerunSpec: () => void +} + +export interface MoreInfoNeededModalContentsProps { + Cypress: CypressInternal + eventManager: CyPromptEventManager + testId: string + logId: string + onClose: () => void +} + +export type MoreInfoNeededModalContentsShape = ( + props: MoreInfoNeededModalContentsProps +) => JSX.Element + +export interface CyPromptAppDefaultShape { + // Purposefully do not use React in this signature to avoid conflicts when this type gets + // transferred to the Cypress app + GetCodeModalContents: GetCodeModalContentsShape + MoreInfoNeededModalContents: MoreInfoNeededModalContentsShape +} diff --git a/packages/app/src/runner/SpecRunnerOpenMode.vue b/packages/app/src/runner/SpecRunnerOpenMode.vue index 42660a4166..9849f4f60c 100644 --- a/packages/app/src/runner/SpecRunnerOpenMode.vue +++ b/packages/app/src/runner/SpecRunnerOpenMode.vue @@ -1,4 +1,14 @@