feat(tests, components): enhance Cypress commands and UI elements for improved testing and accessibility

- Added new Cypress commands for mocking admin-related API interactions, including list, create, update, delete, and change status functionalities.
- Introduced data-cy attributes across various components (e.g., Breadcrumbs, Forms, Tables) to improve testability and accessibility.
- Updated existing components to support new data-cy attributes for better integration with Cypress tests.
This commit is contained in:
AmirReza Jamali
2026-04-25 13:25:23 +03:30
parent 2a4f3e7e4b
commit eab516c7f3
24 changed files with 814 additions and 23 deletions
@@ -38,6 +38,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
onSubmit={handleSubmit((data) => {
onSubmit(data);
})}
data-cy={editMode ? "admin-edit-form" : "admin-create-form"}
>
<div className="flex flex-col gap-9">
<ShowcaseSection
@@ -62,6 +63,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
required
type="text"
name="full_name"
dataCy="admin-form-full-name-input"
/>
{errors.full_name && (
<p className="mt-1 text-sm text-red-500">
@@ -96,6 +98,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
},
})}
name="username"
dataCy="admin-form-username-input"
/>
{errors.username && (
<p className="mt-1 text-sm text-red-500">
@@ -122,6 +125,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
},
})}
name="email"
dataCy="admin-form-email-input"
/>
{errors.email && (
<p className="mt-1 text-sm text-red-500">
@@ -152,6 +156,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
},
})}
name="password"
dataCy="admin-form-password-input"
/>
{errors.password && (
<p className="mt-1 text-sm text-red-500">
@@ -180,6 +185,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
},
})}
name="phone"
dataCy="admin-form-phone-input"
/>
{errors.phone && (
<p className="mt-1 text-sm text-red-500">
@@ -203,6 +209,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
},
})}
name="department"
dataCy="admin-form-department-input"
/>
{errors.department && (
<p className="mt-1 text-sm text-red-500">
@@ -226,6 +233,7 @@ const CreateAdminForm: FC<IProps> = ({ defaultValues, editMode, id }) => {
},
})}
name="position"
dataCy="admin-form-position-input"
/>
{errors.position && (
<p className="mt-1 text-sm text-red-500">