import { describe, expect, it } from "vitest"; import { readFileSync } from "node:fs"; import { resolve } from "node:path"; const readSubjectEditorDrawer = () => readFileSync(resolve(__dirname, "./SubjectEditorDrawer.vue"), "utf8"); describe("SubjectEditorDrawer screening date editing", () => { it("keeps screening date editable when editing an existing participant", () => { const source = readSubjectEditorDrawer(); const screeningDateField = source.slice( source.indexOf('v-model="form.screening_date"'), source.indexOf('v-model="form.consent_date"') ); expect(screeningDateField).toContain(':disabled="isReadOnly"'); expect(screeningDateField).not.toContain(':disabled="isEdit || isReadOnly"'); }); it("submits screening date in the edit payload", () => { const source = readSubjectEditorDrawer(); const editPayload = source.slice( source.indexOf("await updateSubject(studyId.value, props.subjectId, {"), source.indexOf("});", source.indexOf("await updateSubject(studyId.value, props.subjectId, {")) ); expect(editPayload).toContain("screening_date: form.screening_date || null"); }); });