Skip to content

Commit

Permalink
feat: [#188645598] add environmental questionnaire for land
Browse files Browse the repository at this point in the history
  • Loading branch information
somabadri committed Dec 19, 2024
1 parent 6e955a1 commit d9cac7b
Show file tree
Hide file tree
Showing 34 changed files with 2,343 additions and 764 deletions.
23 changes: 23 additions & 0 deletions api/src/db/migrations/v151_extract_business_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,3 +885,26 @@ export const getRandomv151LicenseStatus = (): v151LicenseStatus => {
const randomIndex = Math.floor(Math.random() * v151LicenseStatuses.length);
return v151LicenseStatuses[randomIndex];
};

export const generatev151WasteQuestionnaireData = (
overrides: Partial<v151WasteQuestionnaireData>
): v151WasteQuestionnaireData => {
return {
hazardousMedicalWaste: false,
constructionDebris: false,
compostWaste: false,
treatProcessWaste: false,
noWaste: false,
...overrides,
};
};

export const generatev151WasteData = (overrides: Partial<v151WasteData>): v151WasteData => {
return {
questionnaireData: generatev151WasteQuestionnaireData({
...overrides.questionnaireData,
}),
submitted: false,
...overrides,
};
};
96 changes: 96 additions & 0 deletions api/src/db/migrations/v152_add_land_to_environment_data.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import {
generatev151Business,
generatev151UserData,
generatev151WasteData,
generatev151WasteQuestionnaireData,
} from "@db/migrations/v151_extract_business_data";
import { migrate_v151_to_v152, v152EnvironmentData } from "@db/migrations/v152_add_land_to_environment_data";

describe("v152_add_land_to_environment_data", () => {
it("migrates environment data when waste task is COMPLETED", () => {
const id = "biz-1";
const v151Business = generatev151Business({
taskProgress: { "waste-permitting": "COMPLETED" },
environmentData: {
waste: generatev151WasteData({
questionnaireData: generatev151WasteQuestionnaireData({
hazardousMedicalWaste: false,
constructionDebris: true,
compostWaste: true,
treatProcessWaste: false,
noWaste: false,
}),
submitted: true,
}),
},
id,
});
const v151User = generatev151UserData({
businesses: { "biz-1": v151Business },
});

const v152User = migrate_v151_to_v152(v151User);

expect(v152User.businesses[id].environmentData?.waste?.questionnaireData).toEqual({
hazardousMedicalWaste: false,
constructionDebris: true,
compostWaste: true,
treatProcessWaste: false,
noWaste: false,
});
expect(v152User.businesses[id].environmentData?.waste?.submitted).toEqual(true);
expect(v152User.businesses[id].taskProgress["waste-permitting"]).toEqual("COMPLETED");
});

it("migrates environment data when waste task is IN_PROGRESS", () => {
const id = "biz-1";
const v151Business = generatev151Business({
taskProgress: { "waste-permitting": "IN_PROGRESS" },
environmentData: {
waste: generatev151WasteData({
questionnaireData: generatev151WasteQuestionnaireData({
hazardousMedicalWaste: false,
constructionDebris: true,
compostWaste: true,
treatProcessWaste: false,
noWaste: false,
}),
submitted: false,
}),
},
id,
});
const v151User = generatev151UserData({
businesses: { "biz-1": v151Business },
});

const v152User = migrate_v151_to_v152(v151User);

expect(v152User.businesses[id].environmentData?.waste?.questionnaireData).toEqual({
hazardousMedicalWaste: false,
constructionDebris: true,
compostWaste: true,
treatProcessWaste: false,
noWaste: false,
});
expect(v152User.businesses[id].environmentData?.waste?.submitted).toEqual(false);
expect(v152User.businesses[id].taskProgress["waste-permitting"]).toEqual("IN_PROGRESS");
});

it("adds land section to environment data", () => {
const id = "biz-1";
const v151Business = generatev151Business({
taskProgress: { "waste-permitting": "IN_PROGRESS" },
environmentData: {
waste: generatev151WasteData({}),
},
id,
});
const v151User = generatev151UserData({
businesses: { "biz-1": v151Business },
});
const v152User = migrate_v151_to_v152(v151User);
const environmentData = v152User.businesses[id].environmentData as v152EnvironmentData;
expect("land" in environmentData).toEqual(true);
});
});
Loading

0 comments on commit d9cac7b

Please sign in to comment.