Update guest v2 branding and theming
This commit is contained in:
33
resources/js/guest/services/__tests__/photosApi.test.ts
Normal file
33
resources/js/guest/services/__tests__/photosApi.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createPhotoShareLink } from '../photosApi';
|
||||
|
||||
const fetchMock = vi.fn();
|
||||
|
||||
describe('photosApi', () => {
|
||||
beforeEach(() => {
|
||||
fetchMock.mockReset();
|
||||
global.fetch = fetchMock as unknown as typeof fetch;
|
||||
document.head.innerHTML = '<meta name="csrf-token" content="csrf-token-demo" />';
|
||||
localStorage.setItem('device-id', 'device-123');
|
||||
});
|
||||
|
||||
it('creates a share link with CSRF headers', async () => {
|
||||
fetchMock.mockResolvedValueOnce(
|
||||
new Response(JSON.stringify({ slug: 'demo', url: 'http://example.com/share/demo' }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
);
|
||||
|
||||
const payload = await createPhotoShareLink('token', 123);
|
||||
|
||||
expect(payload.url).toBe('http://example.com/share/demo');
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
const [, options] = fetchMock.mock.calls[0];
|
||||
const headers = options?.headers as Record<string, string>;
|
||||
expect(headers['X-CSRF-TOKEN']).toBe('csrf-token-demo');
|
||||
expect(headers['X-XSRF-TOKEN']).toBe('csrf-token-demo');
|
||||
expect(headers['X-Device-Id']).toBe('device-123');
|
||||
});
|
||||
});
|
||||
@@ -1,18 +1,7 @@
|
||||
import type { LocaleCode } from '../i18n/messages';
|
||||
import type { EventBrandingPayload } from './eventApi';
|
||||
|
||||
export interface GalleryBranding {
|
||||
primary_color: string;
|
||||
secondary_color: string;
|
||||
background_color: string;
|
||||
surface_color?: string;
|
||||
mode?: 'light' | 'dark' | 'auto';
|
||||
palette?: {
|
||||
primary?: string | null;
|
||||
secondary?: string | null;
|
||||
background?: string | null;
|
||||
surface?: string | null;
|
||||
} | null;
|
||||
}
|
||||
export type GalleryBranding = EventBrandingPayload;
|
||||
|
||||
export interface GalleryMetaResponse {
|
||||
event: {
|
||||
|
||||
@@ -174,7 +174,7 @@ export async function uploadPhoto(
|
||||
}
|
||||
|
||||
export async function createPhotoShareLink(eventToken: string, photoId: number): Promise<{ slug: string; url: string; expires_at?: string }> {
|
||||
const headers = getCsrfHeaders();
|
||||
const headers = buildCsrfHeaders();
|
||||
|
||||
const res = await fetch(`/api/v1/events/${encodeURIComponent(eventToken)}/photos/${photoId}/share`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user