= ({ defaultValues, editMode, id }) => {
required
type="text"
name="full_name"
+ dataCy="admin-form-full-name-input"
/>
{errors.full_name && (
@@ -96,6 +98,7 @@ const CreateAdminForm: FC = ({ defaultValues, editMode, id }) => {
},
})}
name="username"
+ dataCy="admin-form-username-input"
/>
{errors.username && (
@@ -122,6 +125,7 @@ const CreateAdminForm: FC = ({ defaultValues, editMode, id }) => {
},
})}
name="email"
+ dataCy="admin-form-email-input"
/>
{errors.email && (
@@ -152,6 +156,7 @@ const CreateAdminForm: FC = ({ defaultValues, editMode, id }) => {
},
})}
name="password"
+ dataCy="admin-form-password-input"
/>
{errors.password && (
@@ -180,6 +185,7 @@ const CreateAdminForm: FC = ({ defaultValues, editMode, id }) => {
},
})}
name="phone"
+ dataCy="admin-form-phone-input"
/>
{errors.phone && (
@@ -203,6 +209,7 @@ const CreateAdminForm: FC = ({ defaultValues, editMode, id }) => {
},
})}
name="department"
+ dataCy="admin-form-department-input"
/>
{errors.department && (
@@ -226,6 +233,7 @@ const CreateAdminForm: FC = ({ defaultValues, editMode, id }) => {
},
})}
name="position"
+ dataCy="admin-form-position-input"
/>
{errors.position && (
diff --git a/src/components/ui/ConfirmationModal.tsx b/src/components/ui/ConfirmationModal.tsx
index 38b9a8e..0543273 100644
--- a/src/components/ui/ConfirmationModal.tsx
+++ b/src/components/ui/ConfirmationModal.tsx
@@ -99,10 +99,12 @@ const ConfirmationModal: React.FC = (props) => {
aria-labelledby="modal-title"
role="dialog"
aria-modal="true"
+ data-cy="confirmation-modal"
>
@@ -139,6 +141,7 @@ const ConfirmationModal: React.FC
= (props) => {
className={`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 sm:ml-3 sm:w-auto ${currentVariant.confirmBtn} dark:ring-offset-dark-2`}
disabled={isMutating > 0}
onClick={onConfirm}
+ data-cy="confirmation-modal-confirm"
>
{isMutating ? (
@@ -150,6 +153,7 @@ const ConfirmationModal: React.FC = (props) => {
type="button"
className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-dark shadow-sm ring-1 ring-inset ring-stroke hover:bg-gray focus:outline-none focus:ring-2 focus:ring-dark-5 focus:ring-offset-2 dark:bg-dark-3 dark:text-white dark:ring-stroke-dark dark:hover:bg-dark-4 dark:focus:ring-offset-dark-2 sm:mt-0 sm:w-auto"
onClick={onCancel}
+ data-cy="confirmation-modal-cancel"
>
{cancelText}
diff --git a/src/components/ui/FormFooter.tsx b/src/components/ui/FormFooter.tsx
index 1b30dcb..48a1256 100644
--- a/src/components/ui/FormFooter.tsx
+++ b/src/components/ui/FormFooter.tsx
@@ -24,6 +24,7 @@ const FormFooter = ({ onCancel }: IProps) => {
shape="rounded"
size="small"
type="submit"
+ data-cy="admin-form-submit-button"
disabled={isMutating > 0}
className="mt-6 w-fit rounded-lg bg-primary p-[13px] font-medium text-white hover:bg-opacity-90"
/>
@@ -32,6 +33,7 @@ const FormFooter = ({ onCancel }: IProps) => {
shape="rounded"
size="small"
type="button"
+ data-cy="admin-form-cancel-button"
variant="error"
onClick={onCancel ?? router.back}
className="mt-6 w-fit rounded-lg bg-error p-[13px] font-medium text-white hover:bg-opacity-90"
diff --git a/src/components/ui/ListHeader.tsx b/src/components/ui/ListHeader.tsx
index 2863c49..011c71f 100644
--- a/src/components/ui/ListHeader.tsx
+++ b/src/components/ui/ListHeader.tsx
@@ -10,6 +10,7 @@ interface IProps {
createButtonText?: string;
filterButtonText?: string;
onFilter?: () => void;
+ dataCyPrefix?: string;
}
const ListHeader = ({
@@ -18,6 +19,7 @@ const ListHeader = ({
createButtonText = "Create",
filterButtonText = "Filter",
onFilter,
+ dataCyPrefix = "list-header",
}: IProps) => {
const pathName = usePathname();
const router = useRouter();
@@ -35,6 +37,7 @@ const ListHeader = ({
shape="rounded"
size="small"
onClick={onFilter}
+ data-cy={`${dataCyPrefix}-filter-button`}
className="shadow-theme-xs mb-5 self-end rounded-xl border-stroke/70 bg-white/80 px-5 text-sm font-semibold text-dark transition-all duration-300 hover:border-primary/35 hover:text-primary dark:border-dark-3 dark:bg-dark-2 dark:text-white dark:hover:bg-white/[0.08]"
/>
@@ -45,6 +48,7 @@ const ListHeader = ({
shape="rounded"
size="small"
onClick={() => router.push(`${pathName}/create`)}
+ data-cy={`${dataCyPrefix}-create-button`}
className="shadow-theme-xs mb-5 self-end rounded-xl bg-gradient-to-r from-primary to-primary/85 text-sm font-semibold transition-all duration-300 hover:opacity-95"
/>
diff --git a/src/components/ui/ListWrapper.tsx b/src/components/ui/ListWrapper.tsx
index ba2f919..573443c 100644
--- a/src/components/ui/ListWrapper.tsx
+++ b/src/components/ui/ListWrapper.tsx
@@ -1,12 +1,15 @@
-import { ReactNode } from "react";
+import { HTMLAttributes, ReactNode } from "react";
type ListWrapperProps = {
children: ReactNode;
-};
+} & HTMLAttributes;
-const ListWrapper = ({ children }: ListWrapperProps) => {
+const ListWrapper = ({ children, ...props }: ListWrapperProps) => {
return (
-
+
{children}
);
diff --git a/src/components/ui/TableSkeleton.tsx b/src/components/ui/TableSkeleton.tsx
index 11021c9..37c7af2 100644
--- a/src/components/ui/TableSkeleton.tsx
+++ b/src/components/ui/TableSkeleton.tsx
@@ -13,11 +13,11 @@ const TableSkeleton = ({
cellColSpan = 100,
}: IProps) => {
return (
-
+
{Array.from({ length }).map((_, i) => (
-
+
{Array.from({ length: column }).map((_, j) => (
-
+
))}
diff --git a/src/components/ui/modal.tsx b/src/components/ui/modal.tsx
index 991f822..a0ce7c3 100644
--- a/src/components/ui/modal.tsx
+++ b/src/components/ui/modal.tsx
@@ -50,14 +50,17 @@ const Modal: React.FC = ({
e.stopPropagation()}
+ data-cy="modal-content"
>
@@ -70,6 +73,7 @@ const Modal: React.FC
= ({
shape="rounded"
className="mt-6 w-fit capitalize"
onClick={onConfirm}
+ data-cy="modal-confirm-button"
label={
isMutating ? (
@@ -85,6 +89,7 @@ const Modal: React.FC = ({
shape="rounded"
className="mt-6 w-fit capitalize"
onClick={onClose}
+ data-cy="modal-cancel-button"
label={cancelText}
/>