From 0d27a2ae2903575100130bd0ab16f580bf588051 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Fri, 3 Jan 2025 14:39:31 -0500 Subject: [PATCH 01/14] Playwright tests --- .dockerignore | 5 ++ .github/workflows/playwright.yml | 27 +++++++ .gitignore | 5 ++ api.Dockerfile | 1 + api/server.mjs | 39 ++++++++- docker-compose.ent.override.yml | 14 ++++ docker-compose.yml | 40 ++++++++++ .../enterprise_response_sample.json | 0 .../enterprise_response_sample_seats.json | 0 .../organization_response_sample.json | 0 .../organization_response_sample_seats.json | 0 package-lock.json | 75 +++++++++++++++-- package.json | 6 +- playwright.config.ts | 80 +++++++++++++++++++ src/api/ExtractSeats.ts | 4 +- src/api/GitHubApi.ts | 4 +- tests/copilot.ent.spec.ts | 31 +++++++ tests/copilot.org.spec.ts | 30 +++++++ 18 files changed, 345 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 docker-compose.ent.override.yml create mode 100644 docker-compose.yml rename {src/assets => mock-data}/enterprise_response_sample.json (100%) rename {src/assets => mock-data}/enterprise_response_sample_seats.json (100%) rename {src/assets => mock-data}/organization_response_sample.json (100%) rename {src/assets => mock-data}/organization_response_sample_seats.json (100%) create mode 100644 playwright.config.ts create mode 100644 tests/copilot.ent.spec.ts create mode 100644 tests/copilot.org.spec.ts diff --git a/.dockerignore b/.dockerignore index 008ce69d..6c73176a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -13,3 +13,8 @@ dist/ .github/ Dockerfile *.md +azure-deploy/ +infra/ +playwright-report/ +test-results/ +test-results-docker/ \ No newline at end of file diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 00000000..43115c7e --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, 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: npm test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index 7b149af8..7dfed31a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,8 @@ pnpm-debug.log* api/public test.http +/test-results/ +/test-results-docker/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ \ No newline at end of file diff --git a/api.Dockerfile b/api.Dockerfile index dfe5c34c..98ca5ede 100644 --- a/api.Dockerfile +++ b/api.Dockerfile @@ -29,6 +29,7 @@ COPY --chown=1000:1000 api/ . # Copy the built Vue.js app from the previous stage COPY --chown=1000:1000 --from=build-stage /app/dist /api/public COPY --chown=1000:1000 --from=build-stage /app/dist/assets/app-config.js /api/app-config.template.js +COPY --chown=1000:1000 --from=build-stage /app/mock-data /mock-data # Expose the port your API will run on EXPOSE 3000 diff --git a/api/server.mjs b/api/server.mjs index eac61854..7c8aae18 100644 --- a/api/server.mjs +++ b/api/server.mjs @@ -45,16 +45,47 @@ const authMiddleware = (req, res, next) => { next(); }; +const simpleRequestLogger = (proxyServer, options) => { + proxyServer.on('proxyReq', (proxyReq, req, res) => { + console.log(`[HPM] [${req.method}] ${req.url}`); // outputs: [HPM] GET /users + }); +} + +const mockResponses = (proxyServer, options) => { + proxyServer.on('proxyReq', (proxyReq, req, res) => { + // Do not send to GitHub when mocked + switch (req.path) { + case "/orgs/octodemo/copilot/usage": + res.json(JSON.parse(readFileSync(path.join(__dirname, '../mock-data/organization_response_sample.json'), 'utf8'))); + break; + case "/orgs/octodemo/copilot/billing/seats": + res.json(JSON.parse(readFileSync(path.join(__dirname, '../mock-data/organization_response_sample_seats.json'), 'utf8'))); + break; + case "/enterprises/octodemo/copilot/usage": + res.json(JSON.parse(readFileSync(path.join(__dirname, '../mock-data/enterprise_response_sample.json'), 'utf8'))); + break; + case "/enterprises/octodemo/copilot/billing/seats": + res.json(JSON.parse(readFileSync(path.join(__dirname, '../mock-data/enterprise_response_sample_seats.json'), 'utf8'))); + break; + default: + res.status(418).send('🫖Request Not Mocked'); + } + }); +} + +const plugins = [simpleRequestLogger]; + +if (process.env.APP_MOCKED_DATA === 'true') { + plugins.push(mockResponses); +} + const githubProxy = createProxyMiddleware({ target: 'https://api.github.com', changeOrigin: true, pathRewrite: { '^/api/github': '', // Rewrite URL path (remove /api/github) }, - onProxyReq: (proxyReq, req) => { - console.log('Proxying request to GitHub API:', req.url); - // Optional: Modify the proxy request here (e.g., headers) - }, + plugins }); // Apply middlewares to the app diff --git a/docker-compose.ent.override.yml b/docker-compose.ent.override.yml new file mode 100644 index 00000000..a55c2b26 --- /dev/null +++ b/docker-compose.ent.override.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + api: + environment: + # Determines the scope of the API calls. + # Can be 'enterprise' or 'organization' to target API calls to an enterprise or an organization respectively. + - VUE_APP_SCOPE=enterprise + # Determines the enterprise or organization name to target API calls. + - VUE_APP_GITHUB_ORG= + - VUE_APP_GITHUB_ENT=octodemo + + playwright: + command: npx playwright test --output test-results-docker --grep @ent \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f9db019a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.8' + +services: + api: + build: + context: . + dockerfile: api.Dockerfile + ports: + - "3000:3000" + environment: + - NODE_ENV=production + # Determines if mocked data should be used instead of making API calls. + - VUE_APP_MOCKED_DATA=false + # Mock requests in the API not UI + - APP_MOCKED_DATA=true + # Determines the scope of the API calls. + # Can be 'enterprise' or 'organization' to target API calls to an enterprise or an organization respectively. + - VUE_APP_SCOPE=organization + # Determines the enterprise or organization name to target API calls. + - VUE_APP_GITHUB_ORG=octodemo + - VUE_APP_GITHUB_ENT= + - VUE_APP_GITHUB_TOKEN=dummy + # GitHub Api Url + # for proxy api - set to /api/github defaults to https://api.github.com + - VUE_APP_GITHUB_API=/api/github + - SESSION_SECRET=secret + + playwright: + image: mcr.microsoft.com/playwright:v1.49.1 + environment: + - TEST_URL=http://api:3000 + - CI=true + volumes: + - .:/workspace + working_dir: /workspace + command: npx playwright test --output test-results-docker --grep @org + ipc: host + profiles: [tests] + depends_on: + - api \ No newline at end of file diff --git a/src/assets/enterprise_response_sample.json b/mock-data/enterprise_response_sample.json similarity index 100% rename from src/assets/enterprise_response_sample.json rename to mock-data/enterprise_response_sample.json diff --git a/src/assets/enterprise_response_sample_seats.json b/mock-data/enterprise_response_sample_seats.json similarity index 100% rename from src/assets/enterprise_response_sample_seats.json rename to mock-data/enterprise_response_sample_seats.json diff --git a/src/assets/organization_response_sample.json b/mock-data/organization_response_sample.json similarity index 100% rename from src/assets/organization_response_sample.json rename to mock-data/organization_response_sample.json diff --git a/src/assets/organization_response_sample_seats.json b/mock-data/organization_response_sample_seats.json similarity index 100% rename from src/assets/organization_response_sample_seats.json rename to mock-data/organization_response_sample_seats.json diff --git a/package-lock.json b/package-lock.json index 343e9a89..8184f190 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,8 @@ "webfontloader": "^1.0.0" }, "devDependencies": { + "@playwright/test": "^1.49.1", + "@types/node": "^22.10.5", "@types/webfontloader": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", @@ -2134,6 +2136,21 @@ "node": ">= 8" } }, + "node_modules/@playwright/test": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz", + "integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==", + "dev": true, + "dependencies": { + "playwright": "1.49.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@polka/url": { "version": "1.0.0-next.25", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.25.tgz", @@ -2369,12 +2386,12 @@ "dev": true }, "node_modules/@types/node": { - "version": "22.2.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz", - "integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==", + "version": "22.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz", + "integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==", "devOptional": true, "dependencies": { - "undici-types": "~6.13.0" + "undici-types": "~6.20.0" } }, "node_modules/@types/node-forge": { @@ -9338,6 +9355,50 @@ "node": ">=8" } }, + "node_modules/playwright": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.1.tgz", + "integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==", + "dev": true, + "dependencies": { + "playwright-core": "1.49.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.1.tgz", + "integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==", + "dev": 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/portfinder": { "version": "1.0.32", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", @@ -11434,9 +11495,9 @@ } }, "node_modules/undici-types": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", - "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", "devOptional": true }, "node_modules/unicode-canonical-property-names-ecmascript": { diff --git a/package.json b/package.json index 347e56b5..f0770e15 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "lint": "vue-cli-service lint" + "lint": "vue-cli-service lint", + "test": "npx playwright test --grep @org", + "test:ent": "npx playwright test --grep @ent" }, "dependencies": { "@mdi/font": "5.9.55", @@ -20,6 +22,8 @@ "webfontloader": "^1.0.0" }, "devDependencies": { + "@playwright/test": "^1.49.1", + "@types/node": "^22.10.5", "@types/webfontloader": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 00000000..47859e34 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,80 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// import dotenv from 'dotenv'; +// import path from 'path'; +// dotenv.config({ path: path.resolve(__dirname, '.env') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +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: { + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: process.env['TEST_URL'] ?? 'http://127.0.0.1:8080', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + screenshot: 'on', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + webServer: { + command: 'npm run serve', + url: process.env['TEST_URL'] ?? 'http://127.0.0.1:8080', + reuseExistingServer: true, + }, +}); diff --git a/src/api/ExtractSeats.ts b/src/api/ExtractSeats.ts index 2f61f643..692ef84b 100644 --- a/src/api/ExtractSeats.ts +++ b/src/api/ExtractSeats.ts @@ -3,8 +3,8 @@ import axios from "axios"; import { Seat } from "../model/Seat"; import config from '../config'; -import organizationMockedResponse_seats from '../assets/organization_response_sample_seats.json'; -import enterpriseMockedResponse_seats from '../assets/enterprise_response_sample_seats.json'; +import organizationMockedResponse_seats from '../../mock-data/organization_response_sample_seats.json'; +import enterpriseMockedResponse_seats from '../../mock-data/enterprise_response_sample_seats.json'; const headers = { Accept: "application/vnd.github+json", diff --git a/src/api/GitHubApi.ts b/src/api/GitHubApi.ts index 15122306..125c6630 100644 --- a/src/api/GitHubApi.ts +++ b/src/api/GitHubApi.ts @@ -7,8 +7,8 @@ import axios from "axios"; import { Metrics } from "../model/Metrics"; -import organizationMockedResponse from '../assets/organization_response_sample.json'; -import enterpriseMockedResponse from '../assets/enterprise_response_sample.json'; +import organizationMockedResponse from '../../mock-data/organization_response_sample.json'; +import enterpriseMockedResponse from '../../mock-data/enterprise_response_sample.json'; import config from '../config'; const headers = { diff --git a/tests/copilot.ent.spec.ts b/tests/copilot.ent.spec.ts new file mode 100644 index 00000000..ab5527f3 --- /dev/null +++ b/tests/copilot.ent.spec.ts @@ -0,0 +1,31 @@ +import { test, expect } from '@playwright/test'; + +const tag = { tag: ['@ent'] } + + +test('has title', tag, async ({ page }) => { + await page.goto('/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/copilot-metrics-viewer/); + await expect(page.locator(".toolbar-title")).toHaveText(/Copilot Metrics Viewer \| Enterprise : octodemo/); +}); + +test('metrics visible', tag, async ({ page }) => { + await page.goto('/'); + + await expect(page.getByText('Acceptance Rate Average')).toBeVisible(); + await expect(page.getByText('Cumulative Number of Suggestions')).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Total Lines Suggested | Total' })).toBeVisible(); + await page.getByRole('tab', { name: 'languages' }).click(); + await expect(page.getByText('Top 5 Languages by acceptance')).toBeVisible(); + await page.getByRole('tab', { name: 'editors' }).click(); + await expect(page.getByText('Number of Editors')).toBeVisible(); + await page.getByRole('tab', { name: 'seat analysis' }).click(); + await expect(page.getByText('Total Assigned')).toBeVisible(); +}); + +test('enterprise tab', tag, async ({ page }) => { + await page.goto('/'); + await expect(page.getByRole('tab', { name: 'enterprise' })).toBeVisible(); +}); \ No newline at end of file diff --git a/tests/copilot.org.spec.ts b/tests/copilot.org.spec.ts new file mode 100644 index 00000000..f580a9c9 --- /dev/null +++ b/tests/copilot.org.spec.ts @@ -0,0 +1,30 @@ +import { test, expect } from '@playwright/test'; + +const tag = { tag: ['@org'] } + +test('has title', tag, async ({ page }) => { + await page.goto('/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/copilot-metrics-viewer/); + await expect(page.locator(".toolbar-title")).toHaveText(/Copilot Metrics Viewer \| Organization : octodemo/); +}); + +test('metrics visible', tag, async ({ page }) => { + await page.goto('/'); + + await expect(page.getByText('Acceptance Rate Average')).toBeVisible(); + await expect(page.getByText('Cumulative Number of Suggestions')).toBeVisible(); + await expect(page.getByRole('heading', { name: 'Total Lines Suggested | Total' })).toBeVisible(); + await page.getByRole('tab', { name: 'languages' }).click(); + await expect(page.getByText('Top 5 Languages by acceptance')).toBeVisible(); + await page.getByRole('tab', { name: 'editors' }).click(); + await expect(page.getByText('Number of Editors')).toBeVisible(); + await page.getByRole('tab', { name: 'seat analysis' }).click(); + await expect(page.getByText('Total Assigned')).toBeVisible(); +}); + +test('organization tab', tag, async ({ page }) => { + await page.goto('/'); + await expect(page.getByRole('tab', { name: 'organization' })).toBeVisible(); +}); \ No newline at end of file From 5c6ae66eac0ed44449b58d135676f14dfa8e9c8d Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Fri, 3 Jan 2025 15:12:35 -0500 Subject: [PATCH 02/14] testing with docker --- .dockerignore | 4 +++- .github/workflows/playwright.yml | 28 +++++++++++++++++++++++++++- .gitignore | 4 +++- docker-compose.ent.override.yml | 2 +- docker-compose.yml | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 6c73176a..19e38bd6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,4 +17,6 @@ azure-deploy/ infra/ playwright-report/ test-results/ -test-results-docker/ \ No newline at end of file +test-results-docker/ +test-results-docker-ent/ +test-results-docker-org/ diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 43115c7e..1ca9747b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -6,7 +6,7 @@ on: branches: [ main, master ] jobs: test: - timeout-minutes: 60 + timeout-minutes: 10 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -25,3 +25,29 @@ jobs: name: playwright-report path: playwright-report/ retention-days: 30 + + test-api-org: + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - name: Run Playwright tests + run: docker compose --profile tests run playwright + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report-docker-org + path: test-results-docker-org/ + retention-days: 30 + + test-api-ent: + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - name: Run Playwright tests + run: docker compose -f docker-compose.yml -f docker-compose.ent.override.yml --profile tests run playwright + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report-docker-ent + path: test-results-docker-ent/ + retention-days: 30 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7dfed31a..5d1b31c4 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,6 @@ test.http /test-results-docker/ /playwright-report/ /blob-report/ -/playwright/.cache/ \ No newline at end of file +/playwright/.cache/ +test-results-docker-ent/ +test-results-docker-org/ diff --git a/docker-compose.ent.override.yml b/docker-compose.ent.override.yml index a55c2b26..6d287055 100644 --- a/docker-compose.ent.override.yml +++ b/docker-compose.ent.override.yml @@ -11,4 +11,4 @@ services: - VUE_APP_GITHUB_ENT=octodemo playwright: - command: npx playwright test --output test-results-docker --grep @ent \ No newline at end of file + command: npx playwright test --output test-results-docker-ent --grep @ent \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index f9db019a..1f000e66 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,7 +33,7 @@ services: volumes: - .:/workspace working_dir: /workspace - command: npx playwright test --output test-results-docker --grep @org + command: npx playwright test --output test-results-docker-org --grep @org ipc: host profiles: [tests] depends_on: From a78aee6f747ff3bc14b79e4e7f4e1cb383560559 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Fri, 3 Jan 2025 15:14:10 -0500 Subject: [PATCH 03/14] added checkout --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1ca9747b..30fb82b2 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -30,6 +30,7 @@ jobs: timeout-minutes: 15 runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Run Playwright tests run: docker compose --profile tests run playwright - uses: actions/upload-artifact@v4 @@ -43,6 +44,7 @@ jobs: timeout-minutes: 15 runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Run Playwright tests run: docker compose -f docker-compose.yml -f docker-compose.ent.override.yml --profile tests run playwright - uses: actions/upload-artifact@v4 From a8ea5eda4020eb78c146bd357db699cac9af3f06 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Fri, 3 Jan 2025 15:27:52 -0500 Subject: [PATCH 04/14] fixes and reporter --- .github/workflows/playwright.yml | 13 +++++++++++++ docker-compose.ent.override.yml | 2 -- docker-compose.yml | 2 -- playwright.config.ts | 11 ++++++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 30fb82b2..6f95e761 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -7,6 +7,9 @@ on: jobs: test: timeout-minutes: 10 + permissions: + checks: write + pull-requests: read runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -31,6 +34,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install Playwright + run: npm install -g @playwright/test - name: Run Playwright tests run: docker compose --profile tests run playwright - uses: actions/upload-artifact@v4 @@ -45,6 +53,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install Playwright + run: npm install -g @playwright/test - name: Run Playwright tests run: docker compose -f docker-compose.yml -f docker-compose.ent.override.yml --profile tests run playwright - uses: actions/upload-artifact@v4 diff --git a/docker-compose.ent.override.yml b/docker-compose.ent.override.yml index 6d287055..5c484f90 100644 --- a/docker-compose.ent.override.yml +++ b/docker-compose.ent.override.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: api: environment: diff --git a/docker-compose.yml b/docker-compose.yml index 1f000e66..ea340055 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: api: build: diff --git a/playwright.config.ts b/playwright.config.ts index 47859e34..4162c6a4 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -22,7 +22,16 @@ export default defineConfig({ /* 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', + reporter: process.env.CI ? + [ + ['html', { open: 'never' }], + ['github'], + ['junit', { outputFile: 'results.xml' }] + ] : + [ + ['list'], + ['html', { open: 'never' }] + ], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ From 425f69a867f5aee819dac16300b328eaebe56029 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:21:36 -0500 Subject: [PATCH 05/14] testing builds --- .github/workflows/playwright.yml | 36 ++++++++++++++++++++-------- api.Dockerfile | 40 ++++++++++++++++++++++++++++---- api/server.mjs | 1 + docker-compose.ent.override.yml | 12 ---------- docker-compose.yml | 38 ------------------------------ package-lock.json | 1 + playwright.docker.config.ts | 17 ++++++++++++++ 7 files changed, 81 insertions(+), 64 deletions(-) delete mode 100644 docker-compose.ent.override.yml delete mode 100644 docker-compose.yml create mode 100644 playwright.docker.config.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6f95e761..c2143fe5 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -34,13 +34,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and export to Docker + uses: docker/build-push-action@v6 with: - node-version: lts/* - - name: Install Playwright - run: npm install -g @playwright/test + load: true + tags: api:test - name: Run Playwright tests - run: docker compose --profile tests run playwright + run: docker run -it --rm --name playwright \ + -v $(pwd)/test-results-docker-org:/test-results \ + -e VUE_APP_SCOPE=organization \ + -e VUE_APP_GITHUB_ORG=octodemo \ + -e VUE_APP_GITHUB_API=/api/github \ + -e APP_MOCKED_DATA=true \ + api:test @org - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: @@ -53,13 +61,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and export to Docker + uses: docker/build-push-action@v6 with: - node-version: lts/* - - name: Install Playwright - run: npm install -g @playwright/test + load: true + tags: api:test - name: Run Playwright tests - run: docker compose -f docker-compose.yml -f docker-compose.ent.override.yml --profile tests run playwright + run: docker run -it --rm --name playwright \ + -v $(pwd)/test-results-docker-ent:/test-results \ + -e VUE_APP_SCOPE=enterprise \ + -e VUE_APP_GITHUB_ENT=octodemo \ + -e VUE_APP_GITHUB_API=/api/github \ + -e APP_MOCKED_DATA=true \ + api:test @ent - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/api.Dockerfile b/api.Dockerfile index 98ca5ede..fa0c6d20 100644 --- a/api.Dockerfile +++ b/api.Dockerfile @@ -1,22 +1,29 @@ # Stage 1: Build the Vue.js application +# mode can be 'prod' - default or 'playwright' +# for 'playwright' mode, the final image will be base-playwright +# for 'prod' mode, the final image will be base-prod +# build with 'docker build -f api.Dockerfile -t api --build-arg mode=playwright .' +# build with 'docker build -f api.Dockerfile -t api .' for production +ARG mode=prod + FROM node:23 AS build-stage USER node WORKDIR /app COPY --chown=1000:1000 package*.json ./ -RUN npm install +RUN npm ci COPY --chown=1000:1000 . . RUN npm run build # Stage 2: Prepare the Node.js API -FROM node:23 AS api-stage +FROM node:23 AS base-prod WORKDIR /api # Copy package.json and other necessary files for the API COPY --chown=1000:1000 api/package*.json ./ -RUN npm install && \ +RUN npm ci && \ chown -R 1000:1000 /api && \ apt-get update && \ apt-get install -y --no-install-recommends gettext-base && \ @@ -38,4 +45,29 @@ EXPOSE 3000 RUN chmod +x /api/docker-entrypoint.api/entrypoint.sh USER node -ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"] + +#----------------------------------- +FROM mcr.microsoft.com/playwright:v1.49.1 AS base-playwright + +WORKDIR /pw + +RUN apt-get update && \ + apt-get install -y --no-install-recommends gettext-base && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY --chown=1000:1000 --from=base-prod /api /api +COPY --chown=1000:1000 --from=base-prod /mock-data /mock-data +COPY --chown=1000:1000 tests ./tests +COPY --chown=1000:1000 playwright.config.ts . +COPY --chown=1000:1000 playwright.docker.config.ts . + + +RUN npm install @playwright/test@1.49.1 +# RUN npx playwright install --with-deps + +ENTRYPOINT [ "npx", "playwright", "test", "-c", "playwright.docker.config.ts", "--output", "/test-results", "--grep"] + +#----------------------------------- +FROM base-${mode} AS final diff --git a/api/server.mjs b/api/server.mjs index 7c8aae18..d7a0d8b9 100644 --- a/api/server.mjs +++ b/api/server.mjs @@ -5,6 +5,7 @@ import axios from 'axios'; import { fileURLToPath } from 'url'; import session from 'express-session'; import { createProxyMiddleware } from 'http-proxy-middleware'; +import { readFileSync } from 'fs'; // Construct __dirname equivalent in ES module scope const __dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/docker-compose.ent.override.yml b/docker-compose.ent.override.yml deleted file mode 100644 index 5c484f90..00000000 --- a/docker-compose.ent.override.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - api: - environment: - # Determines the scope of the API calls. - # Can be 'enterprise' or 'organization' to target API calls to an enterprise or an organization respectively. - - VUE_APP_SCOPE=enterprise - # Determines the enterprise or organization name to target API calls. - - VUE_APP_GITHUB_ORG= - - VUE_APP_GITHUB_ENT=octodemo - - playwright: - command: npx playwright test --output test-results-docker-ent --grep @ent \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index ea340055..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,38 +0,0 @@ -services: - api: - build: - context: . - dockerfile: api.Dockerfile - ports: - - "3000:3000" - environment: - - NODE_ENV=production - # Determines if mocked data should be used instead of making API calls. - - VUE_APP_MOCKED_DATA=false - # Mock requests in the API not UI - - APP_MOCKED_DATA=true - # Determines the scope of the API calls. - # Can be 'enterprise' or 'organization' to target API calls to an enterprise or an organization respectively. - - VUE_APP_SCOPE=organization - # Determines the enterprise or organization name to target API calls. - - VUE_APP_GITHUB_ORG=octodemo - - VUE_APP_GITHUB_ENT= - - VUE_APP_GITHUB_TOKEN=dummy - # GitHub Api Url - # for proxy api - set to /api/github defaults to https://api.github.com - - VUE_APP_GITHUB_API=/api/github - - SESSION_SECRET=secret - - playwright: - image: mcr.microsoft.com/playwright:v1.49.1 - environment: - - TEST_URL=http://api:3000 - - CI=true - volumes: - - .:/workspace - working_dir: /workspace - command: npx playwright test --output test-results-docker-org --grep @org - ipc: host - profiles: [tests] - depends_on: - - api \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8184f190..35c0c601 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2141,6 +2141,7 @@ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz", "integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==", "dev": true, + "license": "Apache-2.0", "dependencies": { "playwright": "1.49.1" }, diff --git a/playwright.docker.config.ts b/playwright.docker.config.ts new file mode 100644 index 00000000..e9c9c789 --- /dev/null +++ b/playwright.docker.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from '@playwright/test'; +import baseConfig from './playwright.config'; + +export default defineConfig({ + ...baseConfig, + use: { + baseURL: 'http://127.0.0.1:3000', + }, + webServer: { + command: '/api/docker-entrypoint.api/entrypoint.sh', + url: 'http://127.0.0.1:3000', + reuseExistingServer: false, + cwd: '/api', + stderr: 'pipe', + stdout: 'pipe' + }, +}); \ No newline at end of file From f813401f965a7bcebce802eb40ce50ec1ca239b5 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:24:03 -0500 Subject: [PATCH 06/14] fix --- .github/workflows/playwright.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index c2143fe5..b79fb76c 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -41,8 +41,9 @@ jobs: with: load: true tags: api:test + build-args: mode=playwright - name: Run Playwright tests - run: docker run -it --rm --name playwright \ + run: docker run --rm --name playwright \ -v $(pwd)/test-results-docker-org:/test-results \ -e VUE_APP_SCOPE=organization \ -e VUE_APP_GITHUB_ORG=octodemo \ @@ -68,8 +69,9 @@ jobs: with: load: true tags: api:test + build-args: mode=playwright - name: Run Playwright tests - run: docker run -it --rm --name playwright \ + run: docker run --rm --name playwright \ -v $(pwd)/test-results-docker-ent:/test-results \ -e VUE_APP_SCOPE=enterprise \ -e VUE_APP_GITHUB_ENT=octodemo \ From b0ed6f33a66a8c60c6e5b19777ca6ede4c6119df Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:28:01 -0500 Subject: [PATCH 07/14] another fix --- .github/workflows/playwright.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b79fb76c..37b840cf 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -43,7 +43,8 @@ jobs: tags: api:test build-args: mode=playwright - name: Run Playwright tests - run: docker run --rm --name playwright \ + run: | + docker run --rm --name playwright \ -v $(pwd)/test-results-docker-org:/test-results \ -e VUE_APP_SCOPE=organization \ -e VUE_APP_GITHUB_ORG=octodemo \ @@ -71,7 +72,8 @@ jobs: tags: api:test build-args: mode=playwright - name: Run Playwright tests - run: docker run --rm --name playwright \ + run: | + docker run --rm --name playwright \ -v $(pwd)/test-results-docker-ent:/test-results \ -e VUE_APP_SCOPE=enterprise \ -e VUE_APP_GITHUB_ENT=octodemo \ From e14819f91912d4d9b5618e023029bbe8233e8cd3 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:32:04 -0500 Subject: [PATCH 08/14] org and ent --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 37b840cf..ce4ac25b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -50,7 +50,7 @@ jobs: -e VUE_APP_GITHUB_ORG=octodemo \ -e VUE_APP_GITHUB_API=/api/github \ -e APP_MOCKED_DATA=true \ - api:test @org + api:test "@org" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: @@ -79,7 +79,7 @@ jobs: -e VUE_APP_GITHUB_ENT=octodemo \ -e VUE_APP_GITHUB_API=/api/github \ -e APP_MOCKED_DATA=true \ - api:test @ent + api:test "@ent" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: From 7cc03209fd087b61665049a82bdda30104dc3dd7 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:35:12 -0500 Subject: [PATCH 09/14] single line? --- .github/workflows/playwright.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ce4ac25b..660dfa69 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,13 +44,7 @@ jobs: build-args: mode=playwright - name: Run Playwright tests run: | - docker run --rm --name playwright \ - -v $(pwd)/test-results-docker-org:/test-results \ - -e VUE_APP_SCOPE=organization \ - -e VUE_APP_GITHUB_ORG=octodemo \ - -e VUE_APP_GITHUB_API=/api/github \ - -e APP_MOCKED_DATA=true \ - api:test "@org" + docker run --rm --name playwright -v $(pwd)/test-results-docker-org:/test-results -e VUE_APP_SCOPE=organization -e VUE_APP_GITHUB_ORG=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true api:test "@org" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: @@ -73,13 +67,7 @@ jobs: build-args: mode=playwright - name: Run Playwright tests run: | - docker run --rm --name playwright \ - -v $(pwd)/test-results-docker-ent:/test-results \ - -e VUE_APP_SCOPE=enterprise \ - -e VUE_APP_GITHUB_ENT=octodemo \ - -e VUE_APP_GITHUB_API=/api/github \ - -e APP_MOCKED_DATA=true \ - api:test "@ent" + docker run --rm --name playwright -v $(pwd)/test-results-docker-ent:/test-results -e VUE_APP_SCOPE=enterprise -e VUE_APP_GITHUB_ENT=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true api:test "@ent" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: From f074008ebcfc0d5bcacbab941281e6022bb522a5 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:38:47 -0500 Subject: [PATCH 10/14] missing session --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 660dfa69..d300ce0f 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: build-args: mode=playwright - name: Run Playwright tests run: | - docker run --rm --name playwright -v $(pwd)/test-results-docker-org:/test-results -e VUE_APP_SCOPE=organization -e VUE_APP_GITHUB_ORG=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true api:test "@org" + docker run --rm --name playwright -v $(pwd)/test-results-docker-org:/test-results -e VUE_APP_SCOPE=organization -e VUE_APP_GITHUB_ORG=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true -e SESSION_SECRET=dummy api:test "@org" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: @@ -67,7 +67,7 @@ jobs: build-args: mode=playwright - name: Run Playwright tests run: | - docker run --rm --name playwright -v $(pwd)/test-results-docker-ent:/test-results -e VUE_APP_SCOPE=enterprise -e VUE_APP_GITHUB_ENT=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true api:test "@ent" + docker run --rm --name playwright -v $(pwd)/test-results-docker-ent:/test-results -e VUE_APP_SCOPE=enterprise -e VUE_APP_GITHUB_ENT=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true -e SESSION_SECRET=dummy api:test "@ent" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: From 7a16016e7b693fad21c80c8f00f90fd4f5c5c818 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:40:39 -0500 Subject: [PATCH 11/14] wrong file Signed-off-by: Piotr Karpala --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d300ce0f..2e9be7e7 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -39,6 +39,7 @@ jobs: - name: Build and export to Docker uses: docker/build-push-action@v6 with: + file: api.Dockerfile load: true tags: api:test build-args: mode=playwright @@ -62,6 +63,7 @@ jobs: - name: Build and export to Docker uses: docker/build-push-action@v6 with: + file: api.Dockerfile load: true tags: api:test build-args: mode=playwright From 13c26b955e04de3ae2e2a72ed59922ea683f46d5 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 00:43:17 -0500 Subject: [PATCH 12/14] fix path Signed-off-by: Piotr Karpala --- .github/{workflows => }/dependabot.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => }/dependabot.yml (100%) diff --git a/.github/workflows/dependabot.yml b/.github/dependabot.yml similarity index 100% rename from .github/workflows/dependabot.yml rename to .github/dependabot.yml From 8f869a71285b483ce8d9f48a4d971884c602ea1a Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 01:10:48 -0500 Subject: [PATCH 13/14] one more fix --- .github/workflows/playwright.yml | 24 +++++++++++++++++++++--- package-lock.json | 21 ++++++++++++--------- playwright.docker.config.ts | 3 +++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 2e9be7e7..367d3436 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -21,7 +21,7 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - name: Run Playwright tests - run: npm test + run: CI=true npm test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: @@ -45,7 +45,16 @@ jobs: build-args: mode=playwright - name: Run Playwright tests run: | - docker run --rm --name playwright -v $(pwd)/test-results-docker-org:/test-results -e VUE_APP_SCOPE=organization -e VUE_APP_GITHUB_ORG=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true -e SESSION_SECRET=dummy api:test "@org" + docker run --rm --name playwright \ + -v $(pwd)/test-results-docker-org:/test-results \ + -e CI=true \ + -e VUE_APP_SCOPE=organization \ + -e VUE_APP_GITHUB_ORG=octodemo \ + -e VUE_APP_GITHUB_API=/api/github \ + -e APP_MOCKED_DATA=true \ + -e VUE_APP_GITHUB_TOKEN=dummy \ + -e SESSION_SECRET=dummy \ + api:test "@org" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: @@ -69,7 +78,16 @@ jobs: build-args: mode=playwright - name: Run Playwright tests run: | - docker run --rm --name playwright -v $(pwd)/test-results-docker-ent:/test-results -e VUE_APP_SCOPE=enterprise -e VUE_APP_GITHUB_ENT=octodemo -e VUE_APP_GITHUB_API=/api/github -e APP_MOCKED_DATA=true -e SESSION_SECRET=dummy api:test "@ent" + docker run --rm --name playwright \ + -v $(pwd)/test-results-docker-ent:/test-results \ + -e CI=true \ + -e VUE_APP_SCOPE=enterprise \ + -e VUE_APP_GITHUB_ENT=octodemo \ + -e VUE_APP_GITHUB_API=/api/github \ + -e APP_MOCKED_DATA=true \ + -e VUE_APP_GITHUB_TOKEN=dummy \ + -e SESSION_SECRET=dummy \ + api:test "@ent" - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/package-lock.json b/package-lock.json index 35c0c601..46423f4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4850,10 +4850,11 @@ } }, "node_modules/cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz", + "integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==", "dev": true, + "license": "MIT", "dependencies": { "nice-try": "^1.0.4", "path-key": "^2.0.1", @@ -5218,10 +5219,11 @@ } }, "node_modules/default-gateway/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -6069,10 +6071,11 @@ "dev": true }, "node_modules/eslint/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", diff --git a/playwright.docker.config.ts b/playwright.docker.config.ts index e9c9c789..e6786bb5 100644 --- a/playwright.docker.config.ts +++ b/playwright.docker.config.ts @@ -5,6 +5,9 @@ export default defineConfig({ ...baseConfig, use: { baseURL: 'http://127.0.0.1:3000', + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'retain-on-failure', + screenshot: 'on', }, webServer: { command: '/api/docker-entrypoint.api/entrypoint.sh', From a8e519435451c53158ce740d8ad28e09eea8f41f Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Sat, 4 Jan 2025 01:19:06 -0500 Subject: [PATCH 14/14] reporters --- playwright.docker.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/playwright.docker.config.ts b/playwright.docker.config.ts index e6786bb5..34ff5e2d 100644 --- a/playwright.docker.config.ts +++ b/playwright.docker.config.ts @@ -3,6 +3,12 @@ import baseConfig from './playwright.config'; export default defineConfig({ ...baseConfig, + reporter: [ + ['list'], + ['html', { open: 'never', outputFolder: '/test-results/html' }], + ['github'], + ['junit', { outputFile: '/test-results/junit/results.xml' }] + ], use: { baseURL: 'http://127.0.0.1:3000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */