Files
fotospiel-app/resources/js/admin/mobile/lib/photoModerationQueue.test.ts
Codex Agent b780d82d62 Added Phase‑1 continuation work across deep links, offline moderation queue, and admin push.
resources/js/admin/mobile/lib.
  - Admin push is end‑to‑end: new backend model/migration/service/job + API endpoints, admin runtime config, push‑aware
    service worker, and a settings toggle via useAdminPushSubscription. Notifications now auto‑refresh on push.
  - New PHP/JS tests: admin push API feature test and queue/haptics unit tests
  Added admin-specific PWA icon assets and wired them into the admin manifest, service worker, and admin shell, plus a
  new “Device & permissions” card in mobile Settings with a persistent storage action and translations.
  Details: public/manifest.json, public/admin-sw.js, resources/views/admin.blade.php, new icons in public/; new hook
  resources/js/admin/mobile/hooks/useDevicePermissions.ts, helpers/tests in resources/js/admin/mobile/lib/
  devicePermissions.ts + resources/js/admin/mobile/lib/devicePermissions.test.ts, and Settings UI updates in resources/
  js/admin/mobile/SettingsPage.tsx with copy in resources/js/admin/i18n/locales/en/management.json and resources/js/
admin/i18n/locales/de/management.json.
2025-12-28 15:00:47 +01:00

50 lines
1.4 KiB
TypeScript

import { beforeEach, describe, expect, it } from 'vitest';
import {
enqueuePhotoAction,
loadPhotoQueue,
removePhotoAction,
replacePhotoQueue,
type PhotoModerationAction,
} from './photoModerationQueue';
describe('photoModerationQueue', () => {
beforeEach(() => {
window.localStorage.clear();
});
it('enqueues and loads actions', () => {
const queue = enqueuePhotoAction({ eventSlug: 'demo-event', photoId: 12, action: 'approve' });
expect(queue).toHaveLength(1);
const loaded = loadPhotoQueue();
expect(loaded).toHaveLength(1);
expect(loaded[0]?.eventSlug).toBe('demo-event');
expect(loaded[0]?.photoId).toBe(12);
});
it('removes actions by id', () => {
const queue = enqueuePhotoAction({ eventSlug: 'demo-event', photoId: 12, action: 'approve' });
const next = removePhotoAction(queue, queue[0]!.id);
expect(next).toHaveLength(0);
expect(loadPhotoQueue()).toHaveLength(0);
});
it('replaces the queue', () => {
enqueuePhotoAction({ eventSlug: 'demo-event', photoId: 12, action: 'approve' });
const next: PhotoModerationAction[] = [
{
id: 'fixed',
eventSlug: 'another',
photoId: 99,
action: 'hide',
createdAt: new Date().toISOString(),
},
];
replacePhotoQueue(next);
expect(loadPhotoQueue()).toHaveLength(1);
expect(loadPhotoQueue()[0]?.id).toBe('fixed');
});
});