21 lines
899 B
TypeScript
21 lines
899 B
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { getOperation, runOperation } from '@/features/workflows/operations'
|
|
|
|
describe('项目级长请求互斥', () => {
|
|
it('同一项目不同时执行两个 graph,错误不伪装成功', async () => {
|
|
let fail!: (reason: Error) => void
|
|
const action = vi.fn<() => Promise<unknown>>(
|
|
() =>
|
|
new Promise((_resolve, reject) => {
|
|
fail = reject
|
|
})
|
|
)
|
|
const first = runOperation('operation-test', '拆解', action)
|
|
expect(await runOperation('operation-test', '改写', action)).toBe(false)
|
|
expect(action).toHaveBeenCalledTimes(1)
|
|
fail(new Error('连接中断'))
|
|
expect(await first).toBe(false)
|
|
expect(getOperation('operation-test')).toMatchObject({ pending: false, error: '连接中断', notice: '' })
|
|
})
|
|
})
|