Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/common/phase-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,18 @@ class ChallengePhaseHelper {
...phase,
predecessor: resolvedPredecessor,
description: phaseDefinition.description,
requestedScheduledStartDate: _.get(newPhase, "scheduledStartDate"),
requestedScheduledEndDate: _.get(newPhase, "scheduledEndDate"),
};
if (
_.isNil(updatedPhase.actualEndDate) &&
!_.isNil(updatedPhase.actualStartDate) &&
!_.isNil(updatedPhase.requestedScheduledStartDate)
) {
updatedPhase.scheduledStartDate = moment(updatedPhase.requestedScheduledStartDate)
.toDate()
.toISOString();
}
if (updatedPhase.name === "Post-Mortem") {
updatedPhase.predecessor = "a93544bc-c165-4af4-b55e-18f3593b457a";
}
Expand All @@ -414,7 +424,7 @@ class ChallengePhaseHelper {
}
if (_.isNil(updatedPhase.predecessor)) {
let scheduledStartDate = _.defaultTo(
_.get(newPhase, "scheduledStartDate"),
updatedPhase.requestedScheduledStartDate,
updatedPhase.scheduledStartDate
);
if (
Expand Down Expand Up @@ -485,7 +495,9 @@ class ChallengePhaseHelper {
recalculateScheduledEndDate(phase);
}
validateRecalculatedPhaseSchedules(challengePhasesOrdered, updatedPhases, options);
return _.map(updatedPhases, (phase) => _.omit(phase, "requestedScheduledEndDate"));
return _.map(updatedPhases, (phase) =>
_.omit(phase, ["requestedScheduledStartDate", "requestedScheduledEndDate"])
);
}

handlePhasesAfterCancelling(phases) {
Expand Down
47 changes: 47 additions & 0 deletions test/unit/phase-helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,53 @@ describe('phase helper unit tests', () => {
updatedPhases[0].duration.should.equal(duration)
})

it('allows started non-Design phase schedule to move earlier when duration is unchanged', async () => {
const registrationPhaseId = 'development-registration-phase'
const currentRegistrationStartDate = '2099-05-26T05:14:00.000Z'
const currentRegistrationEndDate = '2099-05-31T05:14:00.000Z'
const requestedRegistrationStartDate = '2099-05-25T05:14:00.000Z'
const requestedRegistrationEndDate = '2099-05-30T05:14:00.000Z'
const duration = 5 * 24 * 60 * 60

stubPhaseLookups(
[{ id: registrationPhaseId, name: 'Registration', description: 'Registration phase' }],
[{ phaseId: registrationPhaseId, defaultDuration: duration }]
)

const updatedPhases = await phaseHelper.populatePhasesForChallengeUpdate(
[
{
duration,
isOpen: true,
name: 'Registration',
phaseId: registrationPhaseId,
actualStartDate: requestedRegistrationStartDate,
scheduledStartDate: currentRegistrationStartDate,
scheduledEndDate: currentRegistrationEndDate
}
],
[
{
duration,
phaseId: registrationPhaseId,
scheduledStartDate: requestedRegistrationStartDate,
scheduledEndDate: requestedRegistrationEndDate
}
],
'timeline-template-id',
false,
{
allowActivePhaseShortening: false,
preventPhaseShortening: true
}
)

updatedPhases[0].actualStartDate.should.equal(requestedRegistrationStartDate)
updatedPhases[0].scheduledStartDate.should.equal(requestedRegistrationStartDate)
updatedPhases[0].scheduledEndDate.should.equal(requestedRegistrationEndDate)
updatedPhases[0].duration.should.equal(duration)
})

it('allows active non-Design dependent phases to move earlier when duration is unchanged', async () => {
const registrationPhaseId = 'development-registration-phase'
const reviewPhaseId = 'development-review-phase'
Expand Down
Loading