From 3fdab5902a2aa6706fea9da8e6d27c34de9b840e Mon Sep 17 00:00:00 2001 From: Chris Dumas Date: Mon, 9 Nov 2026 08:17:28 +0000 Subject: [PATCH] test: add Playwright UI smoke coverage --- .gitignore | 3 +++ README.md | 4 ++++ package-lock.json | 46 +++++++++++++++++++++++++++++++++++++++++ package.json | 4 +++- playwright.config.ts | 21 +++++++++++++++++++ tests/simulator.spec.ts | 40 +++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 playwright.config.ts create mode 100644 tests/simulator.spec.ts diff --git a/.gitignore b/.gitignore index e6aff69..c96de51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ node_modules dist .vs +.playwright/ +playwright-report +test-results .DS_Store src/*.js vite.config.js diff --git a/README.md b/README.md index 38eb75d..360d93c 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ The initial landscape contains Website, API, ERP, CRM and Email Platform plus tw ```bash npm test npm run build + +# Browser UI smoke tests (requires a Playwright browser install once) +npx playwright install chromium +npm run test:ui ``` ## Limitations diff --git a/package-lock.json b/package-lock.json index b4a4d2d..13e94cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "vue": "^3.5.22" }, "devDependencies": { + "@playwright/test": "^1.65.0", "@types/node": "^26.6.6", "@vitejs/plugin-vue": "^6.0.1", "jsdom": "^26.1.0", @@ -644,6 +645,22 @@ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", "license": "MIT" }, + "node_modules/@playwright/test": { + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.0.tgz", + "integrity": "sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.65.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@rolldown/pluginutils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", @@ -1898,6 +1915,35 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/playwright": { + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz", + "integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.65.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz", + "integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/postcss": { "version": "8.5.32", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz", diff --git a/package.json b/package.json index 876ab9d..8493288 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,15 @@ "scripts": { "dev": "vite", "build": "vue-tsc --noEmit && vite build", - "test": "vitest run src/model.test.ts" + "test": "vitest run src/model.test.ts", + "test:ui": "playwright test" }, "dependencies": { "litegraph.js": "^0.7.18", "vue": "^3.5.22" }, "devDependencies": { + "@playwright/test": "^1.65.0", "@types/node": "^26.6.6", "@vitejs/plugin-vue": "^6.0.1", "jsdom": "^26.1.0", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..c948abf --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,21 @@ +import { defineConfig, devices } from '@playwright/test' + +export default defineConfig({ + testDir: './tests', + fullyParallel: true, + retries: process.env.CI ? 2 : 0, + reporter: 'html', + use: { + baseURL: 'http://127.0.0.1:5173', + trace: 'on-first-retry', + screenshot: 'only-on-failure', + video: 'retain-on-failure', + }, + projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }], + webServer: { + command: 'npm run dev -- --host 127.0.0.1', + url: 'http://127.0.0.1:5173', + reuseExistingServer: !process.env.CI, + timeout: 30_000, + }, +}) diff --git a/tests/simulator.spec.ts b/tests/simulator.spec.ts new file mode 100644 index 0000000..912839d --- /dev/null +++ b/tests/simulator.spec.ts @@ -0,0 +1,40 @@ +import { expect, test } from '@playwright/test' + +test.beforeEach(async ({ page }) => { + await page.goto('/') + await page.evaluate(() => localStorage.clear()) + await page.reload() + await expect(page.getByRole('heading', { name: /System Landscape/ })).toBeVisible() +}) + +test('loads the demo and advances a scenario', async ({ page }) => { + await expect(page.locator('.list-area .list-item')).toHaveCount(2) + await page.locator('.list-area .run-mini').first().click() + await expect(page.locator('.guided-card')).toBeVisible() + await expect(page.locator('.guided-card')).not.toContainText('Ready to run') + await page.getByRole('button', { name: '›' }).click() + await expect(page.locator('.timeline-label')).not.toContainText('0 /') +}) + +test('places a preset and keeps the new system editable', async ({ page }) => { + await page.getByRole('button', { name: 'Presets' }).click() + await page.locator('.preset-item .run-mini').first().click() + await expect(page.getByRole('heading', { name: /Place preset/ })).toBeVisible() + await page.getByRole('button', { name: 'Place system' }).click() + await expect(page.locator('.inspector-content').first()).toContainText('Save system') +}) + +test('persists an edited scenario across refresh', async ({ page }) => { + const name = 'Browser persistence check' + await page.locator('.scenario-inspector input').first().fill(name) + await page.reload() + await expect(page.locator('.scenario-inspector input').first()).toHaveValue(name) +}) + +test('enters and exits presentation mode', async ({ page }) => { + await page.getByRole('button', { name: 'Presentation mode' }).click() + await expect(page.getByRole('button', { name: 'Exit presentation' })).toBeVisible() + await expect(page.locator('.topbar')).toBeHidden() + await page.getByRole('button', { name: 'Exit presentation' }).click() + await expect(page.getByRole('button', { name: 'Presentation mode' })).toBeVisible() +})