Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"private": true,
"scripts": {
"e2e": "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=false npx playwright test"
"e2e": "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=false npx playwright test",
"e2e:lightpanda": "playwright test --config=playwright.lightpanda.config.ts"
}
}
26 changes: 26 additions & 0 deletions apps/e2e-tests/playwright.lightpanda.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineConfig } from '@playwright/test';
import { nxE2EPreset } from '@nx/playwright/preset';

const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
const isCI = !!process.env.CI;

export default defineConfig({
...nxE2EPreset(__filename, { testDir: './src' }),
reporter: [['html', { open: isCI ? 'never' : 'on-failure' }]],
use: {
baseURL,
trace: 'on-first-retry',
// video and screenshot disabled — Lightpanda has no rendering engine
video: 'off',
screenshot: 'off',
// Empty locale prevents Playwright from calling Emulation.setUserAgentOverride,
// which Lightpanda does not implement. Playwright's default is "en-US" which
// triggers that CDP command unconditionally (crPage.js: if options.locale → _updateUserAgent).
locale: '',
},
projects: [
{
name: 'lightpanda',
},
],
});
28 changes: 26 additions & 2 deletions apps/e2e-tests/src/fixtures/packmindTest.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
import { test as base } from '@playwright/test';
import { test as base, Browser } from '@playwright/test';
import { chromium } from 'playwright-core';
import { v4 as uuidv4 } from 'uuid';
import { IPackmindApi } from '../domain/api/IPackmindApi';
import { PackmindApi } from '../infra/api/PackmindApi';
import { SignUpWithOrganizationCommand } from '@packmind/types';
import { IDashboardPage, IPageFactory } from '../domain/pages';
import { PageFactory } from '../infra/PageFactory';

export const testWithUserData = base.extend<{
// Override the built-in browser fixture to support Lightpanda via CDP
const testBase = base.extend<Record<string, never>, { browser: Browser }>({
browser: [
// eslint-disable-next-line no-empty-pattern
async ({}, use) => {
const wsEndpoint = process.env['LIGHTPANDA_WS_ENDPOINT'];
if (wsEndpoint) {
const browser = await chromium.connectOverCDP({
endpointURL: wsEndpoint,
});
await use(browser as unknown as Browser);
// Browser.disconnect() does not exist on CDP-connected browsers in playwright-core.
// The connection closes naturally when the worker process exits; Lightpanda keeps running.
} else {
const browser = await chromium.launch();
await use(browser);
await browser.close();
}
},
{ scope: 'worker' },
],
});

export const testWithUserData = testBase.extend<{
userData: SignUpWithOrganizationCommand;
}>({
// eslint-disable-next-line no-empty-pattern
Expand Down
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ services:
run-migrations:
condition: service_completed_successfully

lightpanda:
profiles:
- e2e-lightpanda
image: lightpanda/browser:nightly
container_name: ${COMPOSE_PROJECT_NAME:-dev}-lightpanda
environment:
LIGHTPANDA_DISABLE_TELEMETRY: 'true'
healthcheck:
test: ['CMD', 'bash', '-c', '</dev/tcp/127.0.0.1/9222']
interval: 2s
timeout: 2s
retries: 15

run-e2e-tests:
image: mcr.microsoft.com/playwright:v1.56.1-jammy
container_name: ${COMPOSE_PROJECT_NAME:-dev}-run-e2e-tests-${PACKMIND_EDITION:-oss}
Expand All @@ -334,6 +347,31 @@ services:
backend:
condition: service_healthy

run-e2e-tests-lightpanda:
image: mcr.microsoft.com/playwright:v1.56.1-jammy
container_name: ${COMPOSE_PROJECT_NAME:-dev}-run-e2e-tests-lightpanda-${PACKMIND_EDITION:-oss}
profiles:
- e2e-lightpanda
volumes:
- .:/packmind
- dev-node_modules:/packmind/node_modules
- dev-dist:/packmind/dist
- dev-tmp:/packmind/tmp
- dev-nx-sock:/nx-sock
working_dir: /packmind/apps/e2e-tests
entrypoint: npm run e2e:lightpanda
environment:
BASE_URL: http://frontend:4200
CI: 'true'
LIGHTPANDA_WS_ENDPOINT: ws://lightpanda:9222
depends_on:
lightpanda:
condition: service_healthy
frontend:
condition: service_healthy
backend:
condition: service_healthy

volumes:
dev-nx-sock:
dev-postgres-data:
Expand Down