write some behavioral test and rendered test for create form component

This commit is contained in:
2023-10-02 17:28:54 +03:30
49 changed files with 557 additions and 187 deletions

View File

@@ -0,0 +1,6 @@
import {forwardRef} from "react";
import {Slide} from "@mui/material";
export const DialogTransition = forwardRef(function DialogTransition(props, ref) {
return <Slide direction="up" ref={ref} {...props}/>;
});

View File

@@ -0,0 +1,31 @@
import {fireEvent, getByRole, render, screen} from "@testing-library/react";
import PasswordField from "@/core/components/PasswordField";
import {Formik} from "formik";
describe('Password Field component in core folder', () => {
describe('Rendering', () => {
it('Show password when visibility icon clicked',() => {
render (
<Formik initialValues={{password:''}} onSubmit={()=>{}}>
{(props)=>(
<PasswordField label="رمز عبور" />
)}
</Formik>
)
const iconElement = screen.getByLabelText("رمز عبور")
const iconButton = screen.getByRole("button")
expect(iconElement).toHaveAttribute('type', 'password');
fireEvent.click(iconButton);
expect(iconElement).toHaveAttribute("type", "text");
fireEvent.click(iconButton);
expect(iconElement).toHaveAttribute('type', 'password');
})
})
})

View File

@@ -0,0 +1,11 @@
import {Fab, styled} from "@mui/material";
const StyledFab = styled(Fab)`
position: absolute;
bottom: 16px;
/* @noflip */
left: 16px;
z-index: 1500;
`;
export default StyledFab;

View File

@@ -36,4 +36,4 @@ const ErrorNotification = (t, status, message) => {
);
};
export default ErrorNotification;
export default ErrorNotification;

View File

@@ -9,4 +9,4 @@ const PendingNotification = (t) => {
});
};
export default PendingNotification;
export default PendingNotification;

View File

@@ -39,4 +39,4 @@ const SuccessNotification = (t, status) => {
);
};
export default SuccessNotification;
export default SuccessNotification;

View File

@@ -35,4 +35,4 @@ const UploadFileNotification = (t) => {
);
};
export default UploadFileNotification;
export default UploadFileNotification;

View File

@@ -37,4 +37,4 @@ const WarningNotification = (t, status) => {
);
};
export default WarningNotification;
export default WarningNotification;

View File

@@ -1,7 +1,7 @@
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL;
//login
export const GET_USER_TOKEN = BASE_URL + "/dashboard/login";
export const GET_USER_TOKEN = BASE_URL + "/api/auth/login";
//end login
//change password
@@ -9,7 +9,7 @@ export const SET_USER_PASSWORD = BASE_URL + "/dashboard/profile/change_password"
//end change password
//user data
export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info";
export const GET_USER_ROUTE = BASE_URL + "/api/profile/info";
//user data
//expert management

View File

@@ -48,7 +48,7 @@ const isServerError = status => status >= 500 && status <= 599;
const isClientError = status => status >= 400 && status <= 499;
const errorLogic = (response, t, notification) => {
if (notification) ErrorNotification(t, response.status)
if (notification) ErrorNotification(t, response.status, response.data.message)
}
const errorValidation = (response, t, notification) => {
if (notification) {