diff --git a/e2e/pages/form-builder-page.ts b/e2e/pages/form-builder-page.ts index 9fad386..59dfff6 100644 --- a/e2e/pages/form-builder-page.ts +++ b/e2e/pages/form-builder-page.ts @@ -37,6 +37,8 @@ export class FormBuilderPage { this.page.getByRole("button", { name: /start building/i }); readonly interactiveFormNameInput = () => this.page.getByRole("textbox", { name: /form name/i }); + readonly interactiveFormDescriptionInput = () => + this.page.getByRole("textbox", { name: /form description/i }); readonly createFormButton = () => this.page.getByRole("button", { name: /create form/i }); readonly addPageButton = () => @@ -91,6 +93,9 @@ export class FormBuilderPage { await this.interactiveBuilderTab().click(); await this.startBuildingButton().click(); await this.interactiveFormNameInput().fill("Covid-19 Screening"); + await this.interactiveFormDescriptionInput().fill( + "A test form for recording COVID-19 screening information" + ); await this.createFormButton().click(); await expect(this.page.getByText(/form created/i)).toBeVisible(); @@ -129,13 +134,11 @@ export class FormBuilderPage { await this.formNameInput().fill(formName); await this.formVersionInput().click(); await this.formVersionInput().fill("1.0"); - await this.formDescriptionInput().click(); - await this.formDescriptionInput().fill("this is test form description"); await this.formEncounterType().selectOption("Admission"); await this.formSaveButton().click(); } async searchForm(formName: string) { - await this.page.getByRole('searchbox').fill(formName); + await this.page.getByRole("searchbox").fill(formName); } } diff --git a/package.json b/package.json index 77ace9f..50212b7 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test-e2e": "playwright test", "verify": "turbo lint typescript coverage", "coverage": "yarn test --coverage --passWithNoTests", - "prepare": "husky install", + "postinstall": "husky install", "extract-translations": "i18next 'src/**/*.component.tsx' --config ./i18next-parser.config.js", "ci:bump-form-engine-lib": "yarn up @openmrs/openmrs-form-engine-lib@next" }, diff --git a/src/components/interactive-builder/new-form-modal.component.tsx b/src/components/interactive-builder/new-form-modal.component.tsx index 2a5ad78..60b6555 100644 --- a/src/components/interactive-builder/new-form-modal.component.tsx +++ b/src/components/interactive-builder/new-form-modal.component.tsx @@ -8,6 +8,7 @@ import { ModalBody, ModalFooter, ModalHeader, + Stack, TextInput, } from "@carbon/react"; import { showToast, showNotification } from "@openmrs/esm-framework"; @@ -16,8 +17,8 @@ import type { Schema } from "../../types"; type NewFormModalProps = { schema: Schema; onSchemaChange: (schema: Schema) => void; - showModal: boolean; onModalChange: (showModal: boolean) => void; + showModal: boolean; }; const NewFormModal: React.FC = ({ @@ -28,11 +29,12 @@ const NewFormModal: React.FC = ({ }) => { const { t } = useTranslation(); const [formName, setFormName] = useState(""); + const [formDescription, setFormDescription] = useState(""); - const updateFormName = () => { + const updateSchema = (updates: Partial) => { try { - schema.name = formName; - onSchemaChange({ ...schema }); + const updatedSchema = { ...schema, ...updates }; + onSchemaChange(updatedSchema); showToast({ title: t("success", "Success!"), @@ -50,6 +52,17 @@ const NewFormModal: React.FC = ({ } }; + const handleCreateForm = () => { + if (formName) { + updateSchema({ + name: formName, + description: formDescription, + }); + + onModalChange(false); + } + }; + return ( = ({
event.preventDefault()}> - - setFormName(event.target.value)} - /> - + + + ) => + setFormName(event.target.value) + } + /> + + + ) => + setFormDescription(event.target.value) + } + /> + +
-