refactor: Use static method for IncompleteStepsError

This commit is contained in:
Faruk AYDIN
2024-10-30 14:33:52 +01:00
parent d38b0f088b
commit 5bdc5aed72
2 changed files with 5 additions and 5 deletions

View File

@@ -123,7 +123,7 @@ class Flow extends Base {
return lastExecutions.map((execution) => execution.internalId);
}
get IncompleteStepsError() {
static get IncompleteStepsError() {
return new ValidationError({
data: {
flow: [
@@ -310,7 +310,7 @@ class Flow extends Base {
const triggerStep = await this.getTriggerStep();
if (triggerStep.status === 'incomplete') {
throw this.IncompleteStepsError;
throw Flow.IncompleteStepsError;
}
const trigger = await triggerStep.getTriggerCommand();

View File

@@ -142,6 +142,7 @@ describe('Flow model', () => {
describe('lastInternalIds', () => {
it('should return last internal IDs', async () => {
const flow = await createFlow();
const internalIds = [
await createExecution({ flowId: flow.id }),
await createExecution({ flowId: flow.id }),
@@ -155,6 +156,7 @@ describe('Flow model', () => {
const flow = new Flow();
const limitSpy = vi.fn().mockResolvedValue([]);
vi.spyOn(flow, '$relatedQuery').mockReturnValue({
select: vi.fn().mockReturnThis(),
orderBy: vi.fn().mockReturnThis(),
@@ -168,10 +170,8 @@ describe('Flow model', () => {
});
it('IncompleteStepsError should return validation error for incomplete steps', () => {
const flow = new Flow();
expect(() => {
throw flow.IncompleteStepsError;
throw Flow.IncompleteStepsError;
}).toThrowError(
'flow: All steps should be completed before updating flow status!'
);