mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 06:54:28 +00:00
chore(vitest): exclude packages/e2e/** from root unit test suite
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"test": "bun --bun vitest run",
|
"test": "bun --bun vitest run",
|
||||||
"test:e2e": "playwright test",
|
"test:e2e": "playwright test",
|
||||||
"test:e2e:workflow": "WORKFLOW_EXECUTOR=local bun --bun vitest run -c packages/e2e/vitest.config.ts && WORKFLOW_EXECUTOR=temporal bun --bun vitest run -c packages/e2e/vitest.config.ts",
|
"test:e2e:workflow": "bun --bun vitest run -c packages/e2e/vitest.config.ts",
|
||||||
"test:e2e:ui": "playwright test --ui",
|
"test:e2e:ui": "playwright test --ui",
|
||||||
"test:e2e:report": "playwright show-report",
|
"test:e2e:report": "playwright show-report",
|
||||||
"test:e2e:install": "playwright install --with-deps",
|
"test:e2e:install": "playwright install --with-deps",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|||||||
const agentWorkflowsPath = path.resolve(currentDir, '../../../apps/agent/src/workflows.ts')
|
const agentWorkflowsPath = path.resolve(currentDir, '../../../apps/agent/src/workflows.ts')
|
||||||
const transcodeWorkflowsPath = path.resolve(currentDir, '../../../apps/transcode/src/workflows.ts')
|
const transcodeWorkflowsPath = path.resolve(currentDir, '../../../apps/transcode/src/workflows.ts')
|
||||||
|
|
||||||
describe('Workflow E2E - agentAutofillMedia', () => {
|
describe.each(['local', 'temporal'] as const)('Workflow E2E - agentAutofillMedia (executor: %s)', (mode) => {
|
||||||
setupTestDbHooks()
|
setupTestDbHooks()
|
||||||
|
|
||||||
let agentWorkerPromise: Promise<void> | null = null
|
let agentWorkerPromise: Promise<void> | null = null
|
||||||
@@ -23,6 +23,9 @@ describe('Workflow E2E - agentAutofillMedia', () => {
|
|||||||
// Set bucket environment
|
// Set bucket environment
|
||||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket'
|
process.env.S3_BUCKET = 'shumai-e2e-test-bucket'
|
||||||
|
|
||||||
|
// Configure the workflow service executor dynamically
|
||||||
|
workflowService.setExecutorType(mode)
|
||||||
|
|
||||||
// Initialize registries
|
// Initialize registries
|
||||||
initAgentWorkflows()
|
initAgentWorkflows()
|
||||||
initTranscodeWorkflows()
|
initTranscodeWorkflows()
|
||||||
@@ -50,8 +53,7 @@ describe('Workflow E2E - agentAutofillMedia', () => {
|
|||||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||||
})
|
})
|
||||||
|
|
||||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
if (mode === 'temporal') {
|
||||||
if (type === 'temporal') {
|
|
||||||
console.log('Starting background workers for Temporal E2E tests...')
|
console.log('Starting background workers for Temporal E2E tests...')
|
||||||
agentWorkerPromise = workflowService.startWorkers(TaskQueueAgent, {
|
agentWorkerPromise = workflowService.startWorkers(TaskQueueAgent, {
|
||||||
workflowsPath: agentWorkflowsPath,
|
workflowsPath: agentWorkflowsPath,
|
||||||
@@ -69,8 +71,7 @@ describe('Workflow E2E - agentAutofillMedia', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
if (mode === 'temporal') {
|
||||||
if (type === 'temporal') {
|
|
||||||
console.log('Shutting down Temporal workers...')
|
console.log('Shutting down Temporal workers...')
|
||||||
await workflowService.shutdownWorkers()
|
await workflowService.shutdownWorkers()
|
||||||
await Promise.all([agentWorkerPromise, transcodeWorkerPromise].filter(Boolean))
|
await Promise.all([agentWorkerPromise, transcodeWorkerPromise].filter(Boolean))
|
||||||
|
|||||||
@@ -7,28 +7,26 @@ export async function setup() {
|
|||||||
// 1. Start Postgres DB container & run migrations
|
// 1. Start Postgres DB container & run migrations
|
||||||
await dbSetup()
|
await dbSetup()
|
||||||
|
|
||||||
// 2. Start Temporal Dev Server container if running in temporal mode
|
// 2. Start Temporal Dev Server container for the test suite
|
||||||
if (process.env.WORKFLOW_EXECUTOR === 'temporal') {
|
console.log('Starting Temporal Dev Server container using testcontainers...')
|
||||||
console.log('Starting Temporal Dev Server container using testcontainers...')
|
try {
|
||||||
try {
|
temporalContainer = await new GenericContainer('temporalio/temporal:latest')
|
||||||
temporalContainer = await new GenericContainer('temporalio/temporal:latest')
|
.withExposedPorts(7233, 8233)
|
||||||
.withExposedPorts(7233, 8233)
|
.withCommand(['server', 'start-dev', '--ip', '0.0.0.0'])
|
||||||
.withCommand(['server', 'start-dev', '--ip', '0.0.0.0'])
|
.start()
|
||||||
.start()
|
|
||||||
|
|
||||||
const host = temporalContainer.getHost()
|
const host = temporalContainer.getHost()
|
||||||
const mappedPort = temporalContainer.getMappedPort(7233)
|
const mappedPort = temporalContainer.getMappedPort(7233)
|
||||||
const address = `${host}:${mappedPort}`
|
const address = `${host}:${mappedPort}`
|
||||||
|
|
||||||
process.env.TEMPORAL_ADDRESS = address
|
process.env.TEMPORAL_ADDRESS = address
|
||||||
console.log(`Temporal Dev Server container started. Address: ${address}`)
|
console.log(`Temporal Dev Server container started. Address: ${address}`)
|
||||||
|
|
||||||
// Brief sleep to ensure temporal dev server is fully ready to accept gRPC clients
|
// Brief sleep to ensure temporal dev server is fully ready to accept gRPC clients
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to start Temporal Dev Server container:', err)
|
console.error('Failed to start Temporal Dev Server container:', err)
|
||||||
throw err
|
throw err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,16 +26,12 @@ describe('WorkflowService Temporal Workers Concurrency Control', () => {
|
|||||||
originalExecutor = process.env.WORKFLOW_EXECUTOR
|
originalExecutor = process.env.WORKFLOW_EXECUTOR
|
||||||
originalTranscode = process.env.CONCURRENCY_TRANSCODE
|
originalTranscode = process.env.CONCURRENCY_TRANSCODE
|
||||||
originalAgent = process.env.CONCURRENCY_AGENT
|
originalAgent = process.env.CONCURRENCY_AGENT
|
||||||
process.env.WORKFLOW_EXECUTOR = 'temporal'
|
workflowService.setExecutorType('temporal')
|
||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (originalExecutor === undefined) {
|
workflowService.setExecutorType(originalExecutor === 'temporal' ? 'temporal' : 'local')
|
||||||
delete process.env.WORKFLOW_EXECUTOR
|
|
||||||
} else {
|
|
||||||
process.env.WORKFLOW_EXECUTOR = originalExecutor
|
|
||||||
}
|
|
||||||
|
|
||||||
if (originalTranscode === undefined) {
|
if (originalTranscode === undefined) {
|
||||||
delete process.env.CONCURRENCY_TRANSCODE
|
delete process.env.CONCURRENCY_TRANSCODE
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ export class WorkflowService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setExecutorType(type: 'local' | 'temporal') {
|
||||||
|
if (type === 'temporal') {
|
||||||
|
this.executor = new TemporalExecutor(process.env.TEMPORAL_ADDRESS)
|
||||||
|
} else {
|
||||||
|
this.executor = new LocalExecutor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async submit(task: WorkflowTask): Promise<string> {
|
async submit(task: WorkflowTask): Promise<string> {
|
||||||
return this.executor.submit(task)
|
return this.executor.submit(task)
|
||||||
}
|
}
|
||||||
@@ -77,7 +85,7 @@ export class WorkflowService {
|
|||||||
queue: string,
|
queue: string,
|
||||||
options: { workflowBundle?: unknown; workflowsPath?: string } = {},
|
options: { workflowBundle?: unknown; workflowsPath?: string } = {},
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
const type = this.executor instanceof TemporalExecutor ? 'temporal' : 'local'
|
||||||
if (type === 'temporal') {
|
if (type === 'temporal') {
|
||||||
const { Worker, NativeConnection } = await import('@temporalio/worker')
|
const { Worker, NativeConnection } = await import('@temporalio/worker')
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -7,9 +7,12 @@ export default defineConfig({
|
|||||||
globalSetup: './packages/db/src/test-global-setup.ts',
|
globalSetup: './packages/db/src/test-global-setup.ts',
|
||||||
globals: false,
|
globals: false,
|
||||||
pool: 'forks',
|
pool: 'forks',
|
||||||
// Playwright e2e specs live under packages/webui/e2e and are run by the
|
exclude: [
|
||||||
// Playwright runner (bun run test:e2e), not Vitest.
|
...configDefaults.exclude,
|
||||||
exclude: [...configDefaults.exclude, 'packages/webui/e2e/**', 'apps/web/e2e/**'],
|
'packages/webui/e2e/**',
|
||||||
|
'apps/web/e2e/**',
|
||||||
|
'packages/e2e/**',
|
||||||
|
],
|
||||||
server: {
|
server: {
|
||||||
deps: {
|
deps: {
|
||||||
inline: ['zod', '@shumai/workflow-core', '@temporalio/activity'],
|
inline: ['zod', '@shumai/workflow-core', '@temporalio/activity'],
|
||||||
|
|||||||
Reference in New Issue
Block a user