diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 6d100d6e6828..6d90ad8674a4 100644 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -39,6 +39,7 @@ mainBuildFilters: &mainBuildFilters # use the following branch as well to ensure that v8 snapshot cache updates are fully tested - 'update-v8-snapshot-cache-on-develop' - 'update-chrome-stable-from-136.0.7103.113-beta-from-137.0.7151.40' + - 'feat/cy-prompt' # usually we don't build Mac app - it takes a long time # but sometimes we want to really confirm we are doing the right thing @@ -49,6 +50,7 @@ macWorkflowFilters: &darwin-workflow-filters - 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: [ 'feat/cy-prompt', << pipeline.git.branch >> ] - equal: [ 'update-chrome-stable-from-136.0.7103.113-beta-from-137.0.7151.40', @@ -64,6 +66,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters - 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: [ 'feat/cy-prompt', << pipeline.git.branch >> ] - equal: [ 'update-chrome-stable-from-136.0.7103.113-beta-from-137.0.7151.40', @@ -91,6 +94,7 @@ windowsWorkflowFilters: &windows-workflow-filters - 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: [ 'feat/cy-prompt', << pipeline.git.branch >> ] - equal: [ 'update-chrome-stable-from-136.0.7103.113-beta-from-137.0.7151.40', @@ -169,7 +173,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" != "update-chrome-stable-from-136.0.7103.113-beta-from-137.0.7151.40" ]]; then + echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "update-chrome-stable-from-136.0.7103.113-beta-from-137.0.7151.40" && "$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/guides/cy-prompt-development.md b/guides/cy-prompt-development.md new file mode 100644 index 000000000000..1eebbb52be62 --- /dev/null +++ b/guides/cy-prompt-development.md @@ -0,0 +1,53 @@ +# `cy.prompt` Development + +In production, the code used to facilitate the prompt command will be retrieved from the Cloud. While `cy.prompt` is still in its early stages it is hidden behind an environment variable: `CYPRESS_ENABLE_CY_PROMPT` but can also be run against local cloud prompt code via the environment variable: `CYPRESS_LOCAL_CY_PROMPT_PATH`. + +To run against locally developed `cy.prompt`: + +- Clone the `cypress-services` repo + - Run `yarn` + - 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`) + - `CYPRESS_ENABLE_CY_PROMPT=true` + +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 `e2e` config of the `cypress.config.js|ts` file. + +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/src/prompt/PromptGetCodeModal.vue b/packages/app/src/prompt/PromptGetCodeModal.vue new file mode 100644 index 000000000000..7c53f561909c --- /dev/null +++ b/packages/app/src/prompt/PromptGetCodeModal.vue @@ -0,0 +1,124 @@ + + + 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 000000000000..09014fc44d99 --- /dev/null +++ b/packages/app/src/prompt/prompt-app-types.ts @@ -0,0 +1,28 @@ +// Note: This file is owned by the cloud delivered +// cy prompt bundle. It is downloaded and copied here. +// It should not be modified directly here. + +export interface CypressInternal extends Cypress.Cypress { + backendRequestHandler: ( + backendRequestNamespace: string, + eventName: string, + ...args: any[] + ) => Promise +} + +export interface GetCodeModalContentsProps { + Cypress: CypressInternal + testId: string + logId: string + onClose: () => void +} + +export type GetCodeModalContentsShape = ( + props: GetCodeModalContentsProps +) => 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 +} diff --git a/packages/app/src/runner/SpecRunnerOpenMode.vue b/packages/app/src/runner/SpecRunnerOpenMode.vue index 89f720f76651..a5dfc452157d 100644 --- a/packages/app/src/runner/SpecRunnerOpenMode.vue +++ b/packages/app/src/runner/SpecRunnerOpenMode.vue @@ -1,4 +1,9 @@