2026-11-05 13:03:19 +05:30
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { renderToString } from 'react-dom/server';
|
|
|
|
|
import { Cinematic3DComparison } from '@/components/ui/Cinematic3DComparison';
|
|
|
|
|
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
|
|
|
|
import { ShiftableToolsGridSection } from '@/components/sections/ShiftableToolsGridSection';
|
2026-11-05 13:10:05 +05:30
|
|
|
import { TrendyBentoSection } from '@/components/sections/TrendyBentoSection';
|
2026-11-07 12:44:57 +05:30
|
|
|
import { ToolGridSection } from '@/components/sections/ToolGridSection';
|
2026-11-05 13:03:19 +05:30
|
|
|
|
|
|
|
|
describe('Before/After Comparison Sliders (Mobile & Touch Responsiveness)', () => {
|
2026-11-05 13:10:05 +05:30
|
|
|
it('Cinematic3DComparison arrow handle has touch-none, role="slider", and touchAction: none', () => {
|
2026-11-05 13:03:19 +05:30
|
|
|
const html = renderToString(
|
|
|
|
|
<Cinematic3DComparison
|
|
|
|
|
beforeUrl="/before.jpg"
|
|
|
|
|
afterUrl="/after.jpg"
|
|
|
|
|
beforeLabel="Original"
|
|
|
|
|
afterLabel="Enhanced"
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(html).toContain('role="slider"');
|
2026-11-05 13:10:05 +05:30
|
|
|
expect(html).toContain('aria-label="Before and after comparison slider"');
|
2026-11-05 13:03:19 +05:30
|
|
|
expect(html).toContain('touch-none');
|
|
|
|
|
expect(html).toContain('touch-action:none');
|
2026-11-05 13:10:05 +05:30
|
|
|
expect(html).toContain('touch-action:pan-y');
|
2026-11-05 13:03:19 +05:30
|
|
|
});
|
|
|
|
|
|
2026-11-05 13:10:05 +05:30
|
|
|
it('CardBeforeAfterSlider arrow handle has touch-none, role="slider", and touchAction: none', () => {
|
2026-11-05 13:03:19 +05:30
|
|
|
const html = renderToString(
|
|
|
|
|
<CardBeforeAfterSlider
|
|
|
|
|
beforeUrl="/before.jpg"
|
|
|
|
|
afterUrl="/after.jpg"
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(html).toContain('role="slider"');
|
|
|
|
|
expect(html).toContain('aria-label="Before and after transformation slider"');
|
|
|
|
|
expect(html).toContain('touch-none');
|
|
|
|
|
expect(html).toContain('touch-action:none');
|
2026-11-05 13:10:05 +05:30
|
|
|
expect(html).toContain('touch-action:pan-y');
|
2026-11-05 13:03:19 +05:30
|
|
|
expect(html).toContain('--split:50%');
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-05 13:10:05 +05:30
|
|
|
it('ShiftableToolsGridSection renders comparison cards as clickable links with handle-only slider dragging', () => {
|
2026-11-05 13:03:19 +05:30
|
|
|
const html = renderToString(
|
|
|
|
|
<ShiftableToolsGridSection />
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(html).toContain('role="slider"');
|
|
|
|
|
expect(html).toContain('aria-label="Before and after comparison slider"');
|
|
|
|
|
expect(html).toContain('touch-none');
|
|
|
|
|
expect(html).toContain('touch-action:none');
|
2026-11-05 13:10:05 +05:30
|
|
|
expect(html).toContain('touch-action:pan-y');
|
|
|
|
|
expect(html).toContain('href="/tools/blemish-remover"');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('TrendyBentoSection renders each tile as a fully clickable card link', () => {
|
|
|
|
|
const html = renderToString(
|
|
|
|
|
<TrendyBentoSection />
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(html).toContain('href="/tools/background-remover"');
|
|
|
|
|
expect(html).toContain('href="/tools/old-photo-restorer"');
|
|
|
|
|
expect(html).toContain('href="/tools/cartoon-avatar"');
|
2026-11-05 13:03:19 +05:30
|
|
|
});
|
2026-11-07 12:44:57 +05:30
|
|
|
|
|
|
|
|
it('ToolGridSection comparison cards allow smooth mobile scrolling (touch-action: pan-y) and drag only on handle button (touch-action: none)', () => {
|
|
|
|
|
const html = renderToString(
|
|
|
|
|
<ToolGridSection
|
|
|
|
|
tools={[
|
|
|
|
|
{
|
|
|
|
|
id: 'blemish-remover',
|
|
|
|
|
slug: 'blemish-remover',
|
|
|
|
|
name: { en: 'Blemish Remover' },
|
|
|
|
|
summary: { en: 'Smooth blemishes' },
|
|
|
|
|
category: 'portrait-retouch',
|
|
|
|
|
content: {
|
|
|
|
|
examples: [
|
|
|
|
|
{
|
|
|
|
|
before: '/before.jpg',
|
|
|
|
|
after: '/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
} as any,
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(html).toContain('role="slider"');
|
|
|
|
|
expect(html).toContain('aria-label="Before and after transformation slider"');
|
|
|
|
|
expect(html).toContain('touch-none');
|
|
|
|
|
expect(html).toContain('touch-action:none');
|
|
|
|
|
expect(html).toContain('touch-action:pan-y');
|
|
|
|
|
expect(html).toContain('touch-pan-y');
|
|
|
|
|
});
|
2026-11-05 13:03:19 +05:30
|
|
|
});
|