CFE-3 complete rendering, behavioral and validation testing of PositionAndRole component

This commit is contained in:
2023-10-14 10:13:56 +03:30
parent a76c50b59f
commit daabad4e33
2 changed files with 32 additions and 33 deletions

View File

@@ -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(<MockAppWithProviders><CreateFormMock Component={PositionAndRole}/></MockAppWithProviders>);
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);

View File

@@ -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(<MockAppWithProviders><CreateForm/></MockAppWithProviders>);
//
// 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(<MockAppWithProviders><CreateForm/></MockAppWithProviders>);
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();
});
});
})
});