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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix flaky spec
Christophe Bliardfb81283773e3
diff --git a/frontend/src/app/core/apiv3/endpoints/work_packages/work-package.cache.ts b/frontend/src/app/core/apiv3/endpoints/work_packages/work-package.cache.tsindex 624569b9671..60b2cd0f489 100644--- a/frontend/src/app/core/apiv3/endpoints/work_packages/work-package.cache.ts+++ b/frontend/src/app/core/apiv3/endpoints/work_packages/work-package.cache.ts@@ -34,13 +34,16 @@ import { StateCacheService } from 'core-app/core/apiv3/cache/state-cache.serviceimport { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';import isNewResource from 'core-app/features/hal/helpers/is-new-resource';+import { CustomActionResource } from 'core-app/features/hal/resources/custom-action-resource';@Injectable()export class WorkPackageCache extends StateCacheService<WorkPackageResource> {@InjectField() private schemaCacheService:SchemaCacheService;- constructor(readonly injector:Injector,- state:MultiInputState<WorkPackageResource>) {+ constructor(+ readonly injector:Injector,+ state:MultiInputState<WorkPackageResource>,+ ) {super(state);}@@ -55,12 +58,18 @@ export class WorkPackageCache extends StateCacheService<WorkPackageResource> {if (immediate || isNewResource(wp)) {return super.updateValue(wp.id!, wp);}++ // Preserve the full custom actions data if it exists in the current state+ const currentState = this.multiState.get(wp.id!);+ if (currentState.hasValue()) {+ this.preserveCustomActionsData(wp, currentState.value!);+ }+return this.updateValue(wp.id!, wp);}updateWorkPackageList(list:WorkPackageResource[], skipOnIdentical = true) {- list.forEach((i) => {- const wp = i;+ list.forEach((wp) => {const workPackageId = wp.id!;const state = this.multiState.get(workPackageId);@@ -70,9 +79,14 @@ export class WorkPackageCache extends StateCacheService<WorkPackageResource> {return;}+ // Preserve custom actions data if it exists in the current state+ if (state.hasValue()) {+ this.preserveCustomActionsData(wp, state.value!);+ }+// Ensure the schema is loaded// so that no consumer needs to call schema#$load manually- this.schemaCacheService.ensureLoaded(wp).then(() => {+ void this.schemaCacheService.ensureLoaded(wp).then(() => {// Check if the work package has changedif (skipOnIdentical && state.hasValue() && _.isEqual(state.value!.$source, wp.$source)) {debugLog('Skipping identical work package from updating');@@ -83,4 +97,26 @@ export class WorkPackageCache extends StateCacheService<WorkPackageResource> {});});}++ private preserveCustomActionsData(+ wp:WorkPackageResource,+ currentWp:WorkPackageResource,+ ):void {+ if (currentWp.customActions && Array.isArray(currentWp.customActions)) {+ const existingActions = new Map(+ currentWp.customActions.map(+ (action:CustomActionResource) => [action.name, action],+ ),+ );++ if (wp.customActions && Array.isArray(wp.customActions)) {+ wp.customActions = wp.customActions.map(+ (action:CustomActionResource) => {+ const existingAction = existingActions.get(action.name);+ return existingAction || action;+ },+ );+ }+ }+ }}diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.html b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.htmlindex 0343be8d5a3..9cce69118b7 100644--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.html+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.html@@ -1,7 +1,7 @@<button(click)="update()"class="custom-action--button button -narrow hide-when-print"- title="{{action.description ? action.description : action.name}}"+ [title]="title"[disabled]="change.inFlight">{{action.name}}diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.ts b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.tsindex 52890b3af35..0b9ae945ae9 100644--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.ts@@ -87,6 +87,10 @@ export class WpCustomActionComponent extends UntilDestroyedMixin implements OnIn});}+ public get title():string {+ return this.action.description || this.action.name;+ }+public get change():ResourceChangeset<WorkPackageResource> {return this.halEditing.changeFor(this.workPackage);}diff --git a/spec/features/work_packages/custom_actions/custom_actions_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_spec.rbindex 8361f77c8b5..6422839b1bf 100644--- a/spec/features/work_packages/custom_actions/custom_actions_spec.rb+++ b/spec/features/work_packages/custom_actions/custom_actions_spec.rb@@ -313,7 +313,7 @@ RSpec.describe "Custom actions", :js, with_ee: %i[custom_actions] dowithin(".custom-actions") do# When hovering over the button, the description is displayedexpect(page)- .to have_button("Unassign", title: "Removes the assignee", wait: 10)+ .to have_button("Unassign", title: "Removes the assignee")endwp_page.click_custom_action("Unassign")