Skip to content

Commit

Permalink
feat: [188623677] add environmental questionnaire for air
Browse files Browse the repository at this point in the history
  • Loading branch information
somabadri committed Jan 13, 2025
1 parent 85235cd commit e2a2a00
Show file tree
Hide file tree
Showing 20 changed files with 1,442 additions and 32 deletions.
4 changes: 3 additions & 1 deletion api/src/db/migrations/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { migrate_v13_to_v14 } from "@db/migrations/v14_add_cleaning_aid_industry
import { migrate_v149_to_v150 } from "@db/migrations/v150_remove_needs_nexus_dba_name";
import { migrate_v150_to_v151 } from "@db/migrations/v151_extract_business_data";
import { migrate_v151_to_v152 } from "@db/migrations/v152_add_land_to_environment_data";
import { migrate_v152_to_v153 } from "@db/migrations/v153_add_air_to_environment_data";
import { migrate_v14_to_v15 } from "@db/migrations/v15_add_retail_industry";
import { migrate_v15_to_v16 } from "@db/migrations/v16_add_user_preferences";
import { migrate_v16_to_v17 } from "@db/migrations/v17_add_operate_section";
Expand Down Expand Up @@ -308,6 +309,7 @@ export const Migrations: MigrationFunction[] = [
migrate_v149_to_v150,
migrate_v150_to_v151,
migrate_v151_to_v152,
migrate_v152_to_v153,
];

export { generatev152UserData as CURRENT_GENERATOR } from "@db/migrations/v152_add_land_to_environment_data";
export { generatev153UserData as CURRENT_GENERATOR } from "@db/migrations/v153_add_air_to_environment_data";
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ describe("v152_add_land_to_environment_data", () => {
it("adds land section to environment data", () => {
const id = "biz-1";
const v151Business = generatev151Business({
taskProgress: { "waste-permitting": "IN_PROGRESS" },
environmentData: {
waste: generatev151WasteData({}),
},
Expand Down
23 changes: 23 additions & 0 deletions api/src/db/migrations/v152_add_land_to_environment_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,3 +894,26 @@ export const getRandomv152LicenseStatus = (): v152LicenseStatus => {
const randomIndex = Math.floor(Math.random() * v152LicenseStatuses.length);
return v152LicenseStatuses[randomIndex];
};

export const generatev152LandQuestionnaireData = (
overrides: Partial<v152LandQuestionnaireData>
): v152LandQuestionnaireData => {
return {
takeOverExistingBiz: false,
propertyAssessment: false,
constructionActivities: false,
siteImprovementWasteLands: false,
noLand: false,
...overrides,
};
};

export const generatev152LandData = (overrides: Partial<v152LandData>): v152LandData => {
return {
questionnaireData: generatev152LandQuestionnaireData({
...overrides.questionnaireData,
}),
submitted: false,
...overrides,
};
};
96 changes: 96 additions & 0 deletions api/src/db/migrations/v153_add_air_to_environment_data.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import {
generatev152Business,
generatev152LandData,
generatev152LandQuestionnaireData,
generatev152UserData,
} from "@db/migrations/v152_add_land_to_environment_data";
import { migrate_v152_to_v153, v153EnvironmentData } from "@db/migrations/v153_add_air_to_environment_data";

describe("v153_add_air_to_environment_data", () => {
it("migrates environment data when land task is COMPLETED", () => {
const id = "biz-1";
const v152Business = generatev152Business({
taskProgress: { "land-permitting": "COMPLETED" },
environmentData: {
land: generatev152LandData({
questionnaireData: generatev152LandQuestionnaireData({
takeOverExistingBiz: false,
propertyAssessment: true,
constructionActivities: true,
siteImprovementWasteLands: false,
noLand: false,
}),
submitted: true,
}),
},
id,
});
const v152User = generatev152UserData({
businesses: { "biz-1": v152Business },
});

const v153User = migrate_v152_to_v153(v152User);

expect(v153User.businesses[id].environmentData?.land?.questionnaireData).toEqual({
takeOverExistingBiz: false,
propertyAssessment: true,
constructionActivities: true,
siteImprovementWasteLands: false,
noLand: false,
});
expect(v153User.businesses[id].environmentData?.land?.submitted).toEqual(true);
expect(v153User.businesses[id].taskProgress["land-permitting"]).toEqual("COMPLETED");
});

it("migrates environment data when land task is IN_PROGRESS", () => {
const id = "biz-1";
const v152Business = generatev152Business({
taskProgress: { "land-permitting": "IN_PROGRESS" },
environmentData: {
land: generatev152LandData({
questionnaireData: generatev152LandQuestionnaireData({
takeOverExistingBiz: false,
propertyAssessment: true,
constructionActivities: true,
siteImprovementWasteLands: false,
noLand: false,
}),
submitted: false,
}),
},
id,
});
const v152User = generatev152UserData({
businesses: { "biz-1": v152Business },
});

const v153User = migrate_v152_to_v153(v152User);

expect(v153User.businesses[id].environmentData?.land?.questionnaireData).toEqual({
takeOverExistingBiz: false,
propertyAssessment: true,
constructionActivities: true,
siteImprovementWasteLands: false,
noLand: false,
});
expect(v153User.businesses[id].environmentData?.land?.submitted).toEqual(false);
expect(v153User.businesses[id].taskProgress["land-permitting"]).toEqual("IN_PROGRESS");
});

it("adds air section to environment data", () => {
const id = "biz-1";
const v152Business = generatev152Business({
environmentData: {
waste: undefined,
land: generatev152LandData({}),
},
id,
});
const v152User = generatev152UserData({
businesses: { "biz-1": v152Business },
});
const v153User = migrate_v152_to_v153(v152User);
const environmentData = v153User.businesses[id].environmentData as v153EnvironmentData;
expect("air" in environmentData).toEqual(true);
});
});
Loading

0 comments on commit e2a2a00

Please sign in to comment.