From 4ce9976dbc64d5943c1f2e6e54a135845cbb4200 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Wed, 9 Oct 2024 15:41:27 +0200 Subject: [PATCH] refactor: Use isSucceededNonTestRun naming for execution steps --- packages/backend/src/models/execution-step.js | 4 ++-- .../backend/src/models/execution-step.test.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/models/execution-step.js b/packages/backend/src/models/execution-step.js index 7d8de60c..b17343bb 100644 --- a/packages/backend/src/models/execution-step.js +++ b/packages/backend/src/models/execution-step.js @@ -47,7 +47,7 @@ class ExecutionStep extends Base { return this.status === 'failure'; } - async isNormalSucceededRun() { + async isSucceededNonTestRun() { const execution = await this.$relatedQuery('execution'); return !execution.testRun && !this.isFailed; } @@ -63,7 +63,7 @@ class ExecutionStep extends Base { } async increaseUsageCount() { - if (appConfig.isCloud && this.isNormalSucceededRun()) { + if (appConfig.isCloud && this.isSucceededNonTestRun()) { await this.updateUsageData(); } } diff --git a/packages/backend/src/models/execution-step.test.js b/packages/backend/src/models/execution-step.test.js index 2865bd91..4ca9301e 100644 --- a/packages/backend/src/models/execution-step.test.js +++ b/packages/backend/src/models/execution-step.test.js @@ -61,7 +61,7 @@ describe('ExecutionStep model', () => { }); }); - describe('isNormalSuccededRun', () => { + describe('isSucceededNonTestRun', () => { it('should return false if it has a test run execution', async () => { const execution = await createExecution({ testRun: true, @@ -71,7 +71,7 @@ describe('ExecutionStep model', () => { executionId: execution.id, }); - expect(await executionStep.isNormalSucceededRun()).toBe(false); + expect(await executionStep.isSucceededNonTestRun()).toBe(false); }); it('should return false if it has a failure status', async () => { @@ -79,15 +79,15 @@ describe('ExecutionStep model', () => { status: 'failure', }); - expect(await executionStep.isNormalSucceededRun()).toBe(false); + expect(await executionStep.isSucceededNonTestRun()).toBe(false); }); - it('should return true if it has a succeeded normal execution', async () => { + it('should return true if it has a succeeded non test run', async () => { const executionStep = await createExecutionStep({ status: 'success', }); - expect(await executionStep.isNormalSucceededRun()).toBe(true); + expect(await executionStep.isSucceededNonTestRun()).toBe(true); }); }); @@ -107,11 +107,12 @@ describe('ExecutionStep model', () => { }); describe('increaseUsageCount', () => { - it('should call updateUsageData for cloud and normal succeeded run', async () => { + it('should call updateUsageData for cloud and succeeded non test run', async () => { vi.spyOn(appConfig, 'isCloud', 'get').mockReturnValue(true); - vi.spyOn(ExecutionStep.prototype, 'isNormalSucceededRun').mockReturnValue( - true - ); + vi.spyOn( + ExecutionStep.prototype, + 'isSucceededNonTestRun' + ).mockReturnValue(true); const executionStep = await createExecutionStep();