test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
1 parent
1e73715169
commit
ddbf1ca026
439 files changed
+32911
-6107
No files matched your search
@@ -0,0 +1,113 @@
|
||||
import React from 'react';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render } from '@testing-library/react';
|
||||
import {
|
||||
Skeleton,
|
||||
ProductCardSkeleton,
|
||||
ProductListSkeleton,
|
||||
PetProfileSkeleton,
|
||||
OrderRowSkeleton,
|
||||
} from '../Skeleton';
|
||||
|
||||
describe('Skeleton Components', () => {
|
||||
describe('Skeleton base component', () => {
|
||||
it('renders with default base classes including animation and shimmer', () => {
|
||||
const { container } = render(<Skeleton />);
|
||||
const el = container.firstElementChild;
|
||||
|
||||
expect(el).toBeInTheDocument();
|
||||
expect(el).toHaveClass('bg-medical-gray-100');
|
||||
expect(el).toHaveClass('animate-pulse');
|
||||
expect(el).toHaveClass('rounded-2xl');
|
||||
expect(el).toHaveClass('relative');
|
||||
expect(el).toHaveClass('overflow-hidden');
|
||||
// Shimmer pseudo element classes check
|
||||
expect(el?.className).toContain('before:absolute');
|
||||
expect(el?.className).toContain('before:inset-0');
|
||||
expect(el?.className).toContain('before:-translate-x-full');
|
||||
expect(el?.className).toContain('before:animate-[shimmer_2s_infinite]');
|
||||
expect(el?.className).toContain('before:bg-gradient-to-r');
|
||||
});
|
||||
|
||||
it('applies custom className sizing and styling correctly', () => {
|
||||
const { container } = render(<Skeleton className="w-32 h-8 rounded-full custom-skeleton-class" />);
|
||||
const el = container.firstElementChild;
|
||||
|
||||
expect(el).toHaveClass('w-32');
|
||||
expect(el).toHaveClass('h-8');
|
||||
expect(el).toHaveClass('rounded-full');
|
||||
expect(el).toHaveClass('custom-skeleton-class');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ProductCardSkeleton variant', () => {
|
||||
it('renders card skeleton layout with image, tags, titles, symptoms, and footer placeholders', () => {
|
||||
const { container } = render(<ProductCardSkeleton />);
|
||||
|
||||
const rootCard = container.firstElementChild;
|
||||
expect(rootCard).toHaveClass('bg-white');
|
||||
expect(rootCard).toHaveClass('rounded-[2.5rem]');
|
||||
expect(rootCard).toHaveClass('shadow-sm');
|
||||
|
||||
// Check skeleton elements inside
|
||||
const skeletons = container.querySelectorAll('.animate-pulse');
|
||||
expect(skeletons.length).toBeGreaterThanOrEqual(7);
|
||||
|
||||
// Verify aspect-square placeholder for product image
|
||||
const imagePlaceholder = container.querySelector('.aspect-square');
|
||||
expect(imagePlaceholder).toBeInTheDocument();
|
||||
expect(imagePlaceholder).toHaveClass('rounded-[2rem]', 'w-full', 'mb-6');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ProductListSkeleton variant', () => {
|
||||
it('renders horizontal list skeleton item with image thumb and info rows', () => {
|
||||
const { container } = render(<ProductListSkeleton />);
|
||||
|
||||
const root = container.firstElementChild;
|
||||
expect(root).toHaveClass('bg-white', 'rounded-2xl', 'p-3');
|
||||
|
||||
const skeletons = container.querySelectorAll('.animate-pulse');
|
||||
expect(skeletons.length).toBe(6); // thumb + 3 info rows + 2 footer action rows
|
||||
|
||||
// Thumbnail check
|
||||
const thumb = container.querySelector('.w-24.h-24');
|
||||
expect(thumb).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('PetProfileSkeleton variant', () => {
|
||||
it('renders pet profile skeleton layout with avatar, headers, badges, and stat cards', () => {
|
||||
const { container } = render(<PetProfileSkeleton />);
|
||||
|
||||
const root = container.firstElementChild;
|
||||
expect(root).toHaveClass('bg-white', 'rounded-[3rem]', 'shadow-2xl');
|
||||
|
||||
// Avatar placeholder
|
||||
const avatar = container.querySelector('.w-40.h-40');
|
||||
expect(avatar).toBeInTheDocument();
|
||||
|
||||
// Check 4 stat cards exist
|
||||
const statCards = container.querySelectorAll('.bg-medical-gray-50');
|
||||
expect(statCards.length).toBe(4);
|
||||
|
||||
const skeletons = container.querySelectorAll('.animate-pulse');
|
||||
expect(skeletons.length).toBeGreaterThanOrEqual(13); // avatar + 2 headers + 2 tags + 4*2 stats
|
||||
});
|
||||
});
|
||||
|
||||
describe('OrderRowSkeleton variant', () => {
|
||||
it('renders order row skeleton with thumbnail and order detail blocks', () => {
|
||||
const { container } = render(<OrderRowSkeleton />);
|
||||
|
||||
const root = container.firstElementChild;
|
||||
expect(root).toHaveClass('flex', 'items-center', 'gap-6', 'p-6');
|
||||
|
||||
const thumb = container.querySelector('.w-16.h-16');
|
||||
expect(thumb).toBeInTheDocument();
|
||||
|
||||
const skeletons = container.querySelectorAll('.animate-pulse');
|
||||
expect(skeletons.length).toBe(5); // thumb + 4 detail placeholders
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user