From 26982ee4944e2a2cf4acd1aa6c2eb8c1045aaa57 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 15:21:01 +0800 Subject: [PATCH 01/10] feat(e2e): set up fullstack app-level e2e test framework and signup test case --- apps/web/e2e/global-teardown.ts | 36 ++++++++++++++ apps/web/e2e/serve.ts | 34 +++++++++++++ apps/web/e2e/signup-project.spec.ts | 75 +++++++++++++++++++++++++++++ apps/web/src/index.ts | 16 ++++-- playwright.config.ts | 65 ++++++++++++++----------- vitest.config.ts | 2 +- 6 files changed, 193 insertions(+), 35 deletions(-) create mode 100644 apps/web/e2e/global-teardown.ts create mode 100644 apps/web/e2e/serve.ts create mode 100644 apps/web/e2e/signup-project.spec.ts diff --git a/apps/web/e2e/global-teardown.ts b/apps/web/e2e/global-teardown.ts new file mode 100644 index 00000000..6d68fa0e --- /dev/null +++ b/apps/web/e2e/global-teardown.ts @@ -0,0 +1,36 @@ +import { teardown as dbTeardown } from '../../../packages/db/src/test-global-setup' +import * as fs from 'fs' +import * as path from 'path' +import { fileURLToPath } from 'url' + +const currentDir = path.dirname(fileURLToPath(import.meta.url)) + +export default async function globalTeardown() { + const envPath = path.resolve(currentDir, '.env.e2e') + if (fs.existsSync(envPath)) { + const content = fs.readFileSync(envPath, 'utf8') + let bucketName: string | undefined + + content.split('\n').forEach((line) => { + const parts = line.split('=') + if (parts.length >= 2 && parts[0].trim() === 'S3_BUCKET') { + bucketName = parts.slice(1).join('=').trim() + } + }) + + if (bucketName) { + const bucketDir = path.resolve('data', bucketName) + if (fs.existsSync(bucketDir)) { + console.log(`Cleaning up E2E local storage bucket: ${bucketDir}`) + fs.rmSync(bucketDir, { recursive: true, force: true }) + } + } + + // Delete the temp .env.e2e file + fs.unlinkSync(envPath) + } + + // Stop pgvector container + await dbTeardown() + console.log('Global teardown complete.') +} diff --git a/apps/web/e2e/serve.ts b/apps/web/e2e/serve.ts new file mode 100644 index 00000000..41a3e4ed --- /dev/null +++ b/apps/web/e2e/serve.ts @@ -0,0 +1,34 @@ +import { globalTestSetup } from '../../../packages/db/src/test-global-setup' +import { randomBytes } from 'crypto' +import * as fs from 'fs' +import * as path from 'path' +import { fileURLToPath } from 'url' + +const currentDir = path.dirname(fileURLToPath(import.meta.url)) + +async function start() { + console.log('Starting E2E test database container...') + await globalTestSetup() + + // Generate a random S3 bucket name + const randomSuffix = randomBytes(4).toString('hex') + const bucketName = `shumai-e2e-${randomSuffix}` + + process.env.S3_BUCKET = bucketName + process.env.SHUMAI_SERVER_PORT = '5200' + process.env.BETTER_AUTH_URL = 'http://localhost:5200' + process.env.NODE_ENV = 'development' + + // Write variables to .env.e2e file so the teardown can load them + const envContent = [`DATABASE_URL=${process.env.DATABASE_URL}`, `S3_BUCKET=${bucketName}`].join( + '\n', + ) + + fs.writeFileSync(path.resolve(currentDir, '.env.e2e'), envContent) + console.log(`E2E env file written. Starting Web App...`) + + // Now run the web app + await import('../src/index.ts') +} + +start().catch(console.error) diff --git a/apps/web/e2e/signup-project.spec.ts b/apps/web/e2e/signup-project.spec.ts new file mode 100644 index 00000000..7a7ec0b8 --- /dev/null +++ b/apps/web/e2e/signup-project.spec.ts @@ -0,0 +1,75 @@ +import { expect, test } from '@playwright/test' +import * as fs from 'fs' +import * as path from 'path' +import { fileURLToPath } from 'url' + +const currentDir = path.dirname(fileURLToPath(import.meta.url)) +const tempImgPath = path.resolve(currentDir, 'temp-cover.png') + +test.beforeAll(async () => { + // Create a 1x1 transparent PNG file + const pngBase64 = + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' + fs.writeFileSync(tempImgPath, Buffer.from(pngBase64, 'base64')) +}) + +test.afterAll(async () => { + if (fs.existsSync(tempImgPath)) { + fs.unlinkSync(tempImgPath) + } +}) + +test('should sign up and create a project with a cover image', async ({ page }) => { + const email = `test-${Date.now()}@shumai.local` + const password = 'Password123!' + + // 1. Sign Up Flow + await page.goto('/signup') + await expect(page).toHaveURL(/\/signup/) + + // Fill credentials + await page.fill('#email', email) + await page.fill('#password', password) + + // Submit sign up + await page.click('button[type="submit"]') + + // Wait for the automatic redirect to the team page (since only one team exists) + await expect(page).toHaveURL(/\/teams\/[^/]+/) + + // 2. Create Project Flow + // Click the "Create Project" button on the dashboard + await page.click('button:has-text("Create Project")') + + const dialog = page.locator('[role="dialog"]') + await expect(dialog).toBeVisible() + + // Fill project name + const projectName = `My Project ${Date.now()}` + await dialog.locator('#name').fill(projectName) + + // Set cover image + await dialog.locator('input[type="file"]').setInputFiles(tempImgPath) + + // Wait for image upload completion and preview + await expect(dialog.locator('img[alt="Cover Preview"]')).toBeVisible({ timeout: 15_000 }) + + // Click submit in dialog + await dialog.locator('button[type="submit"]').click() + + // Wait for navigation to the project page + await expect(page).toHaveURL(/\/projects\/[^/]+/) + + // Verify project name appears in the project view + await expect(page.locator(`text=${projectName}`).first()).toBeVisible() + + // 3. Verification on Dashboard + // Navigate back to the dashboard via sidebar + await page.click('button[aria-label="Dashboard"]') + + // Wait for dashboard URL + await expect(page).toHaveURL(/\/teams\/[^/]+/) + + // Verify the project card is visible and displays the cover image with project name alt text + await expect(page.locator(`img[alt="${projectName}"]`)).toBeVisible() +}) diff --git a/apps/web/src/index.ts b/apps/web/src/index.ts index 12049077..2e97505a 100644 --- a/apps/web/src/index.ts +++ b/apps/web/src/index.ts @@ -96,7 +96,6 @@ async function run() { .replaceAll('content="./', 'content="/') const serveMainHtml = () => new Response(mainHtmlText, { headers: mainHtmlHeaders }) - routes['/'] = serveMainHtml routes['/*'] = serveMainHtml } else { @@ -136,7 +135,14 @@ async function run() { process.on('SIGTERM', shutdown) } -handleDaemonCommands('shumai', run).catch((err) => { - console.error(err) - process.exit(1) -}) +if (process.env.S3_BUCKET && process.env.S3_BUCKET.startsWith('shumai-e2e')) { + run().catch((err) => { + console.error(err) + process.exit(1) + }) +} else { + handleDaemonCommands('shumai', run).catch((err) => { + console.error(err) + process.exit(1) + }) +} diff --git a/playwright.config.ts b/playwright.config.ts index f68e569f..ce0878bf 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,19 +1,13 @@ import { defineConfig, devices } from '@playwright/test' /** - * Playwright configuration for the webui UI integration tests. + * Playwright configuration for the monorepo integration and E2E tests. * - * The suite runs against a backend-free harness (packages/webui/e2e) served by - * Bun's native HTML bundler, so no database, auth or transcode pipeline is - * required. - * - * Browser selection: pass `--project=` to pick an engine, e.g. - * bun run test:e2e --project=webkit # WebKit (Safari engine), used on macOS CI - * bun run test:e2e --project=chromium - * bun run test:e2e --project=firefox + * We support two test projects: + * 1. harness: pure frontend UI integration tests served on port 5199. + * 2. app: fullstack end-to-end tests with real backend, pgvector container, and S3 local storage on port 5200. */ export default defineConfig({ - testDir: './packages/webui/e2e/tests', testMatch: '**/*.spec.ts', fullyParallel: true, forbidOnly: !!process.env.CI, @@ -23,35 +17,48 @@ export default defineConfig({ timeout: 60_000, expect: { timeout: 10_000 }, + globalTeardown: './apps/web/e2e/global-teardown.ts', + use: { - // `baseURL` is Playwright's required option key and cannot be renamed. - // eslint-disable-next-line @typescript-eslint/naming-convention - baseURL: 'http://localhost:5199', trace: 'on-first-retry', video: 'retain-on-failure', }, projects: [ { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, + name: 'harness', + testDir: './packages/webui/e2e/tests', + use: { + ...devices['Desktop Chrome'], + // eslint-disable-next-line @typescript-eslint/naming-convention + baseURL: 'http://localhost:5199', + }, }, { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - }, - { - name: 'webkit', - use: { ...devices['Desktop Safari'] }, + name: 'app', + testDir: './apps/web/e2e', + fullyParallel: false, // run sequentially to avoid DB and storage conflicts + use: { + ...devices['Desktop Chrome'], + // eslint-disable-next-line @typescript-eslint/naming-convention + baseURL: 'http://localhost:5200', + }, }, ], - // Launch the isolated harness dev server (Bun's native HTML bundler) before - // the tests. - webServer: { - command: 'bun run packages/webui/e2e/harness/serve.ts', - url: 'http://localhost:5199', - reuseExistingServer: !process.env.CI, - timeout: 120_000, - }, + // Launch both the isolated harness server and the fullstack web app server + webServer: [ + { + command: 'bun run packages/webui/e2e/harness/serve.ts', + url: 'http://localhost:5199', + reuseExistingServer: !process.env.CI, + timeout: 120_000, + }, + { + command: 'bun run apps/web/e2e/serve.ts', + url: 'http://localhost:5200', + reuseExistingServer: !process.env.CI, + timeout: 120_000, + }, + ], }) diff --git a/vitest.config.ts b/vitest.config.ts index 53a5dd79..03923092 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ pool: 'forks', // Playwright e2e specs live under packages/webui/e2e and are run by the // Playwright runner (bun run test:e2e), not Vitest. - exclude: [...configDefaults.exclude, 'packages/webui/e2e/**'], + exclude: [...configDefaults.exclude, 'packages/webui/e2e/**', 'apps/web/e2e/**'], server: { deps: { inline: ['zod'], From cd96015b9dbd071e3117e63ce149a1254910f422 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 15:35:59 +0800 Subject: [PATCH 02/10] feat(e2e): add browser selection support for app-level E2E tests --- playwright.config.ts | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index ce0878bf..e5793256 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -25,8 +25,9 @@ export default defineConfig({ }, projects: [ + /* Harness Integration Projects */ { - name: 'harness', + name: 'harness-chromium', testDir: './packages/webui/e2e/tests', use: { ...devices['Desktop Chrome'], @@ -35,7 +36,27 @@ export default defineConfig({ }, }, { - name: 'app', + name: 'harness-firefox', + testDir: './packages/webui/e2e/tests', + use: { + ...devices['Desktop Firefox'], + // eslint-disable-next-line @typescript-eslint/naming-convention + baseURL: 'http://localhost:5199', + }, + }, + { + name: 'harness-webkit', + testDir: './packages/webui/e2e/tests', + use: { + ...devices['Desktop Safari'], + // eslint-disable-next-line @typescript-eslint/naming-convention + baseURL: 'http://localhost:5199', + }, + }, + + /* Fullstack App E2E Projects */ + { + name: 'app-chromium', testDir: './apps/web/e2e', fullyParallel: false, // run sequentially to avoid DB and storage conflicts use: { @@ -44,6 +65,26 @@ export default defineConfig({ baseURL: 'http://localhost:5200', }, }, + { + name: 'app-firefox', + testDir: './apps/web/e2e', + fullyParallel: false, + use: { + ...devices['Desktop Firefox'], + // eslint-disable-next-line @typescript-eslint/naming-convention + baseURL: 'http://localhost:5200', + }, + }, + { + name: 'app-webkit', + testDir: './apps/web/e2e', + fullyParallel: false, + use: { + ...devices['Desktop Safari'], + // eslint-disable-next-line @typescript-eslint/naming-convention + baseURL: 'http://localhost:5200', + }, + }, ], // Launch both the isolated harness server and the fullstack web app server From 0aba2ee557bb343fffd1c0266357e97adc8eed06 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 16:18:45 +0800 Subject: [PATCH 03/10] refactor(e2e): migrate database reset logic to standard Playwright custom fixture --- apps/web/e2e/fixtures.ts | 55 +++++++++++++++++++++++++++++ apps/web/e2e/signup-project.spec.ts | 5 ++- apps/web/package.json | 3 ++ bun.lock | 29 ++++++++------- playwright.config.ts | 2 +- 5 files changed, 77 insertions(+), 17 deletions(-) create mode 100644 apps/web/e2e/fixtures.ts diff --git a/apps/web/e2e/fixtures.ts b/apps/web/e2e/fixtures.ts new file mode 100644 index 00000000..880cf361 --- /dev/null +++ b/apps/web/e2e/fixtures.ts @@ -0,0 +1,55 @@ +import { test as base } from '@playwright/test' +import { PrismaClient } from '../../../packages/db/src/generated/prisma/client' +import { PrismaPg } from '@prisma/adapter-pg' +import { Pool } from 'pg' +import * as fs from 'fs' +import * as path from 'path' +import { fileURLToPath } from 'url' + +const currentDir = path.dirname(fileURLToPath(import.meta.url)) +const envPath = path.resolve(currentDir, '.env.e2e') + +// Load E2E environment variables if present +if (fs.existsSync(envPath)) { + const content = fs.readFileSync(envPath, 'utf8') + content.split('\n').forEach((line) => { + const parts = line.split('=') + if (parts.length >= 2) { + const key = parts[0].trim() + const value = parts.slice(1).join('=').trim() + process.env[key] = value + } + }) +} + +export const test = base.extend<{ prisma: PrismaClient }>({ + prisma: [ + async (_, use) => { + const connectionString = process.env.DATABASE_URL + const pool = new Pool({ connectionString }) + const adapter = new PrismaPg(pool) + const prisma = new PrismaClient({ adapter }) + + // Reset database state before the test runs + await prisma.$executeRawUnsafe(` + DO $$ DECLARE + r RECORD; + BEGIN + FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename <> '_prisma_migrations') LOOP + EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE;'; + END LOOP; + END $$; + `) + + // Provide the clean prisma instance to the test + await use(prisma) + + // Disconnect and clean up resources after the test finishes + await prisma.$disconnect() + await pool.end() + }, + { auto: true }, + ], +}) + +export { expect } from '@playwright/test' diff --git a/apps/web/e2e/signup-project.spec.ts b/apps/web/e2e/signup-project.spec.ts index 7a7ec0b8..806e196b 100644 --- a/apps/web/e2e/signup-project.spec.ts +++ b/apps/web/e2e/signup-project.spec.ts @@ -1,4 +1,4 @@ -import { expect, test } from '@playwright/test' +import { expect, test } from './fixtures' import * as fs from 'fs' import * as path from 'path' import { fileURLToPath } from 'url' @@ -8,8 +8,7 @@ const tempImgPath = path.resolve(currentDir, 'temp-cover.png') test.beforeAll(async () => { // Create a 1x1 transparent PNG file - const pngBase64 = - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' + const pngBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' fs.writeFileSync(tempImgPath, Buffer.from(pngBase64, 'base64')) }) diff --git a/apps/web/package.json b/apps/web/package.json index bfa76f98..4c40834f 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -13,5 +13,8 @@ "@shumai/transcode": "workspace:*", "@shumai/webui": "workspace:*", "hono": "4.12.23" + }, + "devDependencies": { + "@types/pg": "8.20.0" } } diff --git a/bun.lock b/bun.lock index 72d6d422..41ed4b85 100644 --- a/bun.lock +++ b/bun.lock @@ -37,7 +37,7 @@ }, "apps/agent": { "name": "@shumai/agent-app", - "version": "0.1.7", + "version": "0.1.8", "bin": { "shumai-agent": "./src/index.ts", }, @@ -49,7 +49,7 @@ }, "apps/cli": { "name": "@shumai/cli", - "version": "0.1.7", + "version": "0.1.8", "bin": { "shumai-cli": "./src/index.ts", }, @@ -64,7 +64,7 @@ }, "apps/transcode": { "name": "@shumai/transcode-app", - "version": "0.1.7", + "version": "0.1.8", "bin": { "shumai-transcode": "./src/index.ts", }, @@ -76,7 +76,7 @@ }, "apps/web": { "name": "@shumai/web-app", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@shumai/agent": "workspace:*", "@shumai/api": "workspace:*", @@ -88,10 +88,13 @@ "@shumai/workflow-core": "workspace:*", "hono": "4.12.23", }, + "devDependencies": { + "@types/pg": "8.20.0", + }, }, "packages/agent": { "name": "@shumai/agent", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@anthropic-ai/sandbox-runtime": "0.0.52", "@earendil-works/pi-agent-core": "0.78.0", @@ -115,7 +118,7 @@ }, "packages/api": { "name": "@shumai/api", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@hono/zod-validator": "0.7.6", "@shumai/core": "workspace:*", @@ -129,7 +132,7 @@ }, "packages/core": { "name": "@shumai/core", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@earendil-works/pi-agent-core": "0.78.0", "@shumai/db": "workspace:*", @@ -157,7 +160,7 @@ }, "packages/db": { "name": "@shumai/db", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@earendil-works/pi-agent-core": "0.78.0", "@prisma/adapter-pg": "7.8.0", @@ -173,7 +176,7 @@ }, "packages/dtos": { "name": "@shumai/dtos", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@earendil-works/pi-agent-core": "0.78.0", "zod": "4.4.3", @@ -181,11 +184,11 @@ }, "packages/tableprinter": { "name": "@shumai/tableprinter", - "version": "0.1.7", + "version": "0.1.8", }, "packages/transcode": { "name": "@shumai/transcode", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@shumai/core": "workspace:*", "@shumai/db": "workspace:*", @@ -199,7 +202,7 @@ }, "packages/webui": { "name": "@shumai/webui", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@base-ui/react": "1.5.0", "@dnd-kit/abstract": "0.4.0", @@ -296,7 +299,7 @@ }, "packages/workflow-core": { "name": "@shumai/workflow-core", - "version": "0.1.7", + "version": "0.1.8", "dependencies": { "@shumai/core": "workspace:*", "@shumai/db": "workspace:*", diff --git a/playwright.config.ts b/playwright.config.ts index e5793256..79d77c07 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, - workers: process.env.CI ? 1 : undefined, + workers: 1, reporter: process.env.CI ? [['list'], ['html', { open: 'never' }]] : 'list', timeout: 60_000, expect: { timeout: 10_000 }, From 515c491d5dc444529e635ee24af9546649918784 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 16:21:09 +0800 Subject: [PATCH 04/10] fix(e2e): restore Playwright empty object destructuring for fixture parameters --- apps/web/e2e/fixtures.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/e2e/fixtures.ts b/apps/web/e2e/fixtures.ts index 880cf361..87ea3738 100644 --- a/apps/web/e2e/fixtures.ts +++ b/apps/web/e2e/fixtures.ts @@ -24,7 +24,8 @@ if (fs.existsSync(envPath)) { export const test = base.extend<{ prisma: PrismaClient }>({ prisma: [ - async (_, use) => { + // eslint-disable-next-line no-empty-pattern + async ({}, use) => { const connectionString = process.env.DATABASE_URL const pool = new Pool({ connectionString }) const adapter = new PrismaPg(pool) From 9414ebaefd2ca0b0ed4b59cadadca31a82444dc7 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 16:27:51 +0800 Subject: [PATCH 05/10] feat(e2e): run harness tests in parallel and app E2E tests sequentially using project dependencies --- playwright.config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index 79d77c07..c0158da9 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, - workers: 1, + workers: process.env.CI ? 1 : undefined, reporter: process.env.CI ? [['list'], ['html', { open: 'never' }]] : 'list', timeout: 60_000, expect: { timeout: 10_000 }, @@ -68,6 +68,7 @@ export default defineConfig({ { name: 'app-firefox', testDir: './apps/web/e2e', + dependencies: ['app-chromium'], fullyParallel: false, use: { ...devices['Desktop Firefox'], @@ -78,6 +79,7 @@ export default defineConfig({ { name: 'app-webkit', testDir: './apps/web/e2e', + dependencies: ['app-firefox'], fullyParallel: false, use: { ...devices['Desktop Safari'], From 55457fcd36f3fd7a416b2e63531fa1f40dc00d21 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 16:35:41 +0800 Subject: [PATCH 06/10] fix(webui): snap playhead to last frame upon ended event in useFramePlayer --- apps/web/e2e/signup-project.spec.ts | 3 ++- packages/webui/components/viewers/video/use-frame-player.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/web/e2e/signup-project.spec.ts b/apps/web/e2e/signup-project.spec.ts index 806e196b..adb663e1 100644 --- a/apps/web/e2e/signup-project.spec.ts +++ b/apps/web/e2e/signup-project.spec.ts @@ -8,7 +8,8 @@ const tempImgPath = path.resolve(currentDir, 'temp-cover.png') test.beforeAll(async () => { // Create a 1x1 transparent PNG file - const pngBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' + const pngBase64 = + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' fs.writeFileSync(tempImgPath, Buffer.from(pngBase64, 'base64')) }) diff --git a/packages/webui/components/viewers/video/use-frame-player.ts b/packages/webui/components/viewers/video/use-frame-player.ts index c5735a0c..2db01cce 100644 --- a/packages/webui/components/viewers/video/use-frame-player.ts +++ b/packages/webui/components/viewers/video/use-frame-player.ts @@ -186,8 +186,13 @@ export function useFramePlayer( } } + const handleEnded = () => { + setCurrentFrame(totalFrames - 1) + } + video.addEventListener('play', handlePlay) video.addEventListener('pause', handlePause) + video.addEventListener('ended', handleEnded) // If it's already playing when this effect runs if (!video.paused) { @@ -199,6 +204,7 @@ export function useFramePlayer( active = false video.removeEventListener('play', handlePlay) video.removeEventListener('pause', handlePause) + video.removeEventListener('ended', handleEnded) if (rVfcId !== null) { const videoWithCallback = video as unknown as HtmlVideoElementWithCallback if (videoWithCallback.cancelVideoFrameCallback) { From 1e1ddd1a3d5fe22c13d6d3d9acaec43267e20795 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 19:10:30 +0800 Subject: [PATCH 07/10] fix(e2e): declare types dependencies and adjust CI projects execution using --no-deps --- .github/workflows/ci.yaml | 2 +- apps/web/package.json | 2 ++ bun.lock | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 24111478..9d3b1daf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,7 +87,7 @@ jobs: run: bunx playwright install --with-deps ${{ matrix.project }} - name: Run video player e2e tests - run: bun run test:e2e --project=${{ matrix.project }} + run: bun run test:e2e --project=harness-${{ matrix.project }} --project=app-${{ matrix.project }} --no-deps - name: Upload Playwright report if: ${{ !cancelled() }} diff --git a/apps/web/package.json b/apps/web/package.json index 4c40834f..442cca1d 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -15,6 +15,8 @@ "hono": "4.12.23" }, "devDependencies": { + "@prisma/adapter-pg": "7.8.0", + "pg": "8.21.0", "@types/pg": "8.20.0" } } diff --git a/bun.lock b/bun.lock index 41ed4b85..9fe0e9b9 100644 --- a/bun.lock +++ b/bun.lock @@ -89,7 +89,9 @@ "hono": "4.12.23", }, "devDependencies": { + "@prisma/adapter-pg": "7.8.0", "@types/pg": "8.20.0", + "pg": "8.21.0", }, }, "packages/agent": { From 8d23d8b1c3ea1d26ee9c649bd3b00da731fce187 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 19:28:14 +0800 Subject: [PATCH 08/10] fix(ci): split E2E tests into harness and app jobs --- .github/workflows/ci.yaml | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9d3b1daf..af0f74ee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,7 +57,7 @@ jobs: bun run /tmp/shumai-local-release/node/node_modules/@shumai-one/shumai-transcode/bin/shumai-transcode-app.js --check e2e_video_player: - name: E2E (${{ matrix.project }}) + name: Harness E2E (${{ matrix.project }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -86,13 +86,53 @@ jobs: - name: Install Playwright browser (${{ matrix.project }}) run: bunx playwright install --with-deps ${{ matrix.project }} - - name: Run video player e2e tests - run: bun run test:e2e --project=harness-${{ matrix.project }} --project=app-${{ matrix.project }} --no-deps + - name: Run video player harness tests + run: bun run test:e2e --project=harness-${{ matrix.project }} - name: Upload Playwright report if: ${{ !cancelled() }} uses: actions/upload-artifact@v4 with: - name: playwright-report-${{ matrix.project }} + name: playwright-report-harness-${{ matrix.project }} + path: playwright-report/ + retention-days: 7 + + e2e_app: + name: App E2E (${{ matrix.project }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + project: chromium + - os: ubuntu-latest + project: firefox + # App E2E needs Docker for testcontainers, run webkit on Ubuntu + - os: ubuntu-latest + project: webkit + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Install Playwright browser (${{ matrix.project }}) + run: bunx playwright install --with-deps ${{ matrix.project }} + + - name: Run app E2E tests + run: bun run test:e2e --project=app-${{ matrix.project }} --no-deps + + - name: Upload Playwright report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: playwright-report-app-${{ matrix.project }} path: playwright-report/ retention-days: 7 From 4e9fae96b14f5c9799c390b02229c14acf5cdfec Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 19:41:31 +0800 Subject: [PATCH 09/10] fix(ci): split E2E jobs and support skipping app server via E2E_SKIP_APP_SERVER --- .github/workflows/ci.yaml | 2 ++ playwright.config.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af0f74ee..eaed76c5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,6 +87,8 @@ jobs: run: bunx playwright install --with-deps ${{ matrix.project }} - name: Run video player harness tests + env: + E2E_SKIP_APP_SERVER: true run: bun run test:e2e --project=harness-${{ matrix.project }} - name: Upload Playwright report diff --git a/playwright.config.ts b/playwright.config.ts index c0158da9..03e3b6ce 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -97,11 +97,11 @@ export default defineConfig({ reuseExistingServer: !process.env.CI, timeout: 120_000, }, - { + ...(process.env.E2E_SKIP_APP_SERVER === 'true' ? [] : [{ command: 'bun run apps/web/e2e/serve.ts', url: 'http://localhost:5200', reuseExistingServer: !process.env.CI, timeout: 120_000, - }, + }]), ], }) From 13f220ef0f96abe870bc1913df65649de7552939 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 10 Jul 2026 20:11:54 +0800 Subject: [PATCH 10/10] refactor(e2e): replace S3 bucket name check with explicit SHUMAI_E2E env flag --- apps/web/e2e/serve.ts | 1 + apps/web/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/e2e/serve.ts b/apps/web/e2e/serve.ts index 41a3e4ed..500d0398 100644 --- a/apps/web/e2e/serve.ts +++ b/apps/web/e2e/serve.ts @@ -18,6 +18,7 @@ async function start() { process.env.SHUMAI_SERVER_PORT = '5200' process.env.BETTER_AUTH_URL = 'http://localhost:5200' process.env.NODE_ENV = 'development' + process.env.SHUMAI_E2E = 'true' // Write variables to .env.e2e file so the teardown can load them const envContent = [`DATABASE_URL=${process.env.DATABASE_URL}`, `S3_BUCKET=${bucketName}`].join( diff --git a/apps/web/src/index.ts b/apps/web/src/index.ts index 2e97505a..347e51ca 100644 --- a/apps/web/src/index.ts +++ b/apps/web/src/index.ts @@ -135,7 +135,7 @@ async function run() { process.on('SIGTERM', shutdown) } -if (process.env.S3_BUCKET && process.env.S3_BUCKET.startsWith('shumai-e2e')) { +if (process.env.SHUMAI_E2E === 'true') { run().catch((err) => { console.error(err) process.exit(1)