fix(work-orders): allow comp-doc generate without existing completion document

canGenerateCompDoc now ignores the completion-document closability gap so PM/Overdue drafts can enter generation.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
arthur.bassi 2026-08-10 13:46:33 -03:00
parent 67c4ee8119
commit dd60b1d72e
2 changed files with 7 additions and 1 deletions

View file

@ -115,9 +115,11 @@ export type CompDocGateResult = { allowed: true } | { allowed: false; reason: st
/**
* Gate for completion-document generation. CompDocDialog (not yet on `dev`) should call this
* before opening generate flow and surface `reason` when blocked.
*
* Intentionally omits the "Completion document" closability gap — generate is how that gap is filled.
*/
export function canGenerateCompDoc(row: WoClosabilityInput): CompDocGateResult {
const gaps = getClosabilityGaps(row);
const gaps = getClosabilityGaps(row).filter((gap) => gap !== "Completion document");
if (gaps.length > 0) {
return { allowed: false, reason: formatClosabilityMissingTitle(gaps) };
}

View file

@ -137,6 +137,10 @@ describe("canGenerateCompDoc", () => {
expect(canGenerateCompDoc(makeInput())).toEqual({ allowed: true });
});
it("allows generation when only the completion document is missing", () => {
expect(canGenerateCompDoc(makeInput({ docStatus: "No" }))).toEqual({ allowed: true });
});
it("blocks generation with design reason when only pending uplift exists", () => {
expect(canGenerateCompDoc(makeInput({ hasPendingUplift: true }))).toEqual({
allowed: false,