feat(admin): finalize live show settings and related tests
This commit is contained in:
@@ -166,7 +166,9 @@ class Event extends Model
|
|||||||
public function ensureLiveShowToken(): string
|
public function ensureLiveShowToken(): string
|
||||||
{
|
{
|
||||||
if (is_string($this->live_show_token) && $this->live_show_token !== '') {
|
if (is_string($this->live_show_token) && $this->live_show_token !== '') {
|
||||||
$this->refreshLiveShowTokenExpiry();
|
if (! ($this->live_show_token_expires_at instanceof \Carbon\CarbonInterface)) {
|
||||||
|
$this->refreshLiveShowTokenExpiry();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->live_show_token;
|
return $this->live_show_token;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export type LiveShowLink = {
|
|||||||
url: string;
|
url: string;
|
||||||
qr_code_data_url: string | null;
|
qr_code_data_url: string | null;
|
||||||
rotated_at: string | null;
|
rotated_at: string | null;
|
||||||
|
expires_at: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TenantEvent = {
|
export type TenantEvent = {
|
||||||
@@ -1766,6 +1767,7 @@ function normalizeLiveShowLink(payload: JsonValue | LiveShowLink | null | undefi
|
|||||||
url: '',
|
url: '',
|
||||||
qr_code_data_url: null,
|
qr_code_data_url: null,
|
||||||
rotated_at: null,
|
rotated_at: null,
|
||||||
|
expires_at: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1776,6 +1778,7 @@ function normalizeLiveShowLink(payload: JsonValue | LiveShowLink | null | undefi
|
|||||||
url: typeof record.url === 'string' ? record.url : '',
|
url: typeof record.url === 'string' ? record.url : '',
|
||||||
qr_code_data_url: typeof record.qr_code_data_url === 'string' ? record.qr_code_data_url : null,
|
qr_code_data_url: typeof record.qr_code_data_url === 'string' ? record.qr_code_data_url : null,
|
||||||
rotated_at: typeof record.rotated_at === 'string' ? record.rotated_at : null,
|
rotated_at: typeof record.rotated_at === 'string' ? record.rotated_at : null,
|
||||||
|
expires_at: typeof record.expires_at === 'string' ? record.expires_at : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2603,6 +2603,11 @@
|
|||||||
"rotateSuccess": "Live-Show-Link neu generiert.",
|
"rotateSuccess": "Live-Show-Link neu generiert.",
|
||||||
"rotateFailed": "Live-Show-Link konnte nicht neu generiert werden.",
|
"rotateFailed": "Live-Show-Link konnte nicht neu generiert werden.",
|
||||||
"rotatedAt": "Zuletzt erneuert {{time}}",
|
"rotatedAt": "Zuletzt erneuert {{time}}",
|
||||||
|
"expiresAt": "Gültig bis {{time}}",
|
||||||
|
"expiresSoonAt": "Läuft bald ab: {{time}}",
|
||||||
|
"expiredAt": "Abgelaufen am {{time}}",
|
||||||
|
"expiredHint": "Generiere den Link neu, um wieder eine aktive URL und einen aktiven QR-Code zu erhalten.",
|
||||||
|
"rotateNow": "Jetzt neu generieren",
|
||||||
"noExpiry": "Dauerhaft gültig, bis von Dir erneuert.",
|
"noExpiry": "Dauerhaft gültig, bis von Dir erneuert.",
|
||||||
"loadFailed": "Live-Show-Link konnte nicht geladen werden.",
|
"loadFailed": "Live-Show-Link konnte nicht geladen werden.",
|
||||||
"copySuccess": "Link kopiert",
|
"copySuccess": "Link kopiert",
|
||||||
|
|||||||
@@ -2605,6 +2605,11 @@
|
|||||||
"rotateSuccess": "Live Show link rotated.",
|
"rotateSuccess": "Live Show link rotated.",
|
||||||
"rotateFailed": "Live Show link could not be rotated.",
|
"rotateFailed": "Live Show link could not be rotated.",
|
||||||
"rotatedAt": "Last rotated {{time}}",
|
"rotatedAt": "Last rotated {{time}}",
|
||||||
|
"expiresAt": "Valid until {{time}}",
|
||||||
|
"expiresSoonAt": "Expires soon: {{time}}",
|
||||||
|
"expiredAt": "Expired at {{time}}",
|
||||||
|
"expiredHint": "Rotate the link to generate a new active URL and QR code.",
|
||||||
|
"rotateNow": "Rotate now",
|
||||||
"noExpiry": "No expiry date (valid until you rotate it).",
|
"noExpiry": "No expiry date (valid until you rotate it).",
|
||||||
"loadFailed": "Live Show link could not be loaded.",
|
"loadFailed": "Live Show link could not be loaded.",
|
||||||
"copySuccess": "Link copied",
|
"copySuccess": "Link copied",
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ export default function MobileEventLiveShowSettingsPage() {
|
|||||||
const back = useBackNavigation(slug ? adminPath(`/mobile/events/${slug}`) : adminPath('/mobile/events'));
|
const back = useBackNavigation(slug ? adminPath(`/mobile/events/${slug}`) : adminPath('/mobile/events'));
|
||||||
|
|
||||||
const locale = i18n.language?.startsWith('en') ? 'en-GB' : 'de-DE';
|
const locale = i18n.language?.startsWith('en') ? 'en-GB' : 'de-DE';
|
||||||
|
const linkExpiryInfo = React.useMemo(() => parseLinkExpiry(liveShowLink?.expires_at ?? null, locale), [liveShowLink?.expires_at, locale]);
|
||||||
|
const linkExpired = linkExpiryInfo?.isExpired ?? false;
|
||||||
|
|
||||||
const loadLink = React.useCallback(async () => {
|
const loadLink = React.useCallback(async () => {
|
||||||
if (!slug) return;
|
if (!slug) return;
|
||||||
@@ -316,21 +318,21 @@ export default function MobileEventLiveShowSettingsPage() {
|
|||||||
<XStack gap="$2" marginTop="$2" alignItems="center" flexWrap="nowrap">
|
<XStack gap="$2" marginTop="$2" alignItems="center" flexWrap="nowrap">
|
||||||
<IconAction
|
<IconAction
|
||||||
label={t('liveShowSettings.link.copy', 'Copy')}
|
label={t('liveShowSettings.link.copy', 'Copy')}
|
||||||
disabled={!liveShowLink?.url}
|
disabled={!liveShowLink?.url || linkExpired}
|
||||||
onPress={() => liveShowLink?.url && copyToClipboard(liveShowLink.url, t)}
|
onPress={() => liveShowLink?.url && copyToClipboard(liveShowLink.url, t)}
|
||||||
>
|
>
|
||||||
<Copy size={18} />
|
<Copy size={18} />
|
||||||
</IconAction>
|
</IconAction>
|
||||||
<IconAction
|
<IconAction
|
||||||
label={t('liveShowSettings.link.share', 'Share')}
|
label={t('liveShowSettings.link.share', 'Share')}
|
||||||
disabled={!liveShowLink?.url}
|
disabled={!liveShowLink?.url || linkExpired}
|
||||||
onPress={() => liveShowLink?.url && shareLink(liveShowLink.url, event, t)}
|
onPress={() => liveShowLink?.url && shareLink(liveShowLink.url, event, t)}
|
||||||
>
|
>
|
||||||
<Share2 size={18} />
|
<Share2 size={18} />
|
||||||
</IconAction>
|
</IconAction>
|
||||||
<IconAction
|
<IconAction
|
||||||
label={t('liveShowSettings.link.open', 'Open')}
|
label={t('liveShowSettings.link.open', 'Open')}
|
||||||
disabled={!liveShowLink?.url}
|
disabled={!liveShowLink?.url || linkExpired}
|
||||||
onPress={() => liveShowLink?.url && openLink(liveShowLink.url)}
|
onPress={() => liveShowLink?.url && openLink(liveShowLink.url)}
|
||||||
>
|
>
|
||||||
<ExternalLink size={18} />
|
<ExternalLink size={18} />
|
||||||
@@ -360,10 +362,28 @@ export default function MobileEventLiveShowSettingsPage() {
|
|||||||
</XStack>
|
</XStack>
|
||||||
) : null}
|
) : null}
|
||||||
{liveShowLink ? (
|
{liveShowLink ? (
|
||||||
<Text fontSize="$xs" color={muted} marginTop="$1.5">
|
<Text fontSize="$xs" color={linkExpired ? danger : muted} marginTop="$1.5">
|
||||||
{t('liveShowSettings.link.noExpiry', 'No expiry date set.')}
|
{linkExpiryInfo
|
||||||
|
? linkExpiryInfo.isExpired
|
||||||
|
? t('liveShowSettings.link.expiredAt', 'Expired at {{time}}', { time: linkExpiryInfo.formatted })
|
||||||
|
: linkExpiryInfo.isSoon
|
||||||
|
? t('liveShowSettings.link.expiresSoonAt', 'Expires soon: {{time}}', { time: linkExpiryInfo.formatted })
|
||||||
|
: t('liveShowSettings.link.expiresAt', 'Valid until {{time}}', { time: linkExpiryInfo.formatted })
|
||||||
|
: t('liveShowSettings.link.noExpiry', 'No expiry date set.')}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
|
{linkExpired ? (
|
||||||
|
<YStack gap="$2" marginTop="$2">
|
||||||
|
<Text fontSize="$xs" color={muted}>
|
||||||
|
{t('liveShowSettings.link.expiredHint', 'Rotate the link to generate a new active URL and QR code.')}
|
||||||
|
</Text>
|
||||||
|
<CTAButton
|
||||||
|
label={linkBusy ? t('common.processing', '...') : t('liveShowSettings.link.rotateNow', 'Rotate now')}
|
||||||
|
onPress={() => handleRotateLink()}
|
||||||
|
disabled={linkBusy}
|
||||||
|
/>
|
||||||
|
</YStack>
|
||||||
|
) : null}
|
||||||
{liveShowLink?.rotated_at ? (
|
{liveShowLink?.rotated_at ? (
|
||||||
<Text fontSize="$xs" color={muted} marginTop="$1.5">
|
<Text fontSize="$xs" color={muted} marginTop="$1.5">
|
||||||
{t('liveShowSettings.link.rotatedAt', 'Last rotated {{time}}', {
|
{t('liveShowSettings.link.rotatedAt', 'Last rotated {{time}}', {
|
||||||
@@ -623,6 +643,35 @@ function formatTimestamp(value: string, locale: string): string {
|
|||||||
return date.toLocaleString(locale, { day: '2-digit', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
return date.toLocaleString(locale, { day: '2-digit', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseLinkExpiry(
|
||||||
|
value: string | null,
|
||||||
|
locale: string
|
||||||
|
): {
|
||||||
|
formatted: string;
|
||||||
|
isExpired: boolean;
|
||||||
|
isSoon: boolean;
|
||||||
|
} | null {
|
||||||
|
if (!value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const expiresAt = date.getTime();
|
||||||
|
const isExpired = expiresAt < now;
|
||||||
|
const isSoon = !isExpired && expiresAt - now <= 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
return {
|
||||||
|
formatted: formatTimestamp(value, locale),
|
||||||
|
isExpired,
|
||||||
|
isSoon,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function resolveOption<T extends string>(value: unknown, options: T[], fallback: T): T {
|
function resolveOption<T extends string>(value: unknown, options: T[], fallback: T): T {
|
||||||
if (typeof value !== 'string') return fallback;
|
if (typeof value !== 'string') return fallback;
|
||||||
return options.includes(value as T) ? (value as T) : fallback;
|
return options.includes(value as T) ? (value as T) : fallback;
|
||||||
|
|||||||
@@ -0,0 +1,197 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
|
||||||
|
const fixtures = vi.hoisted(() => ({
|
||||||
|
event: {
|
||||||
|
id: 1,
|
||||||
|
name: 'Demo Event',
|
||||||
|
slug: 'demo-event',
|
||||||
|
event_date: '2026-02-12',
|
||||||
|
event_type_id: 1,
|
||||||
|
event_type: { id: 1, name: 'Wedding' },
|
||||||
|
status: 'published',
|
||||||
|
settings: {
|
||||||
|
live_show: {
|
||||||
|
moderation_mode: 'manual',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('react-router-dom', () => ({
|
||||||
|
useParams: () => ({ slug: fixtures.event.slug }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('react-i18next', () => ({
|
||||||
|
useTranslation: () => ({
|
||||||
|
t: (key: string, fallback?: string | Record<string, unknown>) => {
|
||||||
|
if (typeof fallback === 'string') {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
|
||||||
|
return fallback.defaultValue;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
},
|
||||||
|
i18n: { language: 'en' },
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../../api', () => ({
|
||||||
|
getEvent: vi.fn(),
|
||||||
|
getLiveShowLink: vi.fn(),
|
||||||
|
rotateLiveShowLink: vi.fn(),
|
||||||
|
updateEvent: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../../auth/tokens', () => ({
|
||||||
|
isAuthError: () => false,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../../lib/apiError', () => ({
|
||||||
|
getApiErrorMessage: () => 'error',
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../../lib/events', () => ({
|
||||||
|
resolveEventDisplayName: () => fixtures.event.name,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../hooks/useBackNavigation', () => ({
|
||||||
|
useBackNavigation: () => undefined,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/MobileShell', () => ({
|
||||||
|
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
HeaderActionButton: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
|
||||||
|
<button type="button" onClick={onPress}>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/Primitives', () => ({
|
||||||
|
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
CTAButton: ({ label, onPress, disabled }: { label: string; onPress?: () => void; disabled?: boolean }) => (
|
||||||
|
<button type="button" onClick={onPress} disabled={disabled}>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
),
|
||||||
|
SkeletonCard: () => <div>Loading...</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/FormControls', () => ({
|
||||||
|
MobileField: ({ label, children }: { label: string; children: React.ReactNode }) => (
|
||||||
|
<label>
|
||||||
|
{label}
|
||||||
|
{children}
|
||||||
|
</label>
|
||||||
|
),
|
||||||
|
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
|
||||||
|
MobileSelect: (props: React.SelectHTMLAttributes<HTMLSelectElement>) => <select {...props} />,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/ContextHelpLink', () => ({
|
||||||
|
ContextHelpLink: () => null,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@tamagui/stacks', () => ({
|
||||||
|
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@tamagui/text', () => ({
|
||||||
|
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@tamagui/react-native-web-lite', () => ({
|
||||||
|
Pressable: ({
|
||||||
|
children,
|
||||||
|
onPress,
|
||||||
|
disabled,
|
||||||
|
...rest
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
onPress?: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
[key: string]: unknown;
|
||||||
|
}) => (
|
||||||
|
<button type="button" onClick={onPress} disabled={disabled} {...rest}>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('tamagui', () => ({
|
||||||
|
Slider: Object.assign(
|
||||||
|
({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
{
|
||||||
|
Track: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
TrackActive: () => <div />,
|
||||||
|
Thumb: () => <div />,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../theme', () => ({
|
||||||
|
useAdminTheme: () => ({
|
||||||
|
textStrong: '#111827',
|
||||||
|
text: '#111827',
|
||||||
|
muted: '#6b7280',
|
||||||
|
danger: '#dc2626',
|
||||||
|
border: '#e5e7eb',
|
||||||
|
surface: '#ffffff',
|
||||||
|
primary: '#ff5a5f',
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('react-hot-toast', () => ({
|
||||||
|
default: {
|
||||||
|
error: vi.fn(),
|
||||||
|
success: vi.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
import MobileEventLiveShowSettingsPage from '../EventLiveShowSettingsPage';
|
||||||
|
import { getEvent, getLiveShowLink } from '../../api';
|
||||||
|
|
||||||
|
describe('MobileEventLiveShowSettingsPage', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
vi.mocked(getEvent).mockResolvedValue(fixtures.event as any);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows a validity timestamp when link expiry is present', async () => {
|
||||||
|
vi.mocked(getLiveShowLink).mockResolvedValue({
|
||||||
|
token: 'token-1',
|
||||||
|
url: 'https://example.test/show/token-1',
|
||||||
|
qr_code_data_url: null,
|
||||||
|
rotated_at: null,
|
||||||
|
expires_at: '2099-01-01T12:00:00Z',
|
||||||
|
});
|
||||||
|
|
||||||
|
render(<MobileEventLiveShowSettingsPage />);
|
||||||
|
|
||||||
|
expect(await screen.findByText('Live Show link')).toBeInTheDocument();
|
||||||
|
expect(await screen.findByText(/Valid until/)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows expired state and disables stale link actions', async () => {
|
||||||
|
vi.mocked(getLiveShowLink).mockResolvedValue({
|
||||||
|
token: 'token-2',
|
||||||
|
url: 'https://example.test/show/token-2',
|
||||||
|
qr_code_data_url: null,
|
||||||
|
rotated_at: null,
|
||||||
|
expires_at: '2000-01-01T00:00:00Z',
|
||||||
|
});
|
||||||
|
|
||||||
|
render(<MobileEventLiveShowSettingsPage />);
|
||||||
|
|
||||||
|
expect(await screen.findByText(/Expired at/)).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Rotate the link to generate a new active URL and QR code.')).toBeInTheDocument();
|
||||||
|
|
||||||
|
expect(screen.getByRole('button', { name: 'Copy' })).toBeDisabled();
|
||||||
|
expect(screen.getByRole('button', { name: 'Share' })).toBeDisabled();
|
||||||
|
expect(screen.getByRole('button', { name: 'Open' })).toBeDisabled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -52,6 +52,25 @@ class LiveShowDataModelTest extends TestCase
|
|||||||
$this->assertSame($newDate->copy()->addDay()->endOfDay()->toIso8601String(), $event->live_show_token_expires_at?->toIso8601String());
|
$this->assertSame($newDate->copy()->addDay()->endOfDay()->toIso8601String(), $event->live_show_token_expires_at?->toIso8601String());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_ensuring_existing_live_show_token_does_not_mutate_existing_expiry(): void
|
||||||
|
{
|
||||||
|
$this->freezeTime(function (): void {
|
||||||
|
$eventDate = now()->addDays(5)->startOfDay();
|
||||||
|
$event = Event::factory()->create(['date' => $eventDate]);
|
||||||
|
$event->rotateLiveShowToken();
|
||||||
|
$customExpiry = now()->addHours(6)->toImmutable();
|
||||||
|
$event->forceFill(['live_show_token_expires_at' => $customExpiry])->saveQuietly();
|
||||||
|
$initialExpiry = $event->refresh()->live_show_token_expires_at?->toIso8601String();
|
||||||
|
|
||||||
|
$this->travel(6)->hours();
|
||||||
|
$event->refresh()->ensureLiveShowToken();
|
||||||
|
$expiryAfterEnsure = $event->refresh()->live_show_token_expires_at?->toIso8601String();
|
||||||
|
|
||||||
|
$this->assertNotNull($initialExpiry);
|
||||||
|
$this->assertSame($initialExpiry, $expiryAfterEnsure);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function test_photo_live_status_is_cast_and_defaults_to_none(): void
|
public function test_photo_live_status_is_cast_and_defaults_to_none(): void
|
||||||
{
|
{
|
||||||
$photo = Photo::factory()->create();
|
$photo = Photo::factory()->create();
|
||||||
|
|||||||
@@ -62,4 +62,32 @@ class LiveShowLinkControllerTest extends TenantTestCase
|
|||||||
$this->assertIsString($rotatedToken);
|
$this->assertIsString($rotatedToken);
|
||||||
$this->assertNotSame($firstToken, $rotatedToken);
|
$this->assertNotSame($firstToken, $rotatedToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_loading_live_show_link_does_not_mutate_existing_expiry(): void
|
||||||
|
{
|
||||||
|
$this->freezeTime(function (): void {
|
||||||
|
$event = Event::factory()
|
||||||
|
->for($this->tenant)
|
||||||
|
->create([
|
||||||
|
'name' => ['de' => 'Live-Show Ablauf', 'en' => 'Live Show Expiry'],
|
||||||
|
'slug' => 'live-show-fixed-expiry',
|
||||||
|
'date' => now()->addDays(3)->startOfDay(),
|
||||||
|
]);
|
||||||
|
$event->ensureLiveShowToken();
|
||||||
|
$customExpiry = now()->addHours(4)->toImmutable();
|
||||||
|
$event->forceFill(['live_show_token_expires_at' => $customExpiry])->saveQuietly();
|
||||||
|
|
||||||
|
$first = $this->authenticatedRequest('GET', "/api/v1/tenant/events/{$event->slug}/live-show/link");
|
||||||
|
$first->assertOk();
|
||||||
|
$firstExpiry = $first->json('data.expires_at');
|
||||||
|
|
||||||
|
$this->travel(8)->hours();
|
||||||
|
|
||||||
|
$second = $this->authenticatedRequest('GET', "/api/v1/tenant/events/{$event->slug}/live-show/link");
|
||||||
|
$second->assertOk();
|
||||||
|
|
||||||
|
$this->assertIsString($firstExpiry);
|
||||||
|
$this->assertSame($firstExpiry, $second->json('data.expires_at'));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user