From daabad4e33293572692632d2c08aa63e1598238a Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 14 Oct 2023 10:13:56 +0330 Subject: [PATCH] CFE-3 complete rendering, behavioral and validation testing of PositionAndRole component --- .../PositionAndRole/__tests__/index.test.js | 3 +- .../CreateContent/__tests__/index.test.js | 62 +++++++++---------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/RestInfo/PositionAndRole/__tests__/index.test.js b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/RestInfo/PositionAndRole/__tests__/index.test.js index 17be452..df48c8c 100644 --- a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/RestInfo/PositionAndRole/__tests__/index.test.js +++ b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/RestInfo/PositionAndRole/__tests__/index.test.js @@ -80,13 +80,12 @@ describe("CreateContent Component From Expert Management", () => { expect(screen.queryByText("سمت خود را وارد کنید")).toBeInTheDocument() }); }); - it('Should See Error When Role Select Is Empty', async () => { + it('Should Select An Item With Valid Value', async () => { render(); const roleInput = screen.getByTestId("input-role-id") const roleSelectOpener = await waitFor(() => screen.getByTestId("option-opener")); fireEvent.mouseDown(roleSelectOpener); - const selectItem = await waitFor(() => screen.queryByText("ادمین")); expect(selectItem).toBeInTheDocument(); fireEvent.click(selectItem); diff --git a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/__tests__/index.test.js b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/__tests__/index.test.js index 3180159..ebfde9f 100644 --- a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/__tests__/index.test.js +++ b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent/__tests__/index.test.js @@ -19,35 +19,35 @@ describe("CreateContent Component From Expert Management", () => { }); describe("Behavioral", () => { }); - // describe("Form Submission", () => { - // it('Should enable the submit button when the inputs are valid', async () => { - // render(); - // - // const submitButton = screen.getByRole('button', {name: 'ثبت'}); - // - // const nameInput = screen.queryByLabelText('نام'); - // const usernameInput = screen.queryByLabelText('نام کاربری'); - // const emailInput = screen.queryByLabelText('پست الکترونیک'); - // const phoneNumberInput = screen.queryByLabelText('شماره همراه'); - // const nationalIdInput = screen.queryByLabelText('کد ملی'); - // const passwordInput = screen.queryByLabelText('رمز عبور'); - // const positionInput = screen.queryByLabelText('سمت'); - // const provinceInput = screen.queryByLabelText('استان'); - // const roleInput = screen.queryByLabelText('نقش'); - // - // fireEvent.change(nameInput, {target: {value: 'nameTest'}}); - // fireEvent.change(usernameInput, {target: {value: 'usernameTest'}}); - // fireEvent.change(emailInput, {target: {value: 'emailTest'}}); - // fireEvent.change(phoneNumberInput, {target: {value: 'phoneNumberTest'}}); - // fireEvent.change(nationalIdInput, {target: {value: 'nationalIdTest'}}); - // fireEvent.change(passwordInput, {target: {value: 'passwordTest'}}); - // fireEvent.change(positionInput, {target: {value: 'positionTest'}}); - // fireEvent.change(provinceInput, {target: {value: 1}}); - // fireEvent.change(roleInput, {target: {value: 1}}); - // - // await waitFor(() => { - // expect(submitButton).not.toBeDisabled(); - // }); - // }); - // }) + describe("Form Submission", () => { + it('Should enable the submit button when the inputs are valid', async () => { + render(); + + const submitButton = screen.getByRole('button', {name: 'ثبت'}); + + const nameInput = screen.queryByLabelText('نام'); + const usernameInput = screen.queryByLabelText('نام کاربری'); + const emailInput = screen.queryByLabelText('پست الکترونیک'); + const phoneNumberInput = screen.queryByLabelText('شماره همراه'); + const nationalIdInput = screen.queryByLabelText('کد ملی'); + const passwordInput = screen.queryByLabelText('رمز عبور'); + const positionInput = screen.queryByLabelText('سمت'); + // const provinceInput = screen.queryByLabelText('استان'); + // const roleInput = screen.queryByLabelText('نقش'); + + fireEvent.change(nameInput, {target: {value: 'nameTest'}}); + fireEvent.change(usernameInput, {target: {value: 'usernameTest'}}); + fireEvent.change(emailInput, {target: {value: 'emailTest'}}); + fireEvent.change(phoneNumberInput, {target: {value: 'phoneNumberTest'}}); + fireEvent.change(nationalIdInput, {target: {value: 'nationalIdTest'}}); + fireEvent.change(passwordInput, {target: {value: 'passwordTest'}}); + fireEvent.change(positionInput, {target: {value: 'positionTest'}}); + // fireEvent.change(provinceInput, {target: {value: 1}}); + // fireEvent.change(roleInput, {target: {value: 1}}); + + await waitFor(() => { + expect(submitButton).not.toBeDisabled(); + }); + }); + }) }); \ No newline at end of file