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:
2025-11-12 17:48:22 +01:00
parent 228d12b379
commit 14e5839476
3 changed files with 17 additions and 12 deletions

View File

@@ -149,8 +149,9 @@ describe('HomePage', () => {
it('renders demo cards', () => {
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('User Dashboard')[0]).toBeInTheDocument();
// Admin Dashboard appears in both Feature Grid and Demo Section, so use getAllByText
const adminDashboards = screen.getAllByText('Admin Dashboard');
expect(adminDashboards.length).toBeGreaterThanOrEqual(1);
@@ -230,9 +231,9 @@ describe('HomePage', () => {
expect(loginLinks.some((link) => link.getAttribute('href') === '/login')).toBe(true);
});
it('has component showcase link', () => {
it('has design system link', () => {
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);
});

View File

@@ -49,7 +49,7 @@ describe('DemoCredentialsModal', () => {
expect(screen.getByText('Regular User')).toBeInTheDocument();
expect(screen.getByText('demo@example.com')).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', () => {
@@ -58,7 +58,7 @@ describe('DemoCredentialsModal', () => {
expect(screen.getByText('Admin User (Superuser)')).toBeInTheDocument();
expect(screen.getByText('admin@example.com')).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 () => {
@@ -152,17 +152,20 @@ describe('DemoCredentialsModal', () => {
expect(mockOnClose).toHaveBeenCalled();
});
it('has a link to login page', () => {
it('has links to login page', () => {
render(<DemoCredentialsModal open={true} onClose={mockOnClose} />);
const loginLink = screen.getByRole('link', { name: /go to login/i });
expect(loginLink).toHaveAttribute('href', '/login');
const loginAsUserLink = screen.getByRole('link', { name: /login as user/i });
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', () => {
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);
expect(mockOnClose).toHaveBeenCalled();

View File

@@ -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');
});
@@ -154,8 +155,8 @@ describe('Header', () => {
// 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
const componentsLinks = screen.getAllByRole('link', { name: /components/i });
expect(componentsLinks.length).toBeGreaterThan(0);
const designSystemLinks = screen.getAllByRole('link', { name: /Design System/i });
expect(designSystemLinks.length).toBeGreaterThan(0);
});
it('mobile menu contains GitHub link', () => {