feat(subjects): add visit drawer and editable screening dates

This commit is contained in:
Cheng Zhou
2026-06-08 11:01:32 +08:00
parent e5ed18c3cd
commit a3f6a04f35
15 changed files with 1515 additions and 525 deletions
@@ -0,0 +1,28 @@
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");
});
});