Skip to content

Commit

Permalink
feat: [#188520392] Offer multiple dwelling question to residential la…
Browse files Browse the repository at this point in the history
…ndlord industry
  • Loading branch information
sirsamueljoseph authored and SirSamuelJoseph committed Nov 4, 2024
1 parent 1c492cd commit dd4b6dc
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
3 changes: 2 additions & 1 deletion content/src/roadmaps/industries/residential-landlord.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
],
"name": "Residential Landlord",
"nonEssentialQuestionsIds": [
"weights-measures"
"weights-measures",
"multiple-dwelling-register"
],
"displayname": "residential-landlord",
"industryOnboardingQuestions": {
Expand Down
17 changes: 17 additions & 0 deletions web/src/lib/roadmap/fixtures/add-ons/tea-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"filename": "tea-2",
"displayname": "tea-2",
"roadmapSteps": [
{
"step": 1,
"weight": 3,
"task": "tea-task-1"
},
{
"step": 1,
"weight": 1,
"task": "generic-task-1"
}
],
"modifications": []
}
26 changes: 26 additions & 0 deletions web/src/lib/roadmap/roadmapBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,32 @@ describe("roadmapBuilder", () => {

expect(requiredTask?.id).toEqual("tea-task-2-required-id");
});

it("removes duplicate tasks from task list from multiple addons", async () => {
const roadmap1 = await buildRoadmap({
industryId: "standard",
addOns: ["tea"],
});
const roadmap2 = await buildRoadmap({
industryId: "standard",
addOns: ["tea", "tea-2"],
});

expect(roadmap1.tasks.length).toEqual(roadmap2.tasks.length);
});

it("removes duplicate tasks from add ons and industries", async () => {
const roadmap = await buildRoadmap({
industryId: "standard",
addOns: ["tea-2"],
});

expect(
roadmap.tasks.filter((task) => {
return task.filename === "generic-task-1";
}).length
).toEqual(1);
});
});

const expectedGenericRoadmap: Roadmap = {
Expand Down
13 changes: 13 additions & 0 deletions web/src/lib/roadmap/roadmapBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const buildRoadmap = async ({
while (hasSteps(roadmapBuilder) && lastStepHasNoTasks(roadmapBuilder)) {
roadmapBuilder = removeLastStep(roadmapBuilder);
}
roadmapBuilder = removeDuplicateTasks(roadmapBuilder);
return convertToRoadmap(roadmapBuilder);
};

Expand Down Expand Up @@ -146,6 +147,18 @@ const modifyTasks = (roadmap: RoadmapBuilder, modifications: TaskModification[])
return roadmap;
};

const removeDuplicateTasks = (roadmap: RoadmapBuilder): RoadmapBuilder => {
const taskNames: string[] = [];
roadmap.tasks = roadmap.tasks.filter((task) => {
if (taskNames.includes(task.filename)) {
return false;
}
taskNames.push(task.filename);
return true;
});
return roadmap;
};

const findTaskInRoadmapByFilename = (
roadmapBuilder: RoadmapBuilder,
taskFilename: string
Expand Down

0 comments on commit dd4b6dc

Please sign in to comment.