From c678c55a5df0705ac8f0aa7223966799616772cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anderson=20Greg=C3=B3rio?= Date: Thu, 5 Dec 2024 18:38:52 -0300 Subject: [PATCH] fix(page-job-scheduler): corrige erro quando 'firstExecution' undefined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrigo erro quando 'firstExecution' é definido como undefined fixes DTHFUI-10385 --- .../po-page-job-scheduler.component.spec.ts | 18 ++++++++++ .../po-page-job-scheduler.service.spec.ts | 34 +++++++++++++++++++ .../po-page-job-scheduler.service.ts | 4 +++ 3 files changed, 56 insertions(+) diff --git a/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.component.spec.ts b/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.component.spec.ts index 4b9f84bb3b..0401ba7206 100644 --- a/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.component.spec.ts +++ b/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.component.spec.ts @@ -786,4 +786,22 @@ describe('PoPageJobSchedulerComponent:', () => { expect(executionElementHiddenAttribute).toBeFalsy(); }); }); + + it(`getSteps: should use 'literals' when the parameterization step title is not defined`, () => { + const mock = Object.assign(new QueryList(), { + _results: [{}, {}], + length: 1 + }) as QueryList; + + component.parametersTemplate = mock; + component['getSteps'](); + + const result = component['steps'].slice(1, -1); + const resultExpected = [ + { label: `${component['literals']['parameterization']} 1` }, + { label: `${component['literals']['parameterization']} 2` } + ]; + + expect(result).toEqual(resultExpected); + }); }); diff --git a/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.spec.ts b/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.spec.ts index 3ab89e6226..e2bc5d22af 100644 --- a/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.spec.ts +++ b/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.spec.ts @@ -379,6 +379,25 @@ describe('PoPageJobSchedulerService:', () => { expect(poPageJobSchedulerService['removeInvalidKeys']).toHaveBeenCalledWith(jobSchedulerInternal); }); + it(`convertToJobScheduler: should ignore when 'firstExecutionHour' is set but 'firstExecution' is not set`, () => { + const jobSchedulerInternal = { + executionParameter: 'value', + firstExecution: undefined, + firstExecutionHour: '15:30', + processID: '1' + }; + + const jobSchedulerInternalExpected = { + executionParameter: 'value', + firstExecution: undefined, + processID: '1' + }; + + const result = poPageJobSchedulerService['convertToJobScheduler'](jobSchedulerInternal); + + expect(result).toEqual(jobSchedulerInternalExpected); + }); + it(`convertToJobSchedulerInternal: should set 'jobSchedulerInternal.firstExecutionHour' with 'getHourFirstExecution' return if 'firstExecution' is defined`, () => { const jobSchedulerInternal = { @@ -483,6 +502,7 @@ describe('PoPageJobSchedulerService:', () => { expect(result).toEqual(jobSchedulerInternalExpected); }); + it(`convertToJobSchedulerInternal: should return the merge between 'jobSchedulerInternal' and the return from 'convertToPeriodicityInternal'`, () => { const jobSchedulerInternal = { @@ -788,6 +808,20 @@ describe('PoPageJobSchedulerService:', () => { ); }); + it(`replaceHourFirstExecution: should replace hour add time zone`, () => { + const initialDate = new Date(2025, 11, 24, 23, 59, 0); + const isoDate = initialDate.toISOString(); + const stringDate = initialDate.toString(); + + const timeToReplace = '23:59'; + const timeZone = `${stringDate.substring(28, 31)}:${stringDate.substring(31, 33)}`; + const result = `2025-12-25T23:59:00${timeZone}`; + + poPageJobSchedulerService['replaceHourFirstExecution'](isoDate, timeToReplace); + + expect(poPageJobSchedulerService['replaceHourFirstExecution'](isoDate, timeToReplace)).toBe(result); + }); + it('returnValidExecutionParameter: should remove keys that have undefined value', () => { const parameter = { numberKey: 1, diff --git a/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.ts b/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.ts index 2a2c6d7ed9..319f51b764 100644 --- a/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.ts +++ b/projects/templates/src/lib/components/po-page-job-scheduler/po-page-job-scheduler.service.ts @@ -232,6 +232,10 @@ export class PoPageJobSchedulerService { } private replaceHourFirstExecution(date: string, time: string): string { + if (!date) { + return date; + } + const dateSplited = date.split('-'); const year = parseInt(dateSplited[0]); const monthIndex = parseInt(dateSplited[1]) - 1;