refactor: Use static method for IncompleteStepsError
This commit is contained in:
@@ -123,7 +123,7 @@ class Flow extends Base {
|
|||||||
return lastExecutions.map((execution) => execution.internalId);
|
return lastExecutions.map((execution) => execution.internalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
get IncompleteStepsError() {
|
static get IncompleteStepsError() {
|
||||||
return new ValidationError({
|
return new ValidationError({
|
||||||
data: {
|
data: {
|
||||||
flow: [
|
flow: [
|
||||||
@@ -310,7 +310,7 @@ class Flow extends Base {
|
|||||||
const triggerStep = await this.getTriggerStep();
|
const triggerStep = await this.getTriggerStep();
|
||||||
|
|
||||||
if (triggerStep.status === 'incomplete') {
|
if (triggerStep.status === 'incomplete') {
|
||||||
throw this.IncompleteStepsError;
|
throw Flow.IncompleteStepsError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const trigger = await triggerStep.getTriggerCommand();
|
const trigger = await triggerStep.getTriggerCommand();
|
||||||
|
@@ -142,6 +142,7 @@ describe('Flow model', () => {
|
|||||||
describe('lastInternalIds', () => {
|
describe('lastInternalIds', () => {
|
||||||
it('should return last internal IDs', async () => {
|
it('should return last internal IDs', async () => {
|
||||||
const flow = await createFlow();
|
const flow = await createFlow();
|
||||||
|
|
||||||
const internalIds = [
|
const internalIds = [
|
||||||
await createExecution({ flowId: flow.id }),
|
await createExecution({ flowId: flow.id }),
|
||||||
await createExecution({ flowId: flow.id }),
|
await createExecution({ flowId: flow.id }),
|
||||||
@@ -155,6 +156,7 @@ describe('Flow model', () => {
|
|||||||
const flow = new Flow();
|
const flow = new Flow();
|
||||||
|
|
||||||
const limitSpy = vi.fn().mockResolvedValue([]);
|
const limitSpy = vi.fn().mockResolvedValue([]);
|
||||||
|
|
||||||
vi.spyOn(flow, '$relatedQuery').mockReturnValue({
|
vi.spyOn(flow, '$relatedQuery').mockReturnValue({
|
||||||
select: vi.fn().mockReturnThis(),
|
select: vi.fn().mockReturnThis(),
|
||||||
orderBy: vi.fn().mockReturnThis(),
|
orderBy: vi.fn().mockReturnThis(),
|
||||||
@@ -168,10 +170,8 @@ describe('Flow model', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('IncompleteStepsError should return validation error for incomplete steps', () => {
|
it('IncompleteStepsError should return validation error for incomplete steps', () => {
|
||||||
const flow = new Flow();
|
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
throw flow.IncompleteStepsError;
|
throw Flow.IncompleteStepsError;
|
||||||
}).toThrowError(
|
}).toThrowError(
|
||||||
'flow: All steps should be completed before updating flow status!'
|
'flow: All steps should be completed before updating flow status!'
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user