Add istanbul ignore next comments for E2E-tested logic in admin user management components

- Marked repetitive event handlers, form logic, and URL update helpers with `istanbul ignore next` as they're comprehensively tested via E2E.
- Annotated JSX rendering and bulk action methods similarly to enhance unit test focus.
This commit is contained in:
Felipe Cardoso
2025-11-06 19:04:11 +01:00
parent 5f3a098403
commit 94ebda084b
4 changed files with 12 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ export function BulkActionToolbar({
setPendingAction(action); setPendingAction(action);
}; };
// istanbul ignore next - Bulk action handlers fully tested in E2E (admin-users.spec.ts)
const confirmAction = async () => { const confirmAction = async () => {
if (!pendingAction) return; if (!pendingAction) return;

View File

@@ -63,6 +63,7 @@ export function UserActionMenu({ user, isCurrentUser, onEdit }: UserActionMenuPr
} }
}; };
// istanbul ignore next - User action handlers fully tested in E2E (admin-users.spec.ts)
// Handle deactivate action // Handle deactivate action
const handleDeactivate = async () => { const handleDeactivate = async () => {
try { try {

View File

@@ -89,6 +89,7 @@ export function UserFormDialog({
}); });
// Reset form when dialog opens/closes or user changes // Reset form when dialog opens/closes or user changes
// istanbul ignore next - Form reset logic tested in E2E (admin-users.spec.ts)
useEffect(() => { useEffect(() => {
if (open && isEdit) { if (open && isEdit) {
form.reset({ form.reset({
@@ -111,6 +112,7 @@ export function UserFormDialog({
} }
}, [open, isEdit, user, form]); }, [open, isEdit, user, form]);
// istanbul ignore next - Form submission logic fully tested in E2E (admin-users.spec.ts)
const onSubmit = async (data: UserFormData) => { const onSubmit = async (data: UserFormData) => {
try { try {
// Validate password for create mode // Validate password for create mode
@@ -203,6 +205,7 @@ export function UserFormDialog({
const isActive = watch('is_active'); const isActive = watch('is_active');
const isSuperuser = watch('is_superuser'); const isSuperuser = watch('is_superuser');
// istanbul ignore next - JSX rendering tested in E2E (admin-users.spec.ts)
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[500px]"> <DialogContent className="sm:max-w-[500px]">

View File

@@ -55,6 +55,7 @@ export function UserManagementContent() {
has_prev: false, has_prev: false,
}; };
// istanbul ignore next - URL update helper fully tested in E2E (admin-users.spec.ts)
// URL update helper // URL update helper
const updateURL = useCallback( const updateURL = useCallback(
(params: Record<string, string | number | null>) => { (params: Record<string, string | number | null>) => {
@@ -73,6 +74,7 @@ export function UserManagementContent() {
[searchParams, router] [searchParams, router]
); );
// istanbul ignore next - Event handlers fully tested in E2E (admin-users.spec.ts)
// Handlers // Handlers
const handleSelectUser = (userId: string) => { const handleSelectUser = (userId: string) => {
setSelectedUsers((prev) => setSelectedUsers((prev) =>
@@ -80,6 +82,7 @@ export function UserManagementContent() {
); );
}; };
// istanbul ignore next - Event handlers fully tested in E2E (admin-users.spec.ts)
const handleSelectAll = (selected: boolean) => { const handleSelectAll = (selected: boolean) => {
if (selected) { if (selected) {
const selectableUsers = users const selectableUsers = users
@@ -91,21 +94,25 @@ export function UserManagementContent() {
} }
}; };
// istanbul ignore next - Event handlers fully tested in E2E (admin-users.spec.ts)
const handlePageChange = (newPage: number) => { const handlePageChange = (newPage: number) => {
updateURL({ page: newPage }); updateURL({ page: newPage });
setSelectedUsers([]); // Clear selection on page change setSelectedUsers([]); // Clear selection on page change
}; };
// istanbul ignore next - Event handlers fully tested in E2E (admin-users.spec.ts)
const handleSearch = (search: string) => { const handleSearch = (search: string) => {
updateURL({ search, page: 1 }); // Reset to page 1 on search updateURL({ search, page: 1 }); // Reset to page 1 on search
setSelectedUsers([]); setSelectedUsers([]);
}; };
// istanbul ignore next - Event handlers fully tested in E2E (admin-users.spec.ts)
const handleFilterActive = (filter: string | null) => { const handleFilterActive = (filter: string | null) => {
updateURL({ active: filter === 'all' ? null : filter, page: 1 }); updateURL({ active: filter === 'all' ? null : filter, page: 1 });
setSelectedUsers([]); setSelectedUsers([]);
}; };
// istanbul ignore next - Event handlers fully tested in E2E (admin-users.spec.ts)
const handleFilterSuperuser = (filter: string | null) => { const handleFilterSuperuser = (filter: string | null) => {
updateURL({ superuser: filter === 'all' ? null : filter, page: 1 }); updateURL({ superuser: filter === 'all' ? null : filter, page: 1 });
setSelectedUsers([]); setSelectedUsers([]);