From 5fc066aea0760277d03162b126a8c645172cc6af Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Tue, 3 Dec 2024 15:35:28 +1100 Subject: [PATCH] fix planning action utils & tests --- client/utils/planning.ts | 2 +- client/utils/tests/planning_test.ts | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/client/utils/planning.ts b/client/utils/planning.ts index d7d178ade..8119fa75b 100644 --- a/client/utils/planning.ts +++ b/client/utils/planning.ts @@ -141,7 +141,7 @@ function canEditPlanning( ( primaryEvents.length === 0 || isCancelPlanWithEventDisabled() - || primaryEvents.some((event) => ( + || !primaryEvents.some((event) => ( getItemWorkflowState(event) === WORKFLOW_STATE.KILLED || isItemSpiked(event) )) diff --git a/client/utils/tests/planning_test.ts b/client/utils/tests/planning_test.ts index cf73374bc..77a1adc17 100644 --- a/client/utils/tests/planning_test.ts +++ b/client/utils/tests/planning_test.ts @@ -664,7 +664,7 @@ describe('PlanningUtils', () => { const itemActions = planningUtils.getPlanningActions({ item: planning, - events: [event], + events: [], session: session, privileges: privileges, lockedItems: locks, @@ -683,7 +683,7 @@ describe('PlanningUtils', () => { let itemActions = planningUtils.getPlanningActions({ item: planning, - events: [event], + events: [], session: session, privileges: privileges, lockedItems: locks, @@ -694,13 +694,14 @@ describe('PlanningUtils', () => { expectActions(itemActions, ['Duplicate', 'Edit']); planning.related_events = [{ - _id: '1', + _id: 'event1', link_type: 'primary', }]; event = { + _id: 'event1', state: 'cancelled', - planning_ids: ['1'], + planning_ids: ['plan1'], }; itemActions = planningUtils.getPlanningActions({ @@ -721,7 +722,7 @@ describe('PlanningUtils', () => { let itemActions = planningUtils.getPlanningActions({ item: planning, - events: [event], + events: [], session: session, privileges: privileges, lockedItems: locks, @@ -734,13 +735,14 @@ describe('PlanningUtils', () => { ]); planning.related_events = [{ - _id: '1', + _id: 'event1', link_type: 'primary', }]; event = { + _id: 'event1', state: 'rescheduled', - planning_ids: ['1'], + planning_ids: ['plan1'], }; itemActions = planningUtils.getPlanningActions({ @@ -762,13 +764,14 @@ describe('PlanningUtils', () => { planning.state = 'killed'; planning.related_events = [{ - _id: '1', + _id: 'event1', link_type: 'primary', }]; event = { + _id: 'event1', state: 'killed', - planning_ids: ['1'], + planning_ids: ['plan1'], }; let itemActions = planningUtils.getPlanningActions({ @@ -790,13 +793,14 @@ describe('PlanningUtils', () => { planning.state = 'killed'; planning.related_events = [{ - _id: '1', + _id: 'event1', link_type: 'primary', }]; event = { + _id: 'event1', state: 'scheduled', - planning_ids: ['1'], + planning_ids: ['plan1'], }; let itemActions = planningUtils.getPlanningActions({ @@ -830,7 +834,7 @@ describe('PlanningUtils', () => { let itemActions = planningUtils.getPlanningActions({ item: planning, - events: [event], + events: [], session: session, privileges: privileges, lockedItems: locks,