260323:0954 fix CI : Run Tests frontend #01
CI / CD Pipeline / build (push) Failing after 15m27s
CI / CD Pipeline / release (push) Has been skipped
CI / CD Pipeline / deploy (push) Has been skipped

This commit is contained in:
admin
2026-03-23 09:54:31 +07:00
parent 4422c68894
commit 32141f519a
8 changed files with 563 additions and 1073 deletions
+8 -8
View File
@@ -9,7 +9,7 @@ import { toast } from 'sonner';
vi.mock('@/lib/services/user.service', () => ({
userService: {
getAll: vi.fn(),
getById: vi.fn(),
getByUuid: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
@@ -26,7 +26,7 @@ describe('use-users hooks', () => {
it('should generate correct cache keys', () => {
expect(userKeys.all).toEqual(['users']);
expect(userKeys.list({ search: 'john' })).toEqual(['users', 'list', { search: 'john' }]);
expect(userKeys.detail(1)).toEqual(['users', 'detail', 1]);
expect(userKeys.detail('uuid-1')).toEqual(['users', 'detail', 'uuid-1']);
});
});
@@ -146,12 +146,12 @@ describe('use-users hooks', () => {
await act(async () => {
await result.current.mutateAsync({
id: 1,
uuid: 'uuid-1',
data: { email: 'updated@example.com' },
});
});
expect(userService.update).toHaveBeenCalledWith(1, { email: 'updated@example.com' });
expect(userService.update).toHaveBeenCalledWith('uuid-1', { email: 'updated@example.com' });
expect(toast.success).toHaveBeenCalledWith('User updated successfully');
});
@@ -168,7 +168,7 @@ describe('use-users hooks', () => {
await act(async () => {
try {
await result.current.mutateAsync({
id: 999,
uuid: 'uuid-999',
data: { email: 'test@example.com' },
});
} catch {
@@ -190,10 +190,10 @@ describe('use-users hooks', () => {
const { result } = renderHook(() => useDeleteUser(), { wrapper });
await act(async () => {
await result.current.mutateAsync(1);
await result.current.mutateAsync('uuid-1');
});
expect(userService.delete).toHaveBeenCalledWith(1);
expect(userService.delete).toHaveBeenCalledWith('uuid-1');
expect(toast.success).toHaveBeenCalledWith('User deleted successfully');
});
@@ -209,7 +209,7 @@ describe('use-users hooks', () => {
await act(async () => {
try {
await result.current.mutateAsync(1);
await result.current.mutateAsync('uuid-1');
} catch {
// Expected
}