d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
96 lines
2.9 KiB
TypeScript
96 lines
2.9 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import type {
|
|
RowExecutionMetadata,
|
|
TableDefinition,
|
|
TableRow,
|
|
WorkflowGroup,
|
|
} from '@/lib/table/types'
|
|
import { pickNextEligibleGroupForRow } from '@/lib/table/workflow-columns'
|
|
|
|
function makeGroup(overrides: Partial<WorkflowGroup> & { id: string }): WorkflowGroup {
|
|
return {
|
|
workflowId: `wf-${overrides.id}`,
|
|
outputs: [{ blockId: 'b1', path: 'out', columnName: `${overrides.id}_out` }],
|
|
...overrides,
|
|
}
|
|
}
|
|
|
|
function makeTable(groups: WorkflowGroup[]): TableDefinition {
|
|
return {
|
|
id: 'tbl1',
|
|
name: 'T',
|
|
schema: { columns: [], workflowGroups: groups },
|
|
rowCount: 1,
|
|
maxRows: 1000,
|
|
workspaceId: 'ws1',
|
|
createdBy: 'u1',
|
|
createdAt: new Date(),
|
|
updatedAt: new Date(),
|
|
}
|
|
}
|
|
|
|
function makeRow(
|
|
executions: Record<string, RowExecutionMetadata>,
|
|
data: Record<string, unknown> = {}
|
|
): TableRow {
|
|
return {
|
|
id: 'row1',
|
|
data: data as TableRow['data'],
|
|
executions,
|
|
position: 0,
|
|
createdAt: new Date(),
|
|
updatedAt: new Date(),
|
|
}
|
|
}
|
|
|
|
/** The dispatcher's "queued marker" pre-stamp: pending with no executionId. */
|
|
function queuedMarker(workflowId: string): RowExecutionMetadata {
|
|
return { status: 'pending', executionId: null, jobId: null, workflowId, error: null }
|
|
}
|
|
|
|
describe('pickNextEligibleGroupForRow — queued-marker handoff', () => {
|
|
it('runs an autoRun:false group that carries a queued marker (explicit request)', () => {
|
|
const group = makeGroup({ id: 'g1', autoRun: false })
|
|
const table = makeTable([group])
|
|
const row = makeRow({ g1: queuedMarker('wf-g1') })
|
|
|
|
expect(pickNextEligibleGroupForRow(table, row)?.id).toBe('g1')
|
|
})
|
|
|
|
it('does NOT run an autoRun:false group with no marker (auto-cascade respects autoRun)', () => {
|
|
const group = makeGroup({ id: 'g1', autoRun: false })
|
|
const table = makeTable([group])
|
|
const row = makeRow({})
|
|
|
|
expect(pickNextEligibleGroupForRow(table, row)).toBeNull()
|
|
})
|
|
|
|
it('does NOT run an autoRun:true marker whose deps are unmet (no spin)', () => {
|
|
const group = makeGroup({ id: 'g1', autoRun: true, dependencies: { columns: ['need'] } })
|
|
const table = makeTable([group])
|
|
// marker present, but the dep column is empty → deps-unmet
|
|
const row = makeRow({ g1: queuedMarker('wf-g1') }, { need: '' })
|
|
|
|
expect(pickNextEligibleGroupForRow(table, row)).toBeNull()
|
|
})
|
|
|
|
it('still runs a normal autoRun:true group whose deps are satisfied (no marker)', () => {
|
|
const group = makeGroup({ id: 'g1', autoRun: true })
|
|
const table = makeTable([group])
|
|
const row = makeRow({})
|
|
|
|
expect(pickNextEligibleGroupForRow(table, row)?.id).toBe('g1')
|
|
})
|
|
|
|
it('skips excludeGroupId so the just-finished group does not self-retrigger', () => {
|
|
const group = makeGroup({ id: 'g1', autoRun: true })
|
|
const table = makeTable([group])
|
|
const row = makeRow({})
|
|
|
|
expect(pickNextEligibleGroupForRow(table, row, 'g1')).toBeNull()
|
|
})
|
|
})
|