Update test suite to reflect "Design System" renaming and improved navigation structure
- Replaced "Components" references with "Design System" in both links and test assertions. - Adjusted `DemoCredentialsModal` tests to include separate links for user/admin login and updated text expectations. - Enhanced `Home` tests with new demo content validation (`User Dashboard`) and renamed navigation elements.
This commit is contained in:
@@ -149,8 +149,9 @@ describe('HomePage', () => {
|
|||||||
|
|
||||||
it('renders demo cards', () => {
|
it('renders demo cards', () => {
|
||||||
render(<Home />);
|
render(<Home />);
|
||||||
expect(screen.getAllByText('Component Showcase')[0]).toBeInTheDocument();
|
expect(screen.getAllByText('Design System Hub')[0]).toBeInTheDocument();
|
||||||
expect(screen.getAllByText('Authentication Flow')[0]).toBeInTheDocument();
|
expect(screen.getAllByText('Authentication Flow')[0]).toBeInTheDocument();
|
||||||
|
expect(screen.getAllByText('User Dashboard')[0]).toBeInTheDocument();
|
||||||
// Admin Dashboard appears in both Feature Grid and Demo Section, so use getAllByText
|
// Admin Dashboard appears in both Feature Grid and Demo Section, so use getAllByText
|
||||||
const adminDashboards = screen.getAllByText('Admin Dashboard');
|
const adminDashboards = screen.getAllByText('Admin Dashboard');
|
||||||
expect(adminDashboards.length).toBeGreaterThanOrEqual(1);
|
expect(adminDashboards.length).toBeGreaterThanOrEqual(1);
|
||||||
@@ -230,9 +231,9 @@ describe('HomePage', () => {
|
|||||||
expect(loginLinks.some((link) => link.getAttribute('href') === '/login')).toBe(true);
|
expect(loginLinks.some((link) => link.getAttribute('href') === '/login')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has component showcase link', () => {
|
it('has design system link', () => {
|
||||||
render(<Home />);
|
render(<Home />);
|
||||||
const devLinks = screen.getAllByRole('link', { name: /Component/i });
|
const devLinks = screen.getAllByRole('link', { name: /Design System/i });
|
||||||
expect(devLinks.some((link) => link.getAttribute('href') === '/dev')).toBe(true);
|
expect(devLinks.some((link) => link.getAttribute('href') === '/dev')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ describe('DemoCredentialsModal', () => {
|
|||||||
expect(screen.getByText('Regular User')).toBeInTheDocument();
|
expect(screen.getByText('Regular User')).toBeInTheDocument();
|
||||||
expect(screen.getByText('demo@example.com')).toBeInTheDocument();
|
expect(screen.getByText('demo@example.com')).toBeInTheDocument();
|
||||||
expect(screen.getByText('Demo123!')).toBeInTheDocument();
|
expect(screen.getByText('Demo123!')).toBeInTheDocument();
|
||||||
expect(screen.getByText(/Access settings, organizations/i)).toBeInTheDocument();
|
expect(screen.getByText(/User settings & profile/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays admin user credentials', () => {
|
it('displays admin user credentials', () => {
|
||||||
@@ -58,7 +58,7 @@ describe('DemoCredentialsModal', () => {
|
|||||||
expect(screen.getByText('Admin User (Superuser)')).toBeInTheDocument();
|
expect(screen.getByText('Admin User (Superuser)')).toBeInTheDocument();
|
||||||
expect(screen.getByText('admin@example.com')).toBeInTheDocument();
|
expect(screen.getByText('admin@example.com')).toBeInTheDocument();
|
||||||
expect(screen.getByText('Admin123!')).toBeInTheDocument();
|
expect(screen.getByText('Admin123!')).toBeInTheDocument();
|
||||||
expect(screen.getByText(/Full admin panel access/i)).toBeInTheDocument();
|
expect(screen.getByText(/Full admin dashboard/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('copies regular user credentials to clipboard', async () => {
|
it('copies regular user credentials to clipboard', async () => {
|
||||||
@@ -152,17 +152,20 @@ describe('DemoCredentialsModal', () => {
|
|||||||
expect(mockOnClose).toHaveBeenCalled();
|
expect(mockOnClose).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has a link to login page', () => {
|
it('has links to login page', () => {
|
||||||
render(<DemoCredentialsModal open={true} onClose={mockOnClose} />);
|
render(<DemoCredentialsModal open={true} onClose={mockOnClose} />);
|
||||||
|
|
||||||
const loginLink = screen.getByRole('link', { name: /go to login/i });
|
const loginAsUserLink = screen.getByRole('link', { name: /login as user/i });
|
||||||
expect(loginLink).toHaveAttribute('href', '/login');
|
expect(loginAsUserLink).toHaveAttribute('href', '/login');
|
||||||
|
|
||||||
|
const loginAsAdminLink = screen.getByRole('link', { name: /login as admin/i });
|
||||||
|
expect(loginAsAdminLink).toHaveAttribute('href', '/login');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls onClose when login link is clicked', () => {
|
it('calls onClose when login link is clicked', () => {
|
||||||
render(<DemoCredentialsModal open={true} onClose={mockOnClose} />);
|
render(<DemoCredentialsModal open={true} onClose={mockOnClose} />);
|
||||||
|
|
||||||
const loginLink = screen.getByRole('link', { name: /go to login/i });
|
const loginLink = screen.getByRole('link', { name: /login as user/i });
|
||||||
fireEvent.click(loginLink);
|
fireEvent.click(loginLink);
|
||||||
|
|
||||||
expect(mockOnClose).toHaveBeenCalled();
|
expect(mockOnClose).toHaveBeenCalled();
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ describe('Header', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByRole('link', { name: 'Components' })).toHaveAttribute('href', '/dev');
|
expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/');
|
||||||
|
expect(screen.getByRole('link', { name: 'Design System' })).toHaveAttribute('href', '/dev');
|
||||||
expect(screen.getByRole('link', { name: 'Admin Demo' })).toHaveAttribute('href', '/admin');
|
expect(screen.getByRole('link', { name: 'Admin Demo' })).toHaveAttribute('href', '/admin');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -154,8 +155,8 @@ describe('Header', () => {
|
|||||||
|
|
||||||
// Note: SheetContent is hidden by default in tests, but we can verify the links exist
|
// Note: SheetContent is hidden by default in tests, but we can verify the links exist
|
||||||
// The actual mobile menu behavior is tested in E2E tests
|
// The actual mobile menu behavior is tested in E2E tests
|
||||||
const componentsLinks = screen.getAllByRole('link', { name: /components/i });
|
const designSystemLinks = screen.getAllByRole('link', { name: /Design System/i });
|
||||||
expect(componentsLinks.length).toBeGreaterThan(0);
|
expect(designSystemLinks.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('mobile menu contains GitHub link', () => {
|
it('mobile menu contains GitHub link', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user