fix(lint&types): resolve all lint warnings, typecheck errors and effect state updates across frontend application and admin panel
This commit is contained in:
1 parent
920dd532e8
commit
c1b2f416ed
29 files changed
+442
-352
No files matched your search
@@ -44,7 +44,7 @@ describe('CartDrawer', () => {
|
||||
coupon: null,
|
||||
applyCoupon: vi.fn(),
|
||||
addItem: vi.fn(),
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof useCartStore>);
|
||||
|
||||
render(<CartDrawer isOpen={true} onClose={vi.fn()} onCheckout={vi.fn()} />);
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('CartDrawer', () => {
|
||||
coupon: null,
|
||||
applyCoupon: vi.fn(),
|
||||
addItem: vi.fn(),
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof useCartStore>);
|
||||
|
||||
render(<CartDrawer isOpen={true} onClose={vi.fn()} onCheckout={vi.fn()} />);
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('CartDrawer', () => {
|
||||
coupon: null,
|
||||
applyCoupon: vi.fn(),
|
||||
addItem: vi.fn(),
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof useCartStore>);
|
||||
|
||||
render(<CartDrawer isOpen={true} onClose={vi.fn()} onCheckout={vi.fn()} />);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('FeaturedProducts', () => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(usePetStore).mockReturnValue({
|
||||
getActivePet: () => null,
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof usePetStore>);
|
||||
});
|
||||
|
||||
it('renders loading skeletons initially', () => {
|
||||
@@ -48,7 +48,7 @@ describe('FeaturedProducts', () => {
|
||||
});
|
||||
|
||||
it('renders products once loaded', async () => {
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as any);
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as unknown as ReturnType<typeof productService.getFeaturedProducts>);
|
||||
render(<FeaturedProducts onProductClick={vi.fn()} onShopNavigate={vi.fn()} />);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -59,7 +59,7 @@ describe('FeaturedProducts', () => {
|
||||
|
||||
it('calls onProductClick when product card is clicked', async () => {
|
||||
const handleProductClick = vi.fn();
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as any);
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as unknown as ReturnType<typeof productService.getFeaturedProducts>);
|
||||
render(<FeaturedProducts onProductClick={handleProductClick} onShopNavigate={vi.fn()} />);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -72,7 +72,7 @@ describe('FeaturedProducts', () => {
|
||||
|
||||
it('calls onShopNavigate when navigation link is clicked', async () => {
|
||||
const handleShopNavigate = vi.fn();
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as any);
|
||||
vi.mocked(productService.getFeaturedProducts).mockResolvedValue(mockProducts as unknown as ReturnType<typeof productService.getFeaturedProducts>);
|
||||
render(<FeaturedProducts onProductClick={vi.fn()} onShopNavigate={handleShopNavigate} />);
|
||||
|
||||
const navBtn = screen.getByText('مشاهده تمامی محصولات');
|
||||
|
||||
@@ -25,21 +25,21 @@ describe('Header', () => {
|
||||
|
||||
vi.mocked(useCartStore).mockReturnValue({
|
||||
getTotalItems: () => 3,
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof useCartStore>);
|
||||
|
||||
vi.mocked(usePetStore).mockReturnValue({
|
||||
pets: [],
|
||||
activePetId: null,
|
||||
setActivePet: vi.fn(),
|
||||
getActivePet: () => null,
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof usePetStore>);
|
||||
|
||||
vi.mocked(useUserStore).mockReturnValue({
|
||||
role: 'User_Guest',
|
||||
isLoggedIn: false,
|
||||
logout: vi.fn(),
|
||||
profile: { firstName: '' },
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof useUserStore>);
|
||||
});
|
||||
|
||||
it('renders brand name and login button when guest', () => {
|
||||
@@ -65,14 +65,14 @@ describe('Header', () => {
|
||||
isLoggedIn: true,
|
||||
logout: vi.fn(),
|
||||
profile: { firstName: 'کوروش' },
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof useUserStore>);
|
||||
|
||||
vi.mocked(usePetStore).mockReturnValue({
|
||||
pets: [{ id: 'pet-1', name: 'ملوس', type: 'گربه' }],
|
||||
activePetId: 'pet-1',
|
||||
setActivePet: vi.fn(),
|
||||
getActivePet: () => ({ id: 'pet-1', name: 'ملوس', type: 'گربه' }),
|
||||
} as any);
|
||||
} as unknown as ReturnType<typeof usePetStore>);
|
||||
|
||||
render(
|
||||
<Header
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('Hero', () => {
|
||||
return fallback;
|
||||
});
|
||||
|
||||
vi.mocked(useSettingsStore).mockImplementation((selector: any) => selector({ getText: mockGetText }));
|
||||
vi.mocked(useSettingsStore).mockImplementation((selector: (state: { getText: (key: string, fallback: string) => string }) => unknown) => selector({ getText: mockGetText }) as ReturnType<typeof selector>);
|
||||
|
||||
render(<Hero onShopNavigate={vi.fn()} />);
|
||||
|
||||
@@ -31,8 +31,8 @@ describe('Hero', () => {
|
||||
});
|
||||
|
||||
it('calls onShopNavigate when "مشاهده محصولات" button is clicked', () => {
|
||||
const mockGetText = vi.fn().mockImplementation((key, fallback) => fallback);
|
||||
vi.mocked(useSettingsStore).mockImplementation((selector: any) => selector({ getText: mockGetText }));
|
||||
const mockGetText = vi.fn().mockImplementation((_key, fallback) => fallback);
|
||||
vi.mocked(useSettingsStore).mockImplementation((selector: (state: { getText: (key: string, fallback: string) => string }) => unknown) => selector({ getText: mockGetText }) as ReturnType<typeof selector>);
|
||||
|
||||
const handleShopNavigate = vi.fn();
|
||||
render(<Hero onShopNavigate={handleShopNavigate} />);
|
||||
|
||||
Reference in new issue
Block a user