diff --git a/.github/workflows/playwright-pizzashop.yml b/.github/workflows/playwright-pizzashop.yml new file mode 100644 index 0000000..79dcbbb --- /dev/null +++ b/.github/workflows/playwright-pizzashop.yml @@ -0,0 +1,46 @@ +name: Playwright Pizza Shop + +on: [pull_request] + +jobs: + vercel-pizza: + name: Wait for Vercel (pizza-shop) + runs-on: ubuntu-latest + timeout-minutes: 15 + outputs: + preview_url: ${{ steps.waitForVercelPreviewDeployment.outputs.url }} + steps: + - name: Wait for Vercel pizza environment to be ready + uses: patrickedqvist/wait-for-vercel-preview@dca4940010f36d2d44caa487087a09b57939b24a #v1.3.1 + id: waitForVercelPreviewDeployment + with: + environment: "Preview – monorepo-testing-workshop-pizza-shop" + token: ${{ secrets.GITHUB_TOKEN }} + check_interval: 30 + max_timeout: 400 + + playwright-pizza: + needs: vercel-pizza + 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: Setup node + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1 + with: + node-version: 18 + cache: "pnpm" + + - name: Show preview url + run: echo ${{ needs.vercel-pizza.outputs.preview_url }} + + - name: Run Playwright tests + run: pnpm --filter pizza-shop run e2e + env: + PLAYWRIGHT_BASE_URL: ${{ needs.vercel-pizza.outputs.preview_url }} \ No newline at end of file diff --git a/.github/workflows/playwright-ta.yml b/.github/workflows/playwright-ta.yml index db73c80..10c9823 100644 --- a/.github/workflows/playwright-ta.yml +++ b/.github/workflows/playwright-ta.yml @@ -1,35 +1,46 @@ -# 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) + runs-on: ubuntu-latest + timeout-minutes: 15 + outputs: + preview_url: ${{ steps.waitForVercelPreviewDeployment.outputs.url }} + steps: + - name: Wait for Vercel test automation environment to be ready + uses: patrickedqvist/wait-for-vercel-preview@dca4940010f36d2d44caa487087a09b57939b24a #v1.3.1 + id: waitForVercelPreviewDeployment + with: + environment: "Preview – monorepo-testing-workshop-test-automation" + token: ${{ secrets.GITHUB_TOKEN }} + check_interval: 30 + max_timeout: 400 -# 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: 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: Run Playwright tests -# run: pnpm --filter test-automation run e2e -# env: -# PLAYWRIGHT_BASE_URL: ${{ needs.vercel-ta.outputs.preview_url }} + 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: 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: Run Playwright tests + run: pnpm --filter test-automation run e2e + env: + PLAYWRIGHT_BASE_URL: ${{ needs.vercel-ta.outputs.preview_url }} diff --git a/.gitignore b/.gitignore index 79e0077..37fda49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - +.idea +.vscode # dependencies node_modules .pnp diff --git a/apps/pizza-shop/src/app/page.tsx b/apps/pizza-shop/src/app/page.tsx index e75dbf8..7ba08df 100644 --- a/apps/pizza-shop/src/app/page.tsx +++ b/apps/pizza-shop/src/app/page.tsx @@ -11,6 +11,16 @@ const LINKS = [ href: "https://www.google.com/search?q=hawaii+pizza", description: "Italians love it!", }, + { + title: "🇮🇹 Pizza Calzone!", + href: "https://www.google.com/search?q=hawaii+calzone", + description: "Ghislain loves this!", + }, + { + title: "🇮🇹 Pizza Testy!", + href: "https://www.google.com/search?q=hawaii+calzone", + description: "Ghislain loves this!", + }, ]; export default function Page(): JSX.Element { diff --git a/apps/test-automation/playwright.config.ts b/apps/test-automation/playwright.config.ts index 1976924..963cc77 100644 --- a/apps/test-automation/playwright.config.ts +++ b/apps/test-automation/playwright.config.ts @@ -8,7 +8,7 @@ export default defineConfig({ baseURL: process.env.PLAYWRIGHT_BASE_URL ? process.env.PLAYWRIGHT_BASE_URL : "http://127.0.0.1:3000", - trace: "on-first-retry", + trace: "retain-on-failure", }, projects: [ { diff --git a/apps/test-automation/src/app/contact/page.tsx b/apps/test-automation/src/app/contact/page.tsx index 6c304f8..f1f2f12 100644 --- a/apps/test-automation/src/app/contact/page.tsx +++ b/apps/test-automation/src/app/contact/page.tsx @@ -1,16 +1,10 @@ -import { Heading } from "ui"; +import { Heading , Button} from "ui"; export default function Page(): JSX.Element { return (
- +
); } diff --git a/apps/test-automation/src/app/page.tsx b/apps/test-automation/src/app/page.tsx index 6ea2ca1..9da47da 100644 --- a/apps/test-automation/src/app/page.tsx +++ b/apps/test-automation/src/app/page.tsx @@ -11,6 +11,11 @@ const LINKS = [ href: "/contact", description: "Contact us for even better deals", }, + { + title: "💌 Ghislain is amazing", + href: "/Ghislain", + description: "Ghislain is amazing", + }, ]; export default function Page(): JSX.Element { diff --git a/apps/test-automation/tests/seo.spec.ts b/apps/test-automation/tests/seo.spec.ts index c6d5e4d..0dabd3c 100644 --- a/apps/test-automation/tests/seo.spec.ts +++ b/apps/test-automation/tests/seo.spec.ts @@ -1,3 +1,6 @@ -import { shouldHavePageTitle } from "e2e-tests/tests/seo"; +import { shouldHavePageTitle, shouldNavigateToContactPage } from "e2e-tests/tests/seo"; shouldHavePageTitle({ pageTitle: "Test Automation" }); + +shouldNavigateToContactPage() + diff --git a/packages/e2e-tests/tests/seo.ts b/packages/e2e-tests/tests/seo.ts index 76ac93d..41c0baf 100644 --- a/packages/e2e-tests/tests/seo.ts +++ b/packages/e2e-tests/tests/seo.ts @@ -6,3 +6,12 @@ export const shouldHavePageTitle = (options: { pageTitle: string }) => { await expect(page).toHaveTitle(options.pageTitle); }); }; + + +//QUESTION: Store locators in apps or in testcase? +export const shouldNavigateToContactPage = () => { + return test("Should navigate to contact page and click me button", async ({ page }) => { + await page.goto("/contact/"); + await page.locator(`data-testid=contact-button`).click(); + }); +}; diff --git a/packages/ui/src/atoms/button.test.tsx b/packages/ui/src/atoms/button.test.tsx new file mode 100644 index 0000000..0a33ab2 --- /dev/null +++ b/packages/ui/src/atoms/button.test.tsx @@ -0,0 +1,9 @@ +import { expect, it } from "vitest"; +import { render, screen } from "@testing-library/react"; +import {Button} from "./button.tsx"; + +it("renders heading", () => { + render( + ); +} diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx index 9080102..eb4b3dc 100644 --- a/packages/ui/src/index.tsx +++ b/packages/ui/src/index.tsx @@ -3,6 +3,7 @@ import "./styles.css"; // components export * from "./atoms/heading"; +export * from "./atoms/button"; export * from "./molecules/card"; export * from "./organisms/deals"; export * from "./templates/main-view"; diff --git a/packages/ui/src/molecules/card.test.tsx b/packages/ui/src/molecules/card.test.tsx new file mode 100644 index 0000000..6dcf922 --- /dev/null +++ b/packages/ui/src/molecules/card.test.tsx @@ -0,0 +1,11 @@ +// import { expect, it } from "vitest"; +// import { render, screen } from "@testing-library/react"; +// import { Card } from "./card.tsx"; +// +// it("renders heading", () => { +// render(); +// const headline = screen.getByText(/Hello/i); +// expect(headline).not.toBeNull(); +// }); diff --git a/turbo.json b/turbo.json index 45ecc4b..aec3416 100644 --- a/turbo.json +++ b/turbo.json @@ -17,6 +17,11 @@ "clean": { "cache": false }, + "test": { + "dependsOn": ["^build"], + "cache": true, + "inputs": ["src/**/*.tsx", "src/**/ *.ts"] + }, "e2e": { "cache": false, "persistent": true,