Refactor multiline formatting, link definitions, and code consistency across components and tests
- Improved readability by updating multiline statements and object definitions. - Applied consistent link and button wrapping in `DemoSection` and other components. - Enhanced test assertions and helper functions with uniform formatting and parentheses usage.
This commit is contained in:
@@ -27,7 +27,8 @@ import { Separator } from '@/components/ui/separator';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Demo Tour | FastNext Template',
|
||||
description: 'Try all features with demo credentials - comprehensive guide to the FastNext template',
|
||||
description:
|
||||
'Try all features with demo credentials - comprehensive guide to the FastNext template',
|
||||
};
|
||||
|
||||
const demoCategories = [
|
||||
@@ -36,7 +37,12 @@ const demoCategories = [
|
||||
title: 'Design System Hub',
|
||||
description: 'Browse components, layouts, spacing, and forms with live examples',
|
||||
href: '/dev',
|
||||
features: ['All UI components', 'Layout patterns', 'Spacing philosophy', 'Form implementations'],
|
||||
features: [
|
||||
'All UI components',
|
||||
'Layout patterns',
|
||||
'Spacing philosophy',
|
||||
'Form implementations',
|
||||
],
|
||||
credentials: null,
|
||||
},
|
||||
{
|
||||
@@ -260,7 +266,8 @@ export default function DemoTourPage() {
|
||||
{/* CTA */}
|
||||
<Button asChild className="w-full gap-2">
|
||||
<Link href={category.href}>
|
||||
{category.credentials ? 'Try Now' : 'Explore'} <ArrowRight className="h-4 w-4" />
|
||||
{category.credentials ? 'Try Now' : 'Explore'}{' '}
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
</CardContent>
|
||||
|
||||
@@ -14,7 +14,8 @@ import { Separator } from '@/components/ui/separator';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Design System Hub | FastNext Template',
|
||||
description: 'Interactive design system demonstrations with live examples - explore components, layouts, spacing, and forms built with shadcn/ui and Tailwind CSS',
|
||||
description:
|
||||
'Interactive design system demonstrations with live examples - explore components, layouts, spacing, and forms built with shadcn/ui and Tailwind CSS',
|
||||
};
|
||||
|
||||
const demoPages = [
|
||||
|
||||
@@ -10,7 +10,17 @@
|
||||
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { Code2, Palette, LayoutDashboard, Box, FileText, BookOpen, Home, ArrowLeft, Rocket } from 'lucide-react';
|
||||
import {
|
||||
Code2,
|
||||
Palette,
|
||||
LayoutDashboard,
|
||||
Box,
|
||||
FileText,
|
||||
BookOpen,
|
||||
Home,
|
||||
ArrowLeft,
|
||||
Rocket,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { ThemeToggle } from '@/components/theme';
|
||||
|
||||
@@ -120,9 +120,7 @@ export function DemoSection() {
|
||||
transition={{ duration: 0.6, delay: 0.4 }}
|
||||
>
|
||||
<Button asChild variant="outline" size="lg" className="gap-2">
|
||||
<Link href="/demos">
|
||||
View Complete Demo Tour →
|
||||
</Link>
|
||||
<Link href="/demos">View Complete Demo Tour →</Link>
|
||||
</Button>
|
||||
</motion.div>
|
||||
</section>
|
||||
|
||||
@@ -30,7 +30,10 @@ describe('DemoTourPage', () => {
|
||||
const header = screen.getByRole('banner');
|
||||
expect(within(header).getByText('Demo Tour')).toBeInTheDocument();
|
||||
expect(within(header).getByRole('link', { name: /home/i })).toHaveAttribute('href', '/');
|
||||
expect(within(header).getByRole('link', { name: /start exploring/i })).toHaveAttribute('href', '/login');
|
||||
expect(within(header).getByRole('link', { name: /start exploring/i })).toHaveAttribute(
|
||||
'href',
|
||||
'/login'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +41,9 @@ describe('DemoTourPage', () => {
|
||||
it('renders hero heading and description', () => {
|
||||
render(<DemoTourPage />);
|
||||
expect(screen.getByText('Explore All Features')).toBeInTheDocument();
|
||||
expect(screen.getByText(/Try everything with our pre-configured demo accounts/i)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/Try everything with our pre-configured demo accounts/i)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders Interactive Demo badge', () => {
|
||||
@@ -63,7 +68,9 @@ describe('DemoTourPage', () => {
|
||||
expect(screen.getByText(/Copy the demo credentials and login/i)).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByText('Explore Freely')).toBeInTheDocument();
|
||||
expect(screen.getByText(/Test all features - everything resets automatically/i)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/Test all features - everything resets automatically/i)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,7 +84,9 @@ describe('DemoTourPage', () => {
|
||||
it('renders Design System Hub category', () => {
|
||||
render(<DemoTourPage />);
|
||||
expect(screen.getByText('Design System Hub')).toBeInTheDocument();
|
||||
expect(screen.getByText(/Browse components, layouts, spacing, and forms/i)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/Browse components, layouts, spacing, and forms/i)
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText('All UI components')).toBeInTheDocument();
|
||||
expect(screen.getByText('Layout patterns')).toBeInTheDocument();
|
||||
expect(screen.getByText('Spacing philosophy')).toBeInTheDocument();
|
||||
@@ -136,14 +145,14 @@ describe('DemoTourPage', () => {
|
||||
|
||||
// Design System Hub
|
||||
const exploreLinks = screen.getAllByRole('link', { name: /explore/i });
|
||||
expect(exploreLinks.some(link => link.getAttribute('href') === '/dev')).toBe(true);
|
||||
expect(exploreLinks.some((link) => link.getAttribute('href') === '/dev')).toBe(true);
|
||||
|
||||
// Authentication System
|
||||
const tryNowLinks = screen.getAllByRole('link', { name: /try now/i });
|
||||
expect(tryNowLinks.length).toBeGreaterThan(0);
|
||||
expect(tryNowLinks.some(link => link.getAttribute('href') === '/login')).toBe(true);
|
||||
expect(tryNowLinks.some(link => link.getAttribute('href') === '/settings')).toBe(true);
|
||||
expect(tryNowLinks.some(link => link.getAttribute('href') === '/admin')).toBe(true);
|
||||
expect(tryNowLinks.some((link) => link.getAttribute('href') === '/login')).toBe(true);
|
||||
expect(tryNowLinks.some((link) => link.getAttribute('href') === '/settings')).toBe(true);
|
||||
expect(tryNowLinks.some((link) => link.getAttribute('href') === '/admin')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -178,13 +187,13 @@ describe('DemoTourPage', () => {
|
||||
|
||||
// Quick Tour links
|
||||
const devLinks = screen.getAllByRole('link');
|
||||
const hasDevLink = devLinks.some(link => link.getAttribute('href') === '/dev');
|
||||
const hasDevLink = devLinks.some((link) => link.getAttribute('href') === '/dev');
|
||||
expect(hasDevLink).toBe(true);
|
||||
|
||||
const hasLoginLink = devLinks.some(link => link.getAttribute('href') === '/login');
|
||||
const hasLoginLink = devLinks.some((link) => link.getAttribute('href') === '/login');
|
||||
expect(hasLoginLink).toBe(true);
|
||||
|
||||
const hasSettingsLink = devLinks.some(link => link.getAttribute('href') === '/settings');
|
||||
const hasSettingsLink = devLinks.some((link) => link.getAttribute('href') === '/settings');
|
||||
expect(hasSettingsLink).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -199,7 +208,9 @@ describe('DemoTourPage', () => {
|
||||
it('renders Feature Checklist card', () => {
|
||||
render(<DemoTourPage />);
|
||||
expect(screen.getByText('Feature Checklist')).toBeInTheDocument();
|
||||
expect(screen.getByText(/Try these features to experience the full power/i)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/Try these features to experience the full power/i)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders all checklist items', () => {
|
||||
@@ -224,17 +235,19 @@ describe('DemoTourPage', () => {
|
||||
it('renders final CTA heading', () => {
|
||||
render(<DemoTourPage />);
|
||||
expect(screen.getByText('Ready to Start?')).toBeInTheDocument();
|
||||
expect(screen.getByText(/Pick a demo category above or jump right into the action/i)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/Pick a demo category above or jump right into the action/i)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('has CTA buttons', () => {
|
||||
render(<DemoTourPage />);
|
||||
|
||||
const tryAuthLinks = screen.getAllByRole('link', { name: /try authentication flow/i });
|
||||
expect(tryAuthLinks.some(link => link.getAttribute('href') === '/login')).toBe(true);
|
||||
expect(tryAuthLinks.some((link) => link.getAttribute('href') === '/login')).toBe(true);
|
||||
|
||||
const browseDesignLinks = screen.getAllByRole('link', { name: /browse design system/i });
|
||||
expect(browseDesignLinks.some(link => link.getAttribute('href') === '/dev')).toBe(true);
|
||||
expect(browseDesignLinks.some((link) => link.getAttribute('href') === '/dev')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -263,7 +276,7 @@ describe('DemoTourPage', () => {
|
||||
expect(allLinks.length).toBeGreaterThan(10);
|
||||
|
||||
// Verify key destination paths exist
|
||||
const hrefs = allLinks.map(link => link.getAttribute('href'));
|
||||
const hrefs = allLinks.map((link) => link.getAttribute('href'));
|
||||
expect(hrefs).toContain('/');
|
||||
expect(hrefs).toContain('/dev');
|
||||
expect(hrefs).toContain('/login');
|
||||
|
||||
@@ -267,7 +267,7 @@ describe('HomePage', () => {
|
||||
|
||||
// Close the modal
|
||||
const closeButtons = screen.getAllByRole('button', { name: /close/i });
|
||||
const modalCloseButton = closeButtons.find(btn => btn.textContent === 'Close');
|
||||
const modalCloseButton = closeButtons.find((btn) => btn.textContent === 'Close');
|
||||
if (modalCloseButton) {
|
||||
fireEvent.click(modalCloseButton);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user