diff --git a/.github/workflows/test-pr-multi-project.yml b/.github/workflows/test-pr-multi-project.yml new file mode 100644 index 0000000..64f6151 --- /dev/null +++ b/.github/workflows/test-pr-multi-project.yml @@ -0,0 +1,39 @@ +name: Test multi-project + +env: + MOMENTIC_API_KEY: ${{ secrets.MOMENTIC_API_KEY }} + +on: + pull_request: + +jobs: + run-tests: + name: Run all project tests + runs-on: ubuntu-latest + permissions: + contents: read + repository-projects: read + defaults: + run: + working-directory: ./multi-project-workspace-example + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + with: + version: 8 + - uses: actions/setup-node@v4 + with: + node-version: 21 + cache: "pnpm" + - name: Install dependencies + run: pnpm i + - name: Run specific marketing tests using project name and substring match + run: npx momentic@^1 run --filter marketing variable + env: + VAR_FROM_SHELL: test-var-from-shell + - name: Run all QA tests using config path + run: npx momentic@^1 run --config qa/momentic.config.yaml . + - name: Run dashboard tests using absolute path + run: | + cd apps/dashboard + npx momentic@^1 run google-search.test.yaml \ No newline at end of file diff --git a/momentic.config.yaml b/momentic.config.yaml index d1b2b84..cd73ba5 100644 --- a/momentic.config.yaml +++ b/momentic.config.yaml @@ -2,6 +2,8 @@ name: default include: - "**/*.test.yaml" - "**/*.module.yaml" +exclude: + - "multi-project-workspace-example/**/*" environments: - name: development baseUrl: https://momentic-github-actions-demo.vercel.app/ diff --git a/multi-project-workspace-example/apps/dashboard/google-search.test.yaml b/multi-project-workspace-example/apps/dashboard/google-search.test.yaml new file mode 100644 index 0000000..fa55d43 --- /dev/null +++ b/multi-project-workspace-example/apps/dashboard/google-search.test.yaml @@ -0,0 +1,24 @@ +fileType: momentic/test +id: cfa6eb04-a97e-42c0-aeaa-5de0bc3cac0d +name: google-search +baseUrl: https://google.com +schemaVersion: 1.0.18 +advanced: + disableAICaching: false + viewport: + width: 1920 + height: 1080 + browserType: Chromium +retries: 0 +steps: + - id: 980f048a-7ab1-4b8f-b55d-0a0f7b195283 + type: PRESET_ACTION + command: + id: e37b1fbc-bce3-4415-abd8-f5614db2b582 + clearContent: true + pressEnter: true + type: TYPE + target: + type: description + elementDescriptor: search bar + value: hello world diff --git a/multi-project-workspace-example/apps/dashboard/momentic.config.yaml b/multi-project-workspace-example/apps/dashboard/momentic.config.yaml new file mode 100644 index 0000000..32f49c7 --- /dev/null +++ b/multi-project-workspace-example/apps/dashboard/momentic.config.yaml @@ -0,0 +1,5 @@ +name: dashboard +include: + - "**/*.test.yaml" + - "**/*.module.yaml" + - "../../common/**/*.module.yaml" diff --git a/multi-project-workspace-example/apps/marketing/momentic.config.yaml b/multi-project-workspace-example/apps/marketing/momentic.config.yaml new file mode 100644 index 0000000..9d5719a --- /dev/null +++ b/multi-project-workspace-example/apps/marketing/momentic.config.yaml @@ -0,0 +1,11 @@ +name: marketing +include: + - "**/*.test.yaml" + - "**/*.module.yaml" + - "../../common/**/*.module.yaml" +environments: + - name: test + baseUrl: https://google.com + envFile: ../../test.env + envVariables: + VAR_FROM_SHELL: ${VAR_FROM_SHELL} diff --git a/multi-project-workspace-example/apps/marketing/variable-showcase.test.yaml b/multi-project-workspace-example/apps/marketing/variable-showcase.test.yaml new file mode 100644 index 0000000..a6f6d91 --- /dev/null +++ b/multi-project-workspace-example/apps/marketing/variable-showcase.test.yaml @@ -0,0 +1,29 @@ +fileType: momentic/test +id: 345ced8b-ba15-4681-9fab-ba5e8296aa28 +name: variable-showcase +schemaVersion: 1.0.18 +advanced: + disableAICaching: false + viewport: + width: 1920 + height: 1080 +retries: 0 +envs: + - name: test + default: true +steps: + - id: 1ab5e9b2-eb86-4b05-a20e-a47338d9ceeb + type: PRESET_ACTION + command: + id: f2e39d7f-db4a-4ce4-9cc9-22988c9cb83e + code: |- + assert(env.VAR_FROM_FILE === "test-var-from-file") + assert(env.INTERPOLATED_VAR_FROM_FILE === "test-var-from-file-default") + type: JAVASCRIPT + - id: b8f38734-b3ab-45a7-bbd1-bc790fee8cf5 + type: PRESET_ACTION + command: + id: 4b905660-e1d0-4209-b09c-f9d08598a167 + code: | + assert(env.VAR_FROM_SHELL === "test-var-from-shell") + type: JAVASCRIPT diff --git a/multi-project-workspace-example/common/practice-test-login.module.yaml b/multi-project-workspace-example/common/practice-test-login.module.yaml new file mode 100644 index 0000000..425134c --- /dev/null +++ b/multi-project-workspace-example/common/practice-test-login.module.yaml @@ -0,0 +1,33 @@ +fileType: momentic/module +schemaVersion: 1.0.18 +moduleId: a0575e3f-bba8-48a3-91f6-1fb77de5188b +name: practice-test-login +description: "" +enabled: true +steps: + - id: 4657574e-caab-4c1e-9f50-2dfa4a4b4927 + type: PRESET_ACTION + command: + id: 4f0c99f5-743d-4e21-b642-0d2772d32941 + clearContent: true + type: TYPE + target: + type: description + elementDescriptor: username textbox + value: student + - id: 42056ded-31aa-458e-82ec-c3a981172e6f + type: PRESET_ACTION + command: + id: 4b56e24d-d471-4123-8bb6-5ab1d04ad06e + clearContent: true + type: TYPE + target: + type: description + elementDescriptor: password textbox + value: Password123 + - id: d78e2d9c-9dff-4363-a9da-bc2222240258 + type: PRESET_ACTION + command: + id: da49a90d-d83d-460c-99c1-ae0005ff80c8 + type: PRESS + value: Enter diff --git a/multi-project-workspace-example/momentic.workspace.yaml b/multi-project-workspace-example/momentic.workspace.yaml new file mode 100644 index 0000000..0db251f --- /dev/null +++ b/multi-project-workspace-example/momentic.workspace.yaml @@ -0,0 +1,5 @@ +projects: + - qa + # immediate children directories of apps + - apps/* + diff --git a/multi-project-workspace-example/qa/momentic.config.yaml b/multi-project-workspace-example/qa/momentic.config.yaml new file mode 100644 index 0000000..8b8544c --- /dev/null +++ b/multi-project-workspace-example/qa/momentic.config.yaml @@ -0,0 +1,6 @@ +name: qa +include: + - "**/*.test.yaml" + - "**/*.module.yaml" + - ../common/**/*.module.yaml" +moduleCreationDir: ../common \ No newline at end of file diff --git a/multi-project-workspace-example/qa/practice-test-login.test.yaml b/multi-project-workspace-example/qa/practice-test-login.test.yaml new file mode 100644 index 0000000..14322d3 --- /dev/null +++ b/multi-project-workspace-example/qa/practice-test-login.test.yaml @@ -0,0 +1,39 @@ +fileType: momentic/test +id: 032132e8-0271-44d3-a439-5165d6c5e182 +name: practice-test-login +baseUrl: https://practicetestautomation.com/practice-test-login/ +schemaVersion: 1.0.18 +advanced: + disableAICaching: false + viewport: + width: 1920 + height: 1080 + browserType: Chromium +retries: 0 +steps: + - id: 4657574e-caab-4c1e-9f50-2dfa4a4b4927 + type: PRESET_ACTION + command: + id: 4f0c99f5-743d-4e21-b642-0d2772d32941 + clearContent: true + type: TYPE + target: + type: description + elementDescriptor: username textbox + value: student + - id: 42056ded-31aa-458e-82ec-c3a981172e6f + type: PRESET_ACTION + command: + id: 4b56e24d-d471-4123-8bb6-5ab1d04ad06e + clearContent: true + type: TYPE + target: + type: description + elementDescriptor: password textbox + value: Password123 + - id: d78e2d9c-9dff-4363-a9da-bc2222240258 + type: PRESET_ACTION + command: + id: da49a90d-d83d-460c-99c1-ae0005ff80c8 + type: PRESS + value: Enter diff --git a/multi-project-workspace-example/test.env b/multi-project-workspace-example/test.env new file mode 100644 index 0000000..1a415e3 --- /dev/null +++ b/multi-project-workspace-example/test.env @@ -0,0 +1,2 @@ +VAR_FROM_FILE=test-var-from-file +INTERPOLATED_VAR_FROM_FILE=${NON_EXISTENT:-test-var-from-file-default} \ No newline at end of file