From 8fa3954ae92ef7e58e9f638b43708ff75608b0ab Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Tue, 17 Jan 2023 13:34:50 +0100 Subject: [PATCH 1/9] change dayservice to be used for NWDs --- .../core/apiv3/endpoints/days/api-v3-days-paths.ts | 3 +++ frontend/src/app/core/state/days/day.service.ts | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/core/apiv3/endpoints/days/api-v3-days-paths.ts b/frontend/src/app/core/apiv3/endpoints/days/api-v3-days-paths.ts index 899c1bb275..509a581a99 100644 --- a/frontend/src/app/core/apiv3/endpoints/days/api-v3-days-paths.ts +++ b/frontend/src/app/core/apiv3/endpoints/days/api-v3-days-paths.ts @@ -47,4 +47,7 @@ export class ApiV3DaysPaths extends ApiV3ResourceCollection // /api/v3/days/week public readonly week = new ApiV3GettableResource(this.apiRoot, this.path, 'week', this); + + // /api/v3/days/nonWorkingDays + public readonly nonWorkingDays = new ApiV3GettableResource(this.apiRoot, this.path, 'non_working', this); } diff --git a/frontend/src/app/core/state/days/day.service.ts b/frontend/src/app/core/state/days/day.service.ts index 2f96090e5f..657b6fb653 100644 --- a/frontend/src/app/core/state/days/day.service.ts +++ b/frontend/src/app/core/state/days/day.service.ts @@ -12,7 +12,6 @@ import { } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface'; import { collectionKey, - extendCollectionElementsWithId, insertCollectionIntoState, removeCollectionLoading, setCollectionLoading, @@ -30,6 +29,7 @@ export class DayResourceService extends ResourceCollectionService { return this .apiV3Service .days + .nonWorkingDays .path; } @@ -39,17 +39,22 @@ export class DayResourceService extends ResourceCollectionService { return this .requireNonWorkingYear$(input) .pipe( - map((days) => days.findIndex((day:IDay) => !day.working && day.date === date) !== -1), + map((days) => days.findIndex((day:IDay) => day.date === date) !== -1), ); } + public isNonWorkingDay(date:Date):boolean { + let isNonWorkingDay = false; + this.isNonWorkingDay$(date).subscribe((isNonWorking) => { isNonWorkingDay = isNonWorking; }); + return isNonWorkingDay; + } + requireNonWorkingYear$(date:Date):Observable { const from = moment(date).startOf('year').format('YYYY-MM-DD'); const to = moment(date).endOf('year').format('YYYY-MM-DD'); const filters:ApiV3ListFilter[] = [ ['date', '<>d', [from, to]], - ['working', '=', ['f']], ]; return this.require({ filters }); @@ -64,7 +69,6 @@ export class DayResourceService extends ResourceCollectionService { .http .get>(this.basePath() + collectionURL) .pipe( - map((collection) => extendCollectionElementsWithId(collection)), tap((collection) => insertCollectionIntoState(this.store, collection, collectionURL)), finalize(() => removeCollectionLoading(this.store, collectionURL)), ); From 60733364c49fb3e2459662623b972113bce73b05 Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Tue, 17 Jan 2023 13:44:18 +0100 Subject: [PATCH 2/9] check if a date is non-working with weekayService and dayService on gantt chart --- .../wp-table/timeline/cells/timeline-cell-renderer.ts | 10 +++++++--- .../timeline/grid/wp-timeline-grid.directive.ts | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts index 4b1b6b17ef..ca040d10e0 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts @@ -21,6 +21,7 @@ import { timelineMarkerSelectionStartClass, } from '../wp-timeline'; import Moment = moment.Moment; +import { DayResourceService } from 'core-app/core/state/days/day.service'; export interface CellDateMovement { // Target values to move work package to @@ -51,6 +52,8 @@ export class TimelineCellRenderer { @InjectField() weekdayService:WeekdayService; + @InjectField() dayService:DayResourceService; + @InjectField() schemaCache:SchemaCacheService; @InjectField() I18n!:I18nService; @@ -321,7 +324,7 @@ export class TimelineCellRenderer { break; } // Extend the duration if the currentDate is non-working - if (this.weekdayService.isNonWorkingDay(currentDate.toDate())) { + if (this.weekdayService.isNonWorkingDay(currentDate.toDate()) || this.dayService.isNonWorkingDay(currentDate.toDate())) { duration += 1; } } @@ -472,10 +475,11 @@ export class TimelineCellRenderer { const dates = (evOrDates instanceof MouseEvent) ? [this.cursorDateAndDayOffset(evOrDates, renderInfo)[0]] : evOrDates; - if (!renderInfo.workPackage.ignoreNonWorkingDays && direction === 'both' && this.weekdayService.isNonWorkingDay(dates[dates.length - 1].toDate())) { + if (!renderInfo.workPackage.ignoreNonWorkingDays && direction === 'both' + && (this.weekdayService.isNonWorkingDay(dates[dates.length - 1].toDate()) || this.dayService.isNonWorkingDay(dates[dates.length - 1].toDate()))) { return false; } - return dates.some((date) => this.weekdayService.isNonWorkingDay(date.toDate())); + return dates.some((date) => (this.weekdayService.isNonWorkingDay(date.toDate()) || this.dayService.isNonWorkingDay(date.toDate()))); } /** diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts index 70540d3532..73daac5cee 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts @@ -42,6 +42,7 @@ import { } from '../wp-timeline'; import { WeekdayService } from 'core-app/core/days/weekday.service'; import Moment = moment.Moment; +import { DayResourceService } from 'core-app/core/state/days/day.service'; @Component({ selector: 'wp-timeline-grid', @@ -56,6 +57,7 @@ export class WorkPackageTableTimelineGrid implements AfterViewInit { private elementRef:ElementRef, public wpTimeline:WorkPackageTimelineTableController, private weekdaysService:WeekdayService, + private daysService:DayResourceService, ) {} ngAfterViewInit():void { @@ -188,7 +190,7 @@ export class WorkPackageTableTimelineGrid implements AfterViewInit { private checkForNonWorkingDayHighlight(date:Moment, cell:HTMLElement) { const day = date.toDate(); - if (this.weekdaysService.isNonWorkingDay(day)) { + if (this.weekdaysService.isNonWorkingDay(day) || this.daysService.isNonWorkingDay(day)) { cell.classList.add('wp-timeline--non-working-day'); cell.dataset.qaSelector = `wp-timeline--non-working-day_${day.getDate()}-${day.getMonth() + 1}-${day.getFullYear()}`; } From fa404f1405811268ba20cdaafa7d686dd7b71f19 Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Mon, 30 Jan 2023 12:54:27 +0100 Subject: [PATCH 3/9] add a method to day service to fetch NWds of two dates in different years --- frontend/src/app/core/state/days/day.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/src/app/core/state/days/day.service.ts b/frontend/src/app/core/state/days/day.service.ts index c2c7968974..a4150db72b 100644 --- a/frontend/src/app/core/state/days/day.service.ts +++ b/frontend/src/app/core/state/days/day.service.ts @@ -57,6 +57,17 @@ export class DayResourceService extends ResourceCollectionService { return this.require({ filters }); } + requireNonWorkingYears$(start:Date|string, end:Date|string):Observable { + const from = moment(start).startOf('year').format('YYYY-MM-DD'); + const to = moment(end).endOf('year').format('YYYY-MM-DD'); + + const filters:ApiV3ListFilter[] = [ + ['date', '<>d', [from, to]], + ]; + + return this.require({ filters }); + } + fetchCollection(params:ApiV3ListParameters):Observable> { const collectionURL = collectionKey(params); From 2e760c3918c47de8a89c372d9b73b6890af46147 Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Mon, 30 Jan 2023 13:14:59 +0100 Subject: [PATCH 4/9] wait until NWDs of a view are fetched then refresh view --- .../wp-timeline-container.directive.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts index b19c7e7ec6..0d4acf175e 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts @@ -34,7 +34,7 @@ import { IToast, ToastService } from 'core-app/shared/components/toaster/toast.s import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource'; import * as moment from 'moment'; import { Moment } from 'moment'; -import { filter, takeUntil } from 'rxjs/operators'; +import { filter, takeUntil, take } from 'rxjs/operators'; import { input, InputState } from 'reactivestates'; import { WorkPackageTable } from 'core-app/features/work-packages/components/wp-fast-table/wp-fast-table'; import { WorkPackageTimelineCellsRenderer } from 'core-app/features/work-packages/components/wp-table/timeline/cells/wp-timeline-cells-renderer'; @@ -68,6 +68,8 @@ import { } from '../wp-timeline'; import { WeekdayService } from 'core-app/core/days/weekday.service'; import * as Mousetrap from 'mousetrap'; +import { DayResourceService } from 'core-app/core/state/days/day.service'; +import { IDay } from 'core-app/core/state/days/day.model'; @Component({ selector: 'wp-timeline-container', @@ -137,6 +139,7 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl readonly I18n:I18nService, private workPackageViewCollapsedGroupsService:WorkPackageViewCollapsedGroupsService, private weekdaysService:WeekdayService, + private daysService:DayResourceService, ) { super(); } @@ -176,6 +179,8 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl this.setupManageCollapsedGroupHeaderCells(); } + public nonWorkingDays:IDay[] = []; + workPackageCells(wpId:string):WorkPackageTimelineCell[] { return this.cellsRenderer.getCellsFor(wpId); } @@ -225,12 +230,14 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl this.wpTableTimeline.appliedZoomLevel = this.wpTableTimeline.zoomLevel; } - timeOutput('refreshView() in timeline container', () => { + timeOutput('refreshView() in timeline container', async () => { // Reset the width of the outer container if its content shrinks this.outerContainer.css('width', 'auto'); this.calculateViewParams(this._viewParameters); + await this.requireNonWorkingDays(this._viewParameters.visibleViewportAtCalculationTime[0].format('YYYY-MM-DD'), this._viewParameters.visibleViewportAtCalculationTime[1].format('YYYY-MM-DD')); + // Update all cells this.cellsRenderer.refreshAllCells(); @@ -348,6 +355,19 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl this.refreshView(); } + async requireNonWorkingDays(start:Date|string, end:Date|string) { + this.nonWorkingDays = await this + .daysService + .requireNonWorkingYears$(start, end) + .pipe(take(1)) + .toPromise(); + } + + isNonWorkingDay(date:Date|string):boolean { + const formatted = moment(date).format('YYYY-MM-DD'); + return (this.nonWorkingDays.findIndex((el) => el.date === formatted) !== -1); + } + private calculateViewParams(currentParams:TimelineViewParameters):boolean { if (this.disableViewParamsCalculation) { return false; From 1c3f5f4807f56326f92fe3147ee16d06ae61c304 Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Mon, 30 Jan 2023 13:18:58 +0100 Subject: [PATCH 5/9] check NWDs on Gantt chart --- .../wp-table/timeline/cells/timeline-cell-renderer.ts | 6 +++--- .../wp-table/timeline/grid/wp-timeline-grid.directive.ts | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts index ca040d10e0..8b350fd684 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts @@ -324,7 +324,7 @@ export class TimelineCellRenderer { break; } // Extend the duration if the currentDate is non-working - if (this.weekdayService.isNonWorkingDay(currentDate.toDate()) || this.dayService.isNonWorkingDay(currentDate.toDate())) { + if (this.weekdayService.isNonWorkingDay(currentDate.toDate() || this.workPackageTimeline.isNonWorkingDay(currentDate.toDate()))) { duration += 1; } } @@ -476,10 +476,10 @@ export class TimelineCellRenderer { ? [this.cursorDateAndDayOffset(evOrDates, renderInfo)[0]] : evOrDates; if (!renderInfo.workPackage.ignoreNonWorkingDays && direction === 'both' - && (this.weekdayService.isNonWorkingDay(dates[dates.length - 1].toDate()) || this.dayService.isNonWorkingDay(dates[dates.length - 1].toDate()))) { + && (this.weekdayService.isNonWorkingDay(dates[dates.length - 1].toDate() || this.workPackageTimeline.isNonWorkingDay(dates[dates.length - 1].toDate())))) { return false; } - return dates.some((date) => (this.weekdayService.isNonWorkingDay(date.toDate()) || this.dayService.isNonWorkingDay(date.toDate()))); + return dates.some((date) => (this.weekdayService.isNonWorkingDay(date.toDate()) || this.workPackageTimeline.isNonWorkingDay(date.toDate()))); } /** diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts index 73daac5cee..6454cd6907 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts @@ -189,8 +189,7 @@ export class WorkPackageTableTimelineGrid implements AfterViewInit { private checkForNonWorkingDayHighlight(date:Moment, cell:HTMLElement) { const day = date.toDate(); - - if (this.weekdaysService.isNonWorkingDay(day) || this.daysService.isNonWorkingDay(day)) { + if (this.weekdaysService.isNonWorkingDay(day) || this.wpTimeline.isNonWorkingDay(day)) { cell.classList.add('wp-timeline--non-working-day'); cell.dataset.qaSelector = `wp-timeline--non-working-day_${day.getDate()}-${day.getMonth() + 1}-${day.getFullYear()}`; } From bd1a52234cdc378747cdf1d12d21344757938bae Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Tue, 31 Jan 2023 09:04:29 +0100 Subject: [PATCH 6/9] remove unnecessary imports --- .../wp-table/timeline/cells/timeline-cell-renderer.ts | 3 --- .../container/wp-timeline-container.directive.ts | 9 ++++++++- .../wp-table/timeline/grid/wp-timeline-grid.directive.ts | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts index 8b350fd684..5fe6d7d9e5 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/cells/timeline-cell-renderer.ts @@ -21,7 +21,6 @@ import { timelineMarkerSelectionStartClass, } from '../wp-timeline'; import Moment = moment.Moment; -import { DayResourceService } from 'core-app/core/state/days/day.service'; export interface CellDateMovement { // Target values to move work package to @@ -52,8 +51,6 @@ export class TimelineCellRenderer { @InjectField() weekdayService:WeekdayService; - @InjectField() dayService:DayResourceService; - @InjectField() schemaCache:SchemaCacheService; @InjectField() I18n!:I18nService; diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts index 0d4acf175e..58e7731a6a 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts @@ -147,6 +147,13 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl ngAfterViewInit() { this.$element = jQuery(this.elementRef.nativeElement); + const scrollBar = document.querySelector('.work-packages-tabletimeline--timeline-side'); + if (scrollBar) { + scrollBar.addEventListener("scroll", async () => { + await this.requireNonWorkingDays(this.getFirstDayInViewport().format('YYYY-MM-DD'), this.getLastDayInViewport().format('YYYY-MM-DD')); + }) + } + this.text = { selectionMode: this.I18n.t('js.timelines.selection_mode.notification'), }; @@ -236,7 +243,7 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl this.calculateViewParams(this._viewParameters); - await this.requireNonWorkingDays(this._viewParameters.visibleViewportAtCalculationTime[0].format('YYYY-MM-DD'), this._viewParameters.visibleViewportAtCalculationTime[1].format('YYYY-MM-DD')); + await this.requireNonWorkingDays(this.getFirstDayInViewport().format('YYYY-MM-DD'), this.getLastDayInViewport().format('YYYY-MM-DD')); // Update all cells this.cellsRenderer.refreshAllCells(); diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts index 6454cd6907..4cd244e7b3 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/grid/wp-timeline-grid.directive.ts @@ -42,7 +42,6 @@ import { } from '../wp-timeline'; import { WeekdayService } from 'core-app/core/days/weekday.service'; import Moment = moment.Moment; -import { DayResourceService } from 'core-app/core/state/days/day.service'; @Component({ selector: 'wp-timeline-grid', @@ -57,7 +56,6 @@ export class WorkPackageTableTimelineGrid implements AfterViewInit { private elementRef:ElementRef, public wpTimeline:WorkPackageTimelineTableController, private weekdaysService:WeekdayService, - private daysService:DayResourceService, ) {} ngAfterViewInit():void { From 271e81c53a911a4545f4d3a49695efd1066e659f Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Tue, 31 Jan 2023 10:39:39 +0100 Subject: [PATCH 7/9] eslint errors --- .../timeline/container/wp-timeline-container.directive.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts index 58e7731a6a..5f45d86233 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts @@ -149,9 +149,9 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl const scrollBar = document.querySelector('.work-packages-tabletimeline--timeline-side'); if (scrollBar) { - scrollBar.addEventListener("scroll", async () => { - await this.requireNonWorkingDays(this.getFirstDayInViewport().format('YYYY-MM-DD'), this.getLastDayInViewport().format('YYYY-MM-DD')); - }) + scrollBar.addEventListener('scroll', () => { + this.requireNonWorkingDays(this.getFirstDayInViewport().format('YYYY-MM-DD'), this.getLastDayInViewport().format('YYYY-MM-DD')); + }); } this.text = { From f6695495e4a46331e9aeab937378d427a527bb39 Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Tue, 31 Jan 2023 14:24:34 +0100 Subject: [PATCH 8/9] add a test to check if NWDs are correctly highlighted on gantt chart --- .../timeline/container/wp-timeline-container.directive.ts | 2 +- spec/features/work_packages/timeline/timeline_dates_spec.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts index 5f45d86233..6028c2bfe6 100644 --- a/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts +++ b/frontend/src/app/features/work-packages/components/wp-table/timeline/container/wp-timeline-container.directive.ts @@ -150,7 +150,7 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl const scrollBar = document.querySelector('.work-packages-tabletimeline--timeline-side'); if (scrollBar) { scrollBar.addEventListener('scroll', () => { - this.requireNonWorkingDays(this.getFirstDayInViewport().format('YYYY-MM-DD'), this.getLastDayInViewport().format('YYYY-MM-DD')); + this.requireNonWorkingDays(this.getFirstDayInViewport().format('YYYY-MM-DD'), this.getLastDayInViewport().format('YYYY-MM-DD')); }); } diff --git a/spec/features/work_packages/timeline/timeline_dates_spec.rb b/spec/features/work_packages/timeline/timeline_dates_spec.rb index fe475ec2b8..255d8ed3fb 100644 --- a/spec/features/work_packages/timeline/timeline_dates_spec.rb +++ b/spec/features/work_packages/timeline/timeline_dates_spec.rb @@ -125,14 +125,18 @@ RSpec.describe 'Work package timeline date formatting', let(:current_user) { create :admin, language: 'en' } shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend } + shared_let(:non_working_day) do + create(:non_working_day, + date: '28-12-2020') + end it 'shows them as disabled' do expect_date_week work_package.start_date.iso8601, '01' expect(page).to have_selector('[data-qa-selector="wp-timeline--non-working-day_27-12-2020"]') expect(page).to have_selector('[data-qa-selector="wp-timeline--non-working-day_2-1-2021"]') + expect(page).to have_selector('[data-qa-selector="wp-timeline--non-working-day_28-12-2020"]') - expect(page).to have_no_selector('[data-qa-selector="wp-timeline--non-working-day_28-12-2020"]') expect(page).to have_no_selector('[data-qa-selector="wp-timeline--non-working-day_29-12-2020"]') expect(page).to have_no_selector('[data-qa-selector="wp-timeline--non-working-day_30-12-2020"]') expect(page).to have_no_selector('[data-qa-selector="wp-timeline--non-working-day_31-12-2020"]') From 20756c93ac9e28eb55e0e25a8fe731976a5ab54d Mon Sep 17 00:00:00 2001 From: bsatarnejad Date: Wed, 1 Feb 2023 07:49:55 +0100 Subject: [PATCH 9/9] update timeline tetst to set dates with an instance-wide holiday --- .../work_packages/timeline/timeline_dates_spec.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spec/features/work_packages/timeline/timeline_dates_spec.rb b/spec/features/work_packages/timeline/timeline_dates_spec.rb index 255d8ed3fb..a5cbc4a609 100644 --- a/spec/features/work_packages/timeline/timeline_dates_spec.rb +++ b/spec/features/work_packages/timeline/timeline_dates_spec.rb @@ -175,6 +175,11 @@ RSpec.describe 'Work package timeline date formatting', let(:current_user) { create :admin } let(:row) { wp_timeline.timeline_row work_package_with_non_working_days.id } + shared_let(:non_working_day) do + create(:non_working_day, + date: '06-01-2021') + end + shared_examples "sets dates, duration and displays bar" do it 'sets dates, duration and duration bar' do subject @@ -228,7 +233,7 @@ RSpec.describe 'Work package timeline date formatting', let(:expected_bar_duration) { work_package_with_non_working_days.duration } let(:expected_start_date) { Date.parse('2021-01-04') } let(:expected_due_date) { Date.parse('2021-01-08') } - let(:expected_duration) { 5 } + let(:expected_duration) { 4 } let(:expected_label) { work_package_with_non_working_days.subject } end end @@ -241,7 +246,7 @@ RSpec.describe 'Work package timeline date formatting', let(:expected_bar_duration) { work_package_with_non_working_days.duration + 2 } let(:expected_start_date) { Date.parse('2021-01-05') } let(:expected_due_date) { Date.parse('2021-01-11') } - let(:expected_duration) { 5 } + let(:expected_duration) { 4 } let(:expected_label) { work_package_with_non_working_days.subject } end end @@ -254,7 +259,7 @@ RSpec.describe 'Work package timeline date formatting', let(:expected_bar_duration) { work_package_with_non_working_days.duration } let(:expected_start_date) { Date.parse('2021-01-04') } let(:expected_due_date) { Date.parse('2021-01-08') } - let(:expected_duration) { 5 } + let(:expected_duration) { 4 } let(:expected_label) { work_package_with_non_working_days.subject } end end @@ -267,7 +272,7 @@ RSpec.describe 'Work package timeline date formatting', let(:expected_bar_duration) { work_package_with_non_working_days.duration + 2 } let(:expected_start_date) { Date.parse('2021-01-05') } let(:expected_due_date) { Date.parse('2021-01-11') } - let(:expected_duration) { 5 } + let(:expected_duration) { 4 } let(:expected_label) { work_package_with_non_working_days.subject } end end @@ -280,7 +285,7 @@ RSpec.describe 'Work package timeline date formatting', let(:expected_bar_duration) { work_package_with_non_working_days.duration + 3 } let(:expected_start_date) { Date.parse('2021-01-05') } let(:expected_due_date) { Date.parse('2021-01-12') } - let(:expected_duration) { 6 } + let(:expected_duration) { 5 } let(:expected_label) { work_package_with_non_working_days.subject } end end