Skip to content

Commit bd7d48e

Browse files
authored
Merge pull request #3268 from SeedCompany/tests/new-project-workflow-kinda
2 parents 58bcd87 + 7737ce6 commit bd7d48e

14 files changed

+547
-542
lines changed

src/components/engagement/handlers/update-engagement-status.handler.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,18 @@ import { EngagementRepository } from '../engagement.repository';
1414
import { EngagementService } from '../engagement.service';
1515

1616
const changes: Change[] = [
17-
{
18-
to: { status: ProjectStatus.Active },
19-
newStatus: EngagementStatus.Active,
20-
},
2117
{
2218
to: { step: ProjectStep.ActiveChangedPlan },
2319
newStatus: EngagementStatus.ActiveChangedPlan,
2420
},
25-
{
26-
from: { status: ProjectStatus.Active },
27-
to: { status: ProjectStatus.InDevelopment },
28-
newStatus: EngagementStatus.InDevelopment,
29-
},
3021
{
3122
to: { step: ProjectStep.DiscussingChangeToPlan },
3223
newStatus: EngagementStatus.DiscussingChangeToPlan,
3324
},
25+
{
26+
to: { step: ProjectStep.DiscussingSuspension },
27+
newStatus: EngagementStatus.DiscussingSuspension,
28+
},
3429
{
3530
to: { step: ProjectStep.Suspended },
3631
newStatus: EngagementStatus.Suspended,
@@ -63,6 +58,15 @@ const changes: Change[] = [
6358
to: { step: ProjectStep.Terminated },
6459
newStatus: EngagementStatus.Terminated,
6560
},
61+
{
62+
to: { status: ProjectStatus.Active },
63+
newStatus: EngagementStatus.Active,
64+
},
65+
{
66+
from: { status: ProjectStatus.Active },
67+
to: { status: ProjectStatus.InDevelopment },
68+
newStatus: EngagementStatus.InDevelopment,
69+
},
6670
];
6771

6872
type Change = RequireAtLeastOne<{ from: Condition; to: Condition }> & {

src/components/project/workflow/project-workflow.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class ProjectWorkflowService extends WorkflowService(
105105
);
106106
await this.eventBus.publish(event);
107107

108-
return this.projects.secure(updated, session);
108+
return this.projects.secure(event.project, session);
109109
}
110110

111111
/** @deprecated */

src/components/workflow/workflow.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ export const WorkflowService = <W extends Workflow>(workflow: () => W) => {
150150
return WorkflowServiceClass;
151151
};
152152

153-
export const findTransition = <T extends { key: ID }>(
153+
export const findTransition = <T extends { key: ID; disabled?: boolean }>(
154154
transitions: readonly T[],
155155
needle: ExecuteTransitionInput['transition'],
156156
) => {
157-
const transition = transitions.find((t) => t.key === needle);
157+
const transition = transitions.find((t) => t.key === needle && !t.disabled);
158158
if (!transition) {
159159
throw new UnauthorizedException('This transition is not available');
160160
}

src/core/exception/jest-skip-source-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const jestSkipFileInExceptionSource = (
1919
return e;
2020
}
2121

22-
const all = filepath instanceof RegExp && filepath.global;
22+
const all = filepath instanceof RegExp ? filepath.global : true;
2323
e.stack = e.stack?.[all ? 'replaceAll' : 'replace'](filepath, (substr) => {
2424
const path = substr.match(/\s+at /)
2525
? stacktrace.parse({ stack: 'Error \n' + substr } as any)[0].getFileName()

test/engagement-changeset-aware.e2e-spec.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { CalendarDate, ID, Role } from '~/common';
22
import { EngagementStatus } from '../src/components/engagement/dto';
33
import { Language } from '../src/components/language/dto';
44
import { ProjectChangeRequestType } from '../src/components/project-change-request/dto';
5-
import { ProjectStep } from '../src/components/project/dto';
65
import {
76
approveProjectChangeRequest,
87
createFundingAccount,
@@ -22,10 +21,7 @@ import {
2221
updateProject,
2322
} from './utility';
2423
import { fragments } from './utility/fragments';
25-
import {
26-
changeProjectStep,
27-
stepsFromEarlyConversationToBeforeActive,
28-
} from './utility/transition-project';
24+
import { forceProjectTo } from './utility/transition-project';
2925

3026
const readEngagements = (app: TestApp, id: string, changeset?: string) =>
3127
app.graphql.query(
@@ -135,14 +131,7 @@ const activeProject = async (app: TestApp, projectId: ID) => {
135131
primaryLocationId: location.id,
136132
fieldRegionId: region.id,
137133
});
138-
await runAsAdmin(app, async () => {
139-
for (const next of [
140-
...stepsFromEarlyConversationToBeforeActive,
141-
ProjectStep.Active,
142-
]) {
143-
await changeProjectStep(app, projectId, next);
144-
}
145-
});
134+
await forceProjectTo(app, projectId, 'Active');
146135
};
147136

148137
describe('Engagement Changeset Aware e2e', () => {

test/engagement-workflow.e2e-spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('Engagement-Workflow e2e', () => {
4545
const transProject = await createProject(app, {
4646
type: ProjectType.MomentumTranslation,
4747
});
48-
expect(transProject.step.value).toBe(ProjectStep.EarlyConversations);
4948

5049
const langEngagement = await createLanguageEngagement(app, {
5150
projectId: transProject.id,

0 commit comments

Comments
 (0)