From abc829e5aaa48fd1eb3821a2786baa96fe092bf7 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:08:39 +0530 Subject: [PATCH 01/17] chore: playwirght e2e test setup --- .gitignore | 5 ++++ package-lock.json | 60 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 +++- playwright.config.ts | 41 ++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 playwright.config.ts diff --git a/.gitignore b/.gitignore index ac5bc13..f8a2ee8 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,8 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/package-lock.json b/package-lock.json index de6eaef..c5b1312 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "sharp": "^0.33.5" }, "devDependencies": { + "@playwright/test": "^1.47.2", "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", @@ -1943,6 +1944,21 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.47.2.tgz", + "integrity": "sha512-jTXRsoSPONAs8Za9QEQdyjFn+0ZQFjCiIztAIF6bi1HqhBzG9Ma7g1WotyiGqFSBRZjIEqMdT8RUlbk1QVhzCQ==", + "devOptional": true, + "dependencies": { + "playwright": "1.47.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@popperjs/core": { "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", @@ -8095,6 +8111,50 @@ "node": ">=8" } }, + "node_modules/playwright": { + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.47.2.tgz", + "integrity": "sha512-nx1cLMmQWqmA3UsnjaaokyoUpdVaaDhJhMoxX2qj3McpjnsqFHs516QAKYhqHAgOP+oCFTEOCOAaD1RgD/RQfA==", + "devOptional": true, + "dependencies": { + "playwright-core": "1.47.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.47.2.tgz", + "integrity": "sha512-3JvMfF+9LJfe16l7AbSmU555PaTl2tPyQsVInqm3id16pdDfvZ8TTZ/pyzmkbDrZTQefyzU7AIHlZqQnxpqHVQ==", + "devOptional": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", diff --git a/package.json b/package.json index 30d172f..20a21f7 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "prettier:format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css}\"", "test": "jest", "test:watch": "jest --watch", - "test:coverage": "jest --coverage" + "test:coverage": "jest --coverage", + "test:e2e": "npx playwright test", + "test:e2e-report": "npx playwright show-report" }, "dependencies": { "@emotion/react": "^11.13.3", @@ -28,6 +30,7 @@ "sharp": "^0.33.5" }, "devDependencies": { + "@playwright/test": "^1.47.2", "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..cff8fb9 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,41 @@ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + testDir: './tests', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + timeout: 30000, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + timeout: 30000, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + timeout: 30000, + }, + ], +}); From 91f4f96643e8c92b595fddfa6efe096ffc7c4ada Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:09:00 +0530 Subject: [PATCH 02/17] fix: env for backend service fix in docker compose --- docker-compose.dev.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 04a797b..155dd0c 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -15,7 +15,7 @@ services: depends_on: - dicedb environment: - - DICE_ADDR=dicedb:7379 + - DICEDB_ADDR=dicedb:7379 frontend: build: diff --git a/docker-compose.yml b/docker-compose.yml index 9b5bc81..e83c301 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: depends_on: - dicedb environment: - - DICE_ADDR=dicedb:7379 + - DICEDB_ADDR=dicedb:7379 frontend: build: From a54813ffa25cadf0df8e2f25ed8c95321b99f283 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:09:38 +0530 Subject: [PATCH 03/17] chore: modified jest file to look for rtl jest test cases only under src --- jest.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.ts b/jest.config.ts index 23cded0..c669372 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -8,6 +8,7 @@ const createJestConfig = nextJest({ // Add any custom config to be passed to Jest const config: Config = { + roots: ['/src'], coverageProvider: 'v8', testEnvironment: 'jsdom', moduleNameMapper: { From 32d764b882dfae89201953bf8bf7fb85fd6727af Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:09:58 +0530 Subject: [PATCH 04/17] fix: fixed existing tc after change in data-testid --- src/components/Shell/Shell.tsx | 2 +- src/components/Shell/__tests__/index.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Shell/Shell.tsx b/src/components/Shell/Shell.tsx index 96768ee..4dfc6aa 100644 --- a/src/components/Shell/Shell.tsx +++ b/src/components/Shell/Shell.tsx @@ -27,7 +27,7 @@ export default function Shell({ decreaseCommandsLeft }: ShellProps) { {output.map((line, index) => (
{line} diff --git a/src/components/Shell/__tests__/index.test.tsx b/src/components/Shell/__tests__/index.test.tsx index 1fd31f8..9d73ce4 100644 --- a/src/components/Shell/__tests__/index.test.tsx +++ b/src/components/Shell/__tests__/index.test.tsx @@ -60,7 +60,7 @@ describe('Shell Component', () => { const { cliInputElement, user, getByTestId } = setupTest(); await user.type(cliInputElement, 'EXEC{enter}'); - const terminalOutputElement = getByTestId('terminal-output'); + const terminalOutputElement = getByTestId('terminal-output-1'); expect(terminalOutputElement).toHaveTextContent( "(error) ERR unknown command 'EXEC'", ); From b32534b08fe887a27faad6907b48133caca12699 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:10:20 +0530 Subject: [PATCH 05/17] feat: added e2e test for GET, SET, DEL commands --- tests/playground.test.ts | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 tests/playground.test.ts diff --git a/tests/playground.test.ts b/tests/playground.test.ts new file mode 100644 index 0000000..d600808 --- /dev/null +++ b/tests/playground.test.ts @@ -0,0 +1,104 @@ +import { test, expect } from '@playwright/test'; +import type { Page } from '@playwright/test'; + +const runCommand = async (page: Page, cmd: string) => { + const cmdInput = page.getByTestId('shell-input'); + await cmdInput.fill(cmd); + await page.keyboard.press('Enter'); +}; + +test.describe('[Playground Component]', () => { + test.beforeEach(async ({ page }) => { + await page.goto('http://localhost:3000'); + const cmdInput = page.getByTestId('shell-input'); + await expect(cmdInput).toBeVisible(); + }); + + test('should execute SET command properly', async ({ page }) => { + let outputIdx = 0; + + // Happy case + await runCommand(page, 'SET foo bar'); + // Adding 2 to outputIndex after each command execution + // Reason: 2 items are added to output after each execution, 1st is command itself and 2nd is its result + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + 'OK', + ); + + // Error case: SET with wrong number of arguments + await runCommand(page, 'SET foo'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + "(error) ERR wrong number of arguments for 'set' command", + ); + }); + + test('should execute GET command properly', async ({ page }) => { + let outputIdx = 0; + + // Happy case + await runCommand(page, 'SET foo bar'); + outputIdx += 2; + await runCommand(page, 'GET foo'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + 'bar', + ); + + // Error case for wrong key get + await runCommand(page, 'GET foo1'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + '(nil)', + ); + + // Error case: GET with wrong number of arguments + await runCommand(page, 'GET foo bar'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + "(error) ERR wrong number of arguments for 'get' command", + ); + }); + + test('should execute DEL command properly', async ({ page }) => { + let outputIdx = 0; + + // Happy case + await runCommand(page, 'SET foo bar'); + outputIdx += 2; + await runCommand(page, 'GET foo'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + 'bar', + ); + await runCommand(page, 'DEL foo'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + '1', + ); + await runCommand(page, 'GET foo'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + // Getting back the deleted key should return (nil) output + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + '(nil)', + ); + + // Error case: DEL key which is not present + await runCommand(page, 'DEL bar'); + outputIdx += 2; + await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); + await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( + '0', + ); + }); +}); From 4bbc9c0b96b214ff17096dc56089bb8bc2300533 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:10:38 +0530 Subject: [PATCH 06/17] chore: updated readme with commands for e2e test --- README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bd5494f..27ba5d6 100644 --- a/README.md +++ b/README.md @@ -52,20 +52,20 @@ This will launch the app on [http://localhost:3000](http://localhost:3000). The 1. Update `docker-compose.yml` file with the following code: ```yaml -version: "3.8" +version: '3.8' services: dicedb: image: dicedb/dicedb:latest ports: - - "7379:7379" + - '7379:7379' backend: build: context: . dockerfile: Dockerfile_Backend ports: - - "8080:8080" + - '8080:8080' depends_on: - dicedb environment: @@ -144,6 +144,24 @@ To get the test coverage of the project, execute the following command: npm run test:coverage ``` +To run the E2E test cases, execute the following command: + +```bash +npm run test:e2e +``` + +To get the test report, execute the following command: + +```bash +npm run test:e2e-report +``` + +To run E2E test in interactive mode, execute the following command: + +```bash +npm run test:e2e -- --ui +``` + ## Project Structure The main components of the DiceDB Playground include: From bf094f24c720290a4506f13c789c0f9b8ca323ad Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 11:10:52 +0530 Subject: [PATCH 07/17] chore: added github workflow for playwright --- .github/workflows/playwright.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/playwright.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..4dc924d --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,28 @@ +# workflow to check if E2E testing is working properly + +name: Playwright Tests +on: + pull_request: + branches: + - master +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 From b1d683032a027f14a6e8e19d22fa7672f0aeea82 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Mon, 7 Oct 2024 13:09:57 +0530 Subject: [PATCH 08/17] chore: workflow renamed --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 4dc924d..8e1b4e7 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,6 +1,6 @@ # workflow to check if E2E testing is working properly -name: Playwright Tests +name: UI Integration Tests on: pull_request: branches: From 49ae4b82c332bb3707ab4785842e23d944b2d412 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Tue, 8 Oct 2024 11:05:47 +0530 Subject: [PATCH 09/17] chore: added webserver configuration to playwright config --- playwright.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/playwright.config.ts b/playwright.config.ts index cff8fb9..20d55e9 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -18,6 +18,12 @@ export default defineConfig({ trace: 'on-first-retry', }, + webServer: { + command: 'npm run dev', + url: 'http://127.0.0.1:3000', + reuseExistingServer: !process.env.CI, + }, + /* Configure projects for major browsers */ projects: [ { From 281a5b690c72240502c447bd697125a5e0686d74 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Tue, 8 Oct 2024 15:48:59 +0530 Subject: [PATCH 10/17] chore: moved playwright related stuff to playground web app --- apps/playground-web/.gitignore | 5 +++ apps/playground-web/package.json | 5 ++- .../playground-web/playwright.config.ts | 0 .../playground-web/tests}/playground.test.ts | 0 pnpm-lock.yaml | 43 ++++++++++++++++++- 5 files changed, 50 insertions(+), 3 deletions(-) rename playwright.config.ts => apps/playground-web/playwright.config.ts (100%) rename {tests => apps/playground-web/tests}/playground.test.ts (100%) diff --git a/apps/playground-web/.gitignore b/apps/playground-web/.gitignore index f886745..3057931 100644 --- a/apps/playground-web/.gitignore +++ b/apps/playground-web/.gitignore @@ -34,3 +34,8 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ \ No newline at end of file diff --git a/apps/playground-web/package.json b/apps/playground-web/package.json index 1482284..9e636e3 100644 --- a/apps/playground-web/package.json +++ b/apps/playground-web/package.json @@ -14,7 +14,9 @@ "prettier:format": "prettier -c ../../.prettierrc --write \"**/*.{js,jsx,ts,tsx,json,css}\"", "test": "jest", "test:watch": "jest --watch", - "test:coverage": "jest --coverage" + "test:coverage": "jest --coverage", + "test:e2e": "npx playwright test", + "test:e2e-report": "npx playwright show-report" }, "dependencies": { "@emotion/react": "^11.13.3", @@ -32,6 +34,7 @@ "@dicedb/ui": "workspace:*" }, "devDependencies": { + "@playwright/test": "^1.47.2", "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", diff --git a/playwright.config.ts b/apps/playground-web/playwright.config.ts similarity index 100% rename from playwright.config.ts rename to apps/playground-web/playwright.config.ts diff --git a/tests/playground.test.ts b/apps/playground-web/tests/playground.test.ts similarity index 100% rename from tests/playground.test.ts rename to apps/playground-web/tests/playground.test.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c2c16f..8e7e7b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,7 +43,7 @@ importers: version: 0.446.0(react@18.3.1) next: specifier: 14.2.13 - version: 14.2.13(@babel/core@7.25.7)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 14.2.13(@babel/core@7.25.7)(@playwright/test@1.47.2)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) package.json: specifier: ^2.0.1 version: 2.0.1 @@ -69,6 +69,9 @@ importers: '@dicedb/typescript-config': specifier: workspace:* version: link:../../tooling/typescript-config + '@playwright/test': + specifier: ^1.47.2 + version: 1.47.2 '@testing-library/dom': specifier: ^10.4.0 version: 10.4.0 @@ -912,6 +915,11 @@ packages: resolution: {integrity: sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + '@playwright/test@1.47.2': + resolution: {integrity: sha512-jTXRsoSPONAs8Za9QEQdyjFn+0ZQFjCiIztAIF6bi1HqhBzG9Ma7g1WotyiGqFSBRZjIEqMdT8RUlbk1QVhzCQ==} + engines: {node: '>=18'} + hasBin: true + '@popperjs/core@2.11.8': resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} @@ -2235,6 +2243,11 @@ packages: fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -3381,6 +3394,16 @@ packages: resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} engines: {node: '>=8'} + playwright-core@1.47.2: + resolution: {integrity: sha512-3JvMfF+9LJfe16l7AbSmU555PaTl2tPyQsVInqm3id16pdDfvZ8TTZ/pyzmkbDrZTQefyzU7AIHlZqQnxpqHVQ==} + engines: {node: '>=18'} + hasBin: true + + playwright@1.47.2: + resolution: {integrity: sha512-nx1cLMmQWqmA3UsnjaaokyoUpdVaaDhJhMoxX2qj3McpjnsqFHs516QAKYhqHAgOP+oCFTEOCOAaD1RgD/RQfA==} + engines: {node: '>=18'} + hasBin: true + pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} @@ -5166,6 +5189,10 @@ snapshots: picocolors: 1.1.0 tslib: 2.6.2 + '@playwright/test@1.47.2': + dependencies: + playwright: 1.47.2 + '@popperjs/core@2.11.8': {} '@rushstack/eslint-patch@1.5.1': {} @@ -6888,6 +6915,9 @@ snapshots: fs.realpath@1.0.0: {} + fsevents@2.3.2: + optional: true + fsevents@2.3.3: optional: true @@ -8006,7 +8036,7 @@ snapshots: netmask@2.0.2: {} - next@14.2.13(@babel/core@7.25.7)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next@14.2.13(@babel/core@7.25.7)(@playwright/test@1.47.2)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@next/env': 14.2.13 '@swc/helpers': 0.5.5 @@ -8027,6 +8057,7 @@ snapshots: '@next/swc-win32-arm64-msvc': 14.2.13 '@next/swc-win32-ia32-msvc': 14.2.13 '@next/swc-win32-x64-msvc': 14.2.13 + '@playwright/test': 1.47.2 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -8322,6 +8353,14 @@ snapshots: dependencies: find-up: 4.1.0 + playwright-core@1.47.2: {} + + playwright@1.47.2: + dependencies: + playwright-core: 1.47.2 + optionalDependencies: + fsevents: 2.3.2 + pluralize@8.0.0: {} postcss-import@15.1.0(postcss@8.4.31): From 8ea580faf71b8b796c3031bc66c0edf27fcec7f9 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Tue, 8 Oct 2024 16:28:15 +0530 Subject: [PATCH 11/17] chore: added changes in top level package and turbo project --- package.json | 3 ++- turbo.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 62fd8a0..5e30183 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "lint": "turbo lint", "format": "prettier -c ./.prettierrc --write \"**/*.{js,jsx,ts,tsx,json,css}\"", "check:format": "prettier -c ./.prettierrc \"**/*.{js,jsx,ts,tsx,json,css}\"", - "test": "turbo test" + "test": "turbo test", + "test:e2e": "turbo test:e2e" }, "devDependencies": { "prettier": "^3.2.5", diff --git a/turbo.json b/turbo.json index e4f97c8..69514b4 100644 --- a/turbo.json +++ b/turbo.json @@ -24,6 +24,7 @@ "test:watch": { "cache": false, "persistent": true - } + }, + "test:e2e": {} } } From c00b3661b5fbbf46e64dbfa4f4f7201f12da3398 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Tue, 8 Oct 2024 16:33:24 +0530 Subject: [PATCH 12/17] refactor: added integration test in existing workflow --- .github/workflows/lint-build-test.yml | 6 ++++++ .github/workflows/playwright.yml | 28 --------------------------- 2 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/playwright.yml diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index cf955b1..ab0e30d 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -62,3 +62,9 @@ jobs: - name: Test run: pnpm test + + - name: Install Playwright browsers + run: npx playwright install --with-deps + + - name: UI Integration Tests + run: npx playwright test diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml deleted file mode 100644 index 8e1b4e7..0000000 --- a/.github/workflows/playwright.yml +++ /dev/null @@ -1,28 +0,0 @@ -# workflow to check if E2E testing is working properly - -name: UI Integration Tests -on: - pull_request: - branches: - - master -jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v4 - if: ${{ !cancelled() }} - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 From 078f694089cbb90aeca077ae14747f0451fed532 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Tue, 8 Oct 2024 16:35:28 +0530 Subject: [PATCH 13/17] chore: readme update --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 43259ae..30dc19f 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,14 @@ cd alloy pnpm test:watch ``` +### Integration Test + +To run E2E test, run the following command: + +``` +pnpm test:e2e +``` + ### Formatting To format all apps and packages, run the following command: From d1cda29d48902ac92f87332ce44bba944b7d0c1e Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Tue, 8 Oct 2024 17:42:07 +0530 Subject: [PATCH 14/17] fix: ignore playwright test in case of test command run --- apps/playground-web/jest.config.mjs | 1 - apps/playground-web/package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/playground-web/jest.config.mjs b/apps/playground-web/jest.config.mjs index 0d388c6..d6d8657 100644 --- a/apps/playground-web/jest.config.mjs +++ b/apps/playground-web/jest.config.mjs @@ -10,7 +10,6 @@ const createJestConfig = nextJest({ * @type {import('@jest').Config} */ const config = { - roots: ['/src'], coverageProvider: 'v8', testEnvironment: 'jsdom', moduleNameMapper: { diff --git a/apps/playground-web/package.json b/apps/playground-web/package.json index 9e636e3..bd5ff70 100644 --- a/apps/playground-web/package.json +++ b/apps/playground-web/package.json @@ -12,7 +12,7 @@ "lint": "eslint . --ext js,jsx,ts,tsx", "type-check": "tsc --noEmit", "prettier:format": "prettier -c ../../.prettierrc --write \"**/*.{js,jsx,ts,tsx,json,css}\"", - "test": "jest", + "test": "jest --testPathIgnorePatterns=\"/tests/\"", "test:watch": "jest --watch", "test:coverage": "jest --coverage", "test:e2e": "npx playwright test", From bd8f0cf82f18897f7d4e623cb55e3d2f8e4d9e66 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Wed, 9 Oct 2024 10:33:33 +0530 Subject: [PATCH 15/17] fix: workflow command fixes --- .github/workflows/lint-build-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index ab0e30d..dcdd559 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -64,7 +64,7 @@ jobs: run: pnpm test - name: Install Playwright browsers - run: npx playwright install --with-deps + run: pnpm exec playwright install --with-deps - name: UI Integration Tests - run: npx playwright test + run: pnpm test:e2e From 64724952bc5699ad124c0569fdddc2d7e982dec2 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Wed, 9 Oct 2024 10:38:31 +0530 Subject: [PATCH 16/17] chore: added env variable CI in workflow --- .github/workflows/lint-build-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index dcdd559..cd41bff 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -15,6 +15,8 @@ jobs: # env: # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} # TURBO_TEAM: ${{ vars.TURBO_TEAM }} + env: + CI = true steps: - name: Check out code From 54f3150262338ebae32dd8f4543cdb9cf375c1c8 Mon Sep 17 00:00:00 2001 From: Sanketmundada Date: Wed, 9 Oct 2024 13:51:23 +0530 Subject: [PATCH 17/17] fix: removed env from workflow --- .github/workflows/lint-build-test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index cd41bff..dcdd559 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -15,8 +15,6 @@ jobs: # env: # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} # TURBO_TEAM: ${{ vars.TURBO_TEAM }} - env: - CI = true steps: - name: Check out code