diff --git a/.github/workflows/playwright-ta.yml b/.github/workflows/playwright-ta.yml index db73c80..47a533c 100644 --- a/.github/workflows/playwright-ta.yml +++ b/.github/workflows/playwright-ta.yml @@ -1,35 +1,43 @@ -# name: Playwright Test Automation +name: Playwright Test Automation -# on: [pull_request] +on: [pull_request] -# jobs: -# vercel-ta: -# name: Wait for Vercel (test-automation) -# WRITE YOUR CODE HERE -# USE: https://github.com/patrickedqvist/wait-for-vercel-preview +jobs: + vercel-ta: + name: Wait for Vercel (test-automation) + steps: + - name: Waiting for 200 from the Vercel Preview + uses: Spijkerj/monorepo-testing-workshop + id: waitFor200 + with: + token: ${{ secrets.test }} + max_timeout: 60 + # access preview url + - run: echo ${{steps.waitFor200.outputs.url}} + # USE: https://github.com/patrickedqvist/wait-for-vercel-preview -# playwright-ta: -# needs: vercel-ta -# runs-on: ubuntu-latest -# timeout-minutes: 10 -# steps: -# - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0 +playwright-ta: + needs: vercel-ta + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0 -# - name: Pnpm install -# uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 #v2.4.0 -# with: -# run_install: true + - name: Pnpm install + uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 #v2.4.0 + with: + run_install: true -# - name: Setup node -# uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1 -# with: -# node-version: 18 -# cache: "pnpm" + - name: Setup node + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1 + with: + node-version: 18 + cache: "pnpm" -# - name: Show preview url -# run: echo ${{ needs.vercel-ta.outputs.preview_url }} + - name: Show preview url + run: echo ${{ needs.vercel-ta.outputs.preview_url }} -# - name: Run Playwright tests -# run: pnpm --filter test-automation run e2e -# env: -# PLAYWRIGHT_BASE_URL: ${{ needs.vercel-ta.outputs.preview_url }} + - name: Run Playwright tests + run: pnpm --filter test-automation run e2e + env: + PLAYWRIGHT_BASE_URL: ${{ needs.vercel-ta.outputs.preview_url }} diff --git a/apps/test-automation/tests/contact.spec.ts b/apps/test-automation/tests/contact.spec.ts new file mode 100644 index 0000000..c5044cc --- /dev/null +++ b/apps/test-automation/tests/contact.spec.ts @@ -0,0 +1,3 @@ +import { clickContactButton } from "e2e-tests/tests/contact"; + +clickContactButton(); diff --git a/apps/test-automation/tests/seo.spec.ts b/apps/test-automation/tests/seo.spec.ts index c6d5e4d..283625c 100644 --- a/apps/test-automation/tests/seo.spec.ts +++ b/apps/test-automation/tests/seo.spec.ts @@ -1,3 +1,3 @@ import { shouldHavePageTitle } from "e2e-tests/tests/seo"; -shouldHavePageTitle({ pageTitle: "Test Automation" }); +shouldHavePageTitle({ pageTitle: "Test Automation" }); \ No newline at end of file diff --git a/packages/e2e-tests/tests/contact.ts b/packages/e2e-tests/tests/contact.ts new file mode 100644 index 0000000..5eeb0ce --- /dev/null +++ b/packages/e2e-tests/tests/contact.ts @@ -0,0 +1,8 @@ +import { test } from "@playwright/test"; + +export const clickContactButton = () => { + return test("should have page title", async ({ page }) => { + await page.goto("/contact"); + await page.locator('[data-testid="contact-button"]').click(); + }); +}; diff --git a/turbo.json b/turbo.json index 45ecc4b..7488ad4 100644 --- a/turbo.json +++ b/turbo.json @@ -21,6 +21,10 @@ "cache": false, "persistent": true, "inputs": ["tests/**/*.ts"] + }, + "test": { + "cache": true, + "inputs": ["/**/*.ts", "/**/*.tsx"] } } }