I finished the remaining polish so the admin app now feels fully “app‑like” across the core screens.
This commit is contained in:
52
resources/js/admin/mobile/lib/photoModerationSwipe.test.ts
Normal file
52
resources/js/admin/mobile/lib/photoModerationSwipe.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { TenantPhoto } from '../../api';
|
||||
import { resolvePhotoSwipeAction } from './photoModerationSwipe';
|
||||
|
||||
const basePhoto = (overrides: Partial<TenantPhoto>): TenantPhoto => ({
|
||||
id: overrides.id ?? 1,
|
||||
filename: overrides.filename ?? null,
|
||||
original_name: overrides.original_name ?? null,
|
||||
mime_type: overrides.mime_type ?? null,
|
||||
size: overrides.size ?? 1024,
|
||||
url: overrides.url ?? null,
|
||||
thumbnail_url: overrides.thumbnail_url ?? null,
|
||||
status: overrides.status ?? 'approved',
|
||||
is_featured: overrides.is_featured ?? false,
|
||||
likes_count: overrides.likes_count ?? 0,
|
||||
uploaded_at: overrides.uploaded_at ?? new Date().toISOString(),
|
||||
uploader_name: overrides.uploader_name ?? null,
|
||||
ingest_source: overrides.ingest_source ?? null,
|
||||
caption: overrides.caption ?? null,
|
||||
});
|
||||
|
||||
describe('resolvePhotoSwipeAction', () => {
|
||||
it('approves pending photos on right swipe', () => {
|
||||
const photo = basePhoto({ status: 'pending' });
|
||||
expect(resolvePhotoSwipeAction(photo, 'right')).toBe('approve');
|
||||
});
|
||||
|
||||
it('hides pending photos on left swipe', () => {
|
||||
const photo = basePhoto({ status: 'pending' });
|
||||
expect(resolvePhotoSwipeAction(photo, 'left')).toBe('hide');
|
||||
});
|
||||
|
||||
it('shows hidden photos on right swipe', () => {
|
||||
const photo = basePhoto({ status: 'hidden' });
|
||||
expect(resolvePhotoSwipeAction(photo, 'right')).toBe('show');
|
||||
});
|
||||
|
||||
it('returns null for hidden photos on left swipe', () => {
|
||||
const photo = basePhoto({ status: 'hidden' });
|
||||
expect(resolvePhotoSwipeAction(photo, 'left')).toBeNull();
|
||||
});
|
||||
|
||||
it('hides visible photos on left swipe', () => {
|
||||
const photo = basePhoto({ status: 'approved' });
|
||||
expect(resolvePhotoSwipeAction(photo, 'left')).toBe('hide');
|
||||
});
|
||||
|
||||
it('returns null for visible photos on right swipe', () => {
|
||||
const photo = basePhoto({ status: 'approved' });
|
||||
expect(resolvePhotoSwipeAction(photo, 'right')).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user