@@ -16,6 +16,10 @@ const loadBuildRepsArrRulesModule = () => {
|
||||
);
|
||||
|
||||
let source = fs.readFileSync(filePath, "utf8");
|
||||
source = source.replace(
|
||||
/const\s+\{\s*getAvailableRepresentationTypes\s*\}\s*=\s*require\("\.\.\.\.\/\.\.\.\/\.\.\.\/lib\/domain\/representation-type-policy\/getAvailableRepresentationTypes"\);/,
|
||||
'const { getAvailableRepresentationTypes } = require("../../../../lib/domain/representation-type-policy/getAvailableRepresentationTypes");'
|
||||
);
|
||||
source = source.replace(/export const\s+/g, "const ");
|
||||
source += `
|
||||
module.exports = {
|
||||
@@ -30,7 +34,42 @@ module.exports = {
|
||||
const context = {
|
||||
module: { exports: {} },
|
||||
exports: {},
|
||||
require,
|
||||
require: (modulePath) => {
|
||||
if (
|
||||
modulePath ===
|
||||
"../../../../lib/domain/representation-type-policy/getAvailableRepresentationTypes"
|
||||
) {
|
||||
const domainFilePath = path.join(
|
||||
rootDir,
|
||||
"lib",
|
||||
"domain",
|
||||
"representation-type-policy",
|
||||
"getAvailableRepresentationTypes.js"
|
||||
);
|
||||
let domainSource = fs.readFileSync(domainFilePath, "utf8");
|
||||
domainSource = domainSource.replace(
|
||||
/export const\s+getAvailableRepresentationTypes\s*=/g,
|
||||
"const getAvailableRepresentationTypes ="
|
||||
);
|
||||
domainSource +=
|
||||
"\nmodule.exports = { getAvailableRepresentationTypes };\n";
|
||||
|
||||
const domainContext = {
|
||||
module: { exports: {} },
|
||||
exports: {},
|
||||
require,
|
||||
Date
|
||||
};
|
||||
|
||||
vm.runInNewContext(domainSource, domainContext, {
|
||||
filename: domainFilePath
|
||||
});
|
||||
|
||||
return domainContext.module.exports;
|
||||
}
|
||||
|
||||
return require(modulePath);
|
||||
},
|
||||
Date
|
||||
};
|
||||
|
||||
@@ -418,6 +457,94 @@ test("invalid or missing dates suppress date-gated options but SIPS consultation
|
||||
);
|
||||
});
|
||||
|
||||
test("non-DNS startdate plural fallback preserves successful statement availability and current output order", () => {
|
||||
assert.deepStrictEqual(
|
||||
buildOptions({
|
||||
detailsObj: {
|
||||
pinswg_startdate: null,
|
||||
pinswg_startdates: "2026-04-01T00:00:00.000Z",
|
||||
pinswg_statementduedate: "2026-04-30T00:00:00.000Z",
|
||||
pinswg_finalcommentsduedate: "2026-05-25T00:00:00.000Z"
|
||||
},
|
||||
selectedCapacity: "appellant",
|
||||
isCaseOwner: false,
|
||||
now: new Date("2026-04-15T10:00:00.000Z")
|
||||
}),
|
||||
["Statement"]
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
buildOptions({
|
||||
detailsObj: {
|
||||
pinswg_startdate: null,
|
||||
pinswg_startdates: "2026-04-01T00:00:00.000Z",
|
||||
pinswg_statementduedate: "2026-04-30T00:00:00.000Z",
|
||||
pinswg_finalcommentsduedate: "2026-05-25T00:00:00.000Z"
|
||||
},
|
||||
selectedCapacity: "agent",
|
||||
involvementType: INVOLVEMENT_TYPES.LPA,
|
||||
isCaseOwner: false,
|
||||
isNRW: true,
|
||||
appealType: APPEAL_TYPES.SIPS,
|
||||
now: new Date("2026-05-10T10:00:00.000Z")
|
||||
}),
|
||||
[
|
||||
"Questionnaire",
|
||||
"Final comments",
|
||||
"Consultation Response",
|
||||
"Local Impact Report",
|
||||
"Marine Impact Report"
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test("non-DNS statementsduedate plural fallback preserves successful final comments availability", () => {
|
||||
assert.deepStrictEqual(
|
||||
buildOptions({
|
||||
detailsObj: {
|
||||
pinswg_startdate: "2026-04-01T00:00:00.000Z",
|
||||
pinswg_statementduedate: null,
|
||||
pinswg_statementsduedate: "2026-04-30T00:00:00.000Z",
|
||||
pinswg_finalcommentsduedate: "2026-05-25T00:00:00.000Z"
|
||||
},
|
||||
selectedCapacity: "interestedparty",
|
||||
isCaseOwner: false,
|
||||
now: new Date("2026-05-10T10:00:00.000Z")
|
||||
}),
|
||||
["Final comments"]
|
||||
);
|
||||
});
|
||||
|
||||
test("combined plural date fallbacks preserve successful statement and final comments availability across windows", () => {
|
||||
const detailsObj = {
|
||||
pinswg_startdate: null,
|
||||
pinswg_startdates: "2026-04-01T00:00:00.000Z",
|
||||
pinswg_statementduedate: null,
|
||||
pinswg_statementsduedate: "2026-04-30T00:00:00.000Z",
|
||||
pinswg_finalcommentsduedate: "2026-05-25T00:00:00.000Z"
|
||||
};
|
||||
|
||||
assert.deepStrictEqual(
|
||||
buildOptions({
|
||||
detailsObj,
|
||||
selectedCapacity: "appellant",
|
||||
isCaseOwner: false,
|
||||
now: new Date("2026-04-15T10:00:00.000Z")
|
||||
}),
|
||||
["Statement"]
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
buildOptions({
|
||||
detailsObj,
|
||||
selectedCapacity: "appellant",
|
||||
isCaseOwner: false,
|
||||
now: new Date("2026-05-10T10:00:00.000Z")
|
||||
}),
|
||||
["Final comments"]
|
||||
);
|
||||
});
|
||||
|
||||
test("capacity normalization coverage", () => {
|
||||
const inFinalWindow = { now: new Date("2026-05-10T10:00:00.000Z") };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user