33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
it('injects the unhandled rejection logger into Filament pages', function (): void {
|
|
$this->get('/admin/login')
|
|
->assertSuccessful()
|
|
->assertSee('js/tenantpilot/unhandled-rejection-logger.js', escape: false);
|
|
});
|
|
|
|
it('ships a window unhandledrejection logger with structured payload output', function (): void {
|
|
$js = file_get_contents(public_path('js/tenantpilot/unhandled-rejection-logger.js'));
|
|
|
|
expect($js)->toBeString();
|
|
expect($js)
|
|
->toContain('__tenantpilotUnhandledRejectionLoggerApplied')
|
|
->toContain("window.addEventListener('unhandledrejection'")
|
|
->toContain('isExpectedBackgroundTransportFailure')
|
|
->toContain("document.visibilityState !== 'visible'")
|
|
->toContain('document.hasFocus')
|
|
->toContain('event.preventDefault()')
|
|
->toContain('status === 419')
|
|
->toContain('Page Expired')
|
|
->toContain('status === 404')
|
|
->toContain('Not Found')
|
|
->toContain('const dedupeKey = toStableJson({')
|
|
->toContain('reason: payload.reason')
|
|
->toContain('TenantPilot unhandled promise rejection')
|
|
->toContain('JSON.stringify')
|
|
->not->toContain('recentKeys.has(payloadJson)')
|
|
->not->toContain('recentKeys.set(payloadJson, nowMs)');
|
|
});
|