mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 09:47:15 +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",
|
||||
"test": "bun --bun vitest run",
|
||||
"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:report": "playwright show-report",
|
||||
"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 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()
|
||||
|
||||
let agentWorkerPromise: Promise<void> | null = null
|
||||
@@ -23,6 +23,9 @@ describe('Workflow E2E - agentAutofillMedia', () => {
|
||||
// Set bucket environment
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket'
|
||||
|
||||
// Configure the workflow service executor dynamically
|
||||
workflowService.setExecutorType(mode)
|
||||
|
||||
// Initialize registries
|
||||
initAgentWorkflows()
|
||||
initTranscodeWorkflows()
|
||||
@@ -50,8 +53,7 @@ describe('Workflow E2E - agentAutofillMedia', () => {
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
})
|
||||
|
||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
||||
if (type === 'temporal') {
|
||||
if (mode === 'temporal') {
|
||||
console.log('Starting background workers for Temporal E2E tests...')
|
||||
agentWorkerPromise = workflowService.startWorkers(TaskQueueAgent, {
|
||||
workflowsPath: agentWorkflowsPath,
|
||||
@@ -69,8 +71,7 @@ describe('Workflow E2E - agentAutofillMedia', () => {
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
||||
if (type === 'temporal') {
|
||||
if (mode === 'temporal') {
|
||||
console.log('Shutting down Temporal workers...')
|
||||
await workflowService.shutdownWorkers()
|
||||
await Promise.all([agentWorkerPromise, transcodeWorkerPromise].filter(Boolean))
|
||||
|
||||
@@ -7,28 +7,26 @@ export async function setup() {
|
||||
// 1. Start Postgres DB container & run migrations
|
||||
await dbSetup()
|
||||
|
||||
// 2. Start Temporal Dev Server container if running in temporal mode
|
||||
if (process.env.WORKFLOW_EXECUTOR === 'temporal') {
|
||||
console.log('Starting Temporal Dev Server container using testcontainers...')
|
||||
try {
|
||||
temporalContainer = await new GenericContainer('temporalio/temporal:latest')
|
||||
.withExposedPorts(7233, 8233)
|
||||
.withCommand(['server', 'start-dev', '--ip', '0.0.0.0'])
|
||||
.start()
|
||||
// 2. Start Temporal Dev Server container for the test suite
|
||||
console.log('Starting Temporal Dev Server container using testcontainers...')
|
||||
try {
|
||||
temporalContainer = await new GenericContainer('temporalio/temporal:latest')
|
||||
.withExposedPorts(7233, 8233)
|
||||
.withCommand(['server', 'start-dev', '--ip', '0.0.0.0'])
|
||||
.start()
|
||||
|
||||
const host = temporalContainer.getHost()
|
||||
const mappedPort = temporalContainer.getMappedPort(7233)
|
||||
const address = `${host}:${mappedPort}`
|
||||
const host = temporalContainer.getHost()
|
||||
const mappedPort = temporalContainer.getMappedPort(7233)
|
||||
const address = `${host}:${mappedPort}`
|
||||
|
||||
process.env.TEMPORAL_ADDRESS = address
|
||||
console.log(`Temporal Dev Server container started. Address: ${address}`)
|
||||
process.env.TEMPORAL_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
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
} catch (err) {
|
||||
console.error('Failed to start Temporal Dev Server container:', err)
|
||||
throw err
|
||||
}
|
||||
// Brief sleep to ensure temporal dev server is fully ready to accept gRPC clients
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
} catch (err) {
|
||||
console.error('Failed to start Temporal Dev Server container:', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,12 @@ describe('WorkflowService Temporal Workers Concurrency Control', () => {
|
||||
originalExecutor = process.env.WORKFLOW_EXECUTOR
|
||||
originalTranscode = process.env.CONCURRENCY_TRANSCODE
|
||||
originalAgent = process.env.CONCURRENCY_AGENT
|
||||
process.env.WORKFLOW_EXECUTOR = 'temporal'
|
||||
workflowService.setExecutorType('temporal')
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (originalExecutor === undefined) {
|
||||
delete process.env.WORKFLOW_EXECUTOR
|
||||
} else {
|
||||
process.env.WORKFLOW_EXECUTOR = originalExecutor
|
||||
}
|
||||
workflowService.setExecutorType(originalExecutor === 'temporal' ? 'temporal' : 'local')
|
||||
|
||||
if (originalTranscode === undefined) {
|
||||
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> {
|
||||
return this.executor.submit(task)
|
||||
}
|
||||
@@ -77,7 +85,7 @@ export class WorkflowService {
|
||||
queue: string,
|
||||
options: { workflowBundle?: unknown; workflowsPath?: string } = {},
|
||||
): Promise<void> {
|
||||
const type = process.env.WORKFLOW_EXECUTOR || 'local'
|
||||
const type = this.executor instanceof TemporalExecutor ? 'temporal' : 'local'
|
||||
if (type === 'temporal') {
|
||||
const { Worker, NativeConnection } = await import('@temporalio/worker')
|
||||
|
||||
|
||||
+6
-3
@@ -7,9 +7,12 @@ export default defineConfig({
|
||||
globalSetup: './packages/db/src/test-global-setup.ts',
|
||||
globals: false,
|
||||
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/**', 'apps/web/e2e/**'],
|
||||
exclude: [
|
||||
...configDefaults.exclude,
|
||||
'packages/webui/e2e/**',
|
||||
'apps/web/e2e/**',
|
||||
'packages/e2e/**',
|
||||
],
|
||||
server: {
|
||||
deps: {
|
||||
inline: ['zod', '@shumai/workflow-core', '@temporalio/activity'],
|
||||
|
||||
Reference in New Issue
Block a user