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.
This commit is contained in:
Codex Agent
2025-12-28 15:00:47 +01:00
parent 4ce409e918
commit b780d82d62
42 changed files with 2258 additions and 121 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Tests\Feature;
use Tests\TestCase;
class AdminPwaAssetsTest extends TestCase
{
public function test_admin_shell_includes_admin_apple_touch_icon(): void
{
$response = $this->get('/event-admin');
$response->assertOk();
$response->assertSee('/admin-apple-touch-icon.png', false);
}
public function test_admin_manifest_exposes_required_icons(): void
{
$manifestPath = public_path('manifest.json');
$manifest = json_decode(file_get_contents($manifestPath), true, 512, JSON_THROW_ON_ERROR);
$icons = collect($manifest['icons'] ?? [])->pluck('src')->all();
$this->assertContains('/admin-icon-192.png', $icons);
$this->assertContains('/admin-icon-512.png', $icons);
$this->assertContains('/admin-icon-192-maskable.png', $icons);
$this->assertContains('/admin-icon-512-maskable.png', $icons);
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace Tests\Feature\Tenant;
use App\Models\TenantAdminPushSubscription;
use Illuminate\Support\Str;
class AdminPushSubscriptionTest extends TenantTestCase
{
public function test_admin_push_subscription_can_be_registered(): void
{
$payload = [
'endpoint' => 'https://example.com/push/'.Str::random(8),
'keys' => [
'p256dh' => base64_encode(random_bytes(32)),
'auth' => base64_encode(random_bytes(16)),
],
'expiration_time' => null,
'content_encoding' => 'aes128gcm',
'device_id' => 'admin-device-123',
];
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/notifications/push-subscriptions', $payload);
$response->assertCreated();
$this->assertDatabaseHas('tenant_admin_push_subscriptions', [
'tenant_id' => $this->tenant->id,
'user_id' => $this->tenantUser->id,
'endpoint' => $payload['endpoint'],
'device_id' => $payload['device_id'],
'status' => 'active',
]);
}
public function test_admin_push_subscription_can_be_revoked(): void
{
$subscription = TenantAdminPushSubscription::factory()->create([
'tenant_id' => $this->tenant->id,
'user_id' => $this->tenantUser->id,
'status' => 'active',
]);
$response = $this->authenticatedRequest('DELETE', '/api/v1/tenant/notifications/push-subscriptions', [
'endpoint' => $subscription->endpoint,
]);
$response->assertOk();
$this->assertDatabaseHas('tenant_admin_push_subscriptions', [
'id' => $subscription->id,
'status' => 'revoked',
]);
}
}