Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

test that resources/events are dropped if filtered in split view

Oliver Günther704fea78dd93
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
index 42fa0f7b3d0..ed217ff0105 100644
--- a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
+++ b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
@@ -40,7 +40,10 @@ import {
HalEvent,
HalEventsService,
} from 'core-app/features/hal/services/hal-events.service';
-import { map } from 'rxjs/operators';
+import {
+ map,
+ withLatestFrom,
+} from 'rxjs/operators';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';
@@ -85,7 +88,6 @@ export class TeamPlannerComponent extends UntilDestroyedMixin {
ngOnInit() {
this.setupWorkPackagesListener();
- this.setupHalEventsListener();
this.initializeCalendar();
this.projectIdentifier = this.currentProject.identifier;
}
@@ -97,6 +99,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin {
):void|PromiseLike<EventInput[]> {
this
.currentWorkPackages()
+ .toPromise()
.then((workPackages) => {
const resources = this.mapToCalendarResources(workPackages);
successCallback(resources);
@@ -111,6 +114,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin {
):void|PromiseLike<EventInput[]> {
this
.currentWorkPackages()
+ .toPromise()
.then((workPackages) => {
const events = this.mapToCalendarEvents(workPackages);
successCallback(events);
@@ -120,7 +124,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin {
this.updateTimeframe(fetchInfo);
}
- private currentWorkPackages():Promise<WorkPackageResource[]> {
+ private currentWorkPackages():Observable<WorkPackageResource[]> {
return this
.querySpace
.results
@@ -132,8 +136,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin {
.elements
.map((wp) => this.apiV3Service.work_packages.cache.current(wp.id as string, wp) as WorkPackageResource)
)),
- )
- .toPromise();
+ );
}
private initializeCalendar() {
@@ -235,20 +238,6 @@ export class TeamPlannerComponent extends UntilDestroyedMixin {
this.ucCalendar.getApi().refetchResources();
}
- /**
- * Update events and resources on external updates
- */
- private setupHalEventsListener() {
- this.halEvents
- .aggregated$('WorkPackage')
- .pipe(
- this.untilDestroyed(),
- )
- .subscribe(() => {
- this.renderCurrent();
- });
- }
-
private mapToCalendarEvents(workPackages:WorkPackageResource[]):EventInput[] {
return workPackages
.map((workPackage:WorkPackageResource) => {
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts
index cd354c22dd0..d531e4a8da2 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts
@@ -232,7 +232,11 @@ export abstract class WorkPackagesViewBase extends UntilDestroyedMixin implement
* @return {boolean} whether any of these events should trigger the view reloading
*/
protected filterRefreshEvents(events:HalEvent[]):boolean {
- const rendered = new Set(this.querySpace.renderedWorkPackageIds.getValueOr([]));
+ const source:string[] = this.querySpace.renderedWorkPackageIds.value
+ || this.querySpace.results.value?.elements.map((el) => el.id as string)
+ || [];
+
+ const rendered = new Set(source);
for (let i = 0; i < events.length; i++) {
const item = events[i];
diff --git a/modules/team_planner/spec/features/team_planner_spec.rb b/modules/team_planner/spec/features/team_planner_spec.rb
index 24484db3f25..5c0916cc794 100644
--- a/modules/team_planner/spec/features/team_planner_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_spec.rb
@@ -39,7 +39,9 @@ describe 'Team planner', type: :feature, js: true do
shared_let(:user) do
FactoryBot.create :user,
member_in_project: project,
- member_with_permissions: %w[view_work_packages view_team_planner manage_team_planner]
+ member_with_permissions: %w[
+ view_work_packages edit_work_packages view_team_planner manage_team_planner
+ ]
end
let(:team_planner) { ::Pages::TeamPlanner.new project }
@@ -137,6 +139,14 @@ describe 'Team planner', type: :feature, js: true do
team_planner.expect_event other_task
team_planner.expect_event other_bug, present: false
end
+
+ # Open the split view for that task and change to bug
+ split_view = team_planner.open_split_view(other_task)
+ split_view.edit_field(:type).update(type_bug)
+ split_view.expect_and_dismiss_toaster(message: "Successful update.")
+
+ team_planner.expect_assignee(user, present: false)
+ team_planner.expect_assignee(other_user, present: false)
end
end
end
diff --git a/modules/team_planner/spec/support/pages/team_planner.rb b/modules/team_planner/spec/support/pages/team_planner.rb
index 78786102617..0e995fd0c7d 100644
--- a/modules/team_planner/spec/support/pages/team_planner.rb
+++ b/modules/team_planner/spec/support/pages/team_planner.rb
@@ -65,5 +65,13 @@ module Pages
def expect_event(work_package, present: true)
expect(page).to have_conditional_selector(present, '.fc-event', text: work_package.subject)
end
+
+ def open_split_view(work_package)
+ page
+ .find('.fc-event', text: work_package.subject)
+ .click
+
+ ::Pages::SplitWorkPackage.new(work_package, project)
+ end
end
end