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

Fix tests

Oliver Güntherf98f98e833df
diff --git a/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
index b24dc90249b..04ffeceab0a 100644
--- a/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
@@ -1,10 +1,8 @@
import {Injectable} from "@angular/core";
-import {BoardActionService} from "core-app/modules/boards/board/board-actions/board-action.service";
import {UserResource} from 'core-app/modules/hal/resources/user-resource';
import {CollectionResource} from 'core-app/modules/hal/resources/collection-resource';
import {AssigneeBoardHeaderComponent} from "core-app/modules/boards/board/board-actions/assignee/assignee-board-header.component";
import {ProjectResource} from "core-app/modules/hal/resources/project-resource";
-import {StatusResource} from "core-app/modules/hal/resources/status-resource";
import {CachedBoardActionService} from "core-app/modules/boards/board/board-actions/cached-board-action.service";
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
diff --git a/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
index 67154063207..84df7b97ddf 100644
--- a/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
@@ -64,14 +64,19 @@ export abstract class BoardActionService {
* @param query
* @returns The id of the resource
*/
- getActionValueId(query:QueryResource):string|undefined {
+ getActionValueId(query:QueryResource, getHref = false):string|undefined {
const filter = _.find(query.filters, filter => filter.id === this.filterName);
- if (filter) {
- const value = filter.values[0] as string|HalResource;
- return (value instanceof HalResource) ? value.id! : value;
+ if (!filter) {
+ return;
}
- return;
+ const value = filter.values[0] as string|HalResource;
+
+ if (value instanceof HalResource) {
+ return getHref ? value.href! : value.id!;
+ }
+
+ return value;
}
/**
diff --git a/frontend/src/app/modules/boards/board/board-actions/cached-board-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/cached-board-action.service.ts
index 48013dde6dc..e0ee154b739 100644
--- a/frontend/src/app/modules/boards/board/board-actions/cached-board-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/cached-board-action.service.ts
@@ -7,7 +7,7 @@ import {filter, map, take} from "rxjs/operators";
@Injectable()
export abstract class CachedBoardActionService extends BoardActionService {
- protected cache = input<HalResource[]>([]);
+ protected cache = input<HalResource[]>();
protected loadValues(matching?:string):Observable<HalResource[]> {
this
@@ -37,6 +37,9 @@ export abstract class CachedBoardActionService extends BoardActionService {
return this
.cache
.values$()
+ .pipe(
+ take(1)
+ )
.toPromise()
.then(results => {
return results.find(resource => resource.id === id)!;
diff --git a/frontend/src/app/modules/boards/board/board-actions/subproject/subproject-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/subproject/subproject-action.service.ts
index a661a344f56..249ef1ce20b 100644
--- a/frontend/src/app/modules/boards/board/board-actions/subproject/subproject-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/subproject/subproject-action.service.ts
@@ -22,8 +22,6 @@ export class BoardSubprojectActionService extends CachedBoardActionService {
icon = 'icon-projects';
- private subprojects = input<HalResource[]>();
-
get localizedName() {
return this.I18n.t('js.work_packages.properties.subproject');
}
@@ -39,7 +37,7 @@ export class BoardSubprojectActionService extends CachedBoardActionService {
}
assignToWorkPackage(changeset:WorkPackageChangeset, query:QueryResource) {
- const href = this.getActionValueId(query);
+ const href = this.getActionValueId(query, true);
changeset.setValue('project', { href: href });
}
diff --git a/modules/boards/spec/features/action_boards/subproject_board_spec.rb b/modules/boards/spec/features/action_boards/subproject_board_spec.rb
index afc3df21f13..562e2342946 100644
--- a/modules/boards/spec/features/action_boards/subproject_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/subproject_board_spec.rb
@@ -159,10 +159,9 @@ describe 'Subproject action board', type: :feature, js: true do
board_page.expect_card('Child 2', 'Task 1', present: true)
# Expect work package to be saved in query second
- sleep 2
retry_block do
- expect(first.reload.ordered_work_packages).to be_empty
- expect(second.reload.ordered_work_packages.count).to eq(1)
+ raise "first should be empty" if first.reload.ordered_work_packages.any?
+ raise "second should have one item" if second.reload.ordered_work_packages.count != 1
end
subjects = WorkPackage.where(id: second.ordered_work_packages.pluck(:work_package_id)).pluck(:subject, :project_id)