create(['role' => 'super_admin']); $event = Event::factory()->create([ 'date' => now()->addDays(10), ]); $token = $event->joinTokens()->latest('id')->first(); $minimumExpiry = app(EventJoinTokenService::class)->minimumExpiryForEvent($event); $newExpiry = ($minimumExpiry ?? now()->addDay())->copy()->addDays(2)->seconds(0); $this->bootSuperAdminPanel($user); Livewire::test(ListEvents::class) ->callAction( [ TestAction::make('join_tokens')->table($event), TestAction::make('extend_join_token_expiry') ->arguments(['token_id' => $token->id]), ], [ 'expires_at' => $newExpiry->toDateTimeString(), ] ) ->assertHasNoErrors(); $token->refresh(); $this->assertSame( $newExpiry->toDateTimeString(), $token->expires_at?->toDateTimeString() ); } public function test_superadmin_can_toggle_demo_read_only_on_join_token(): void { $user = User::factory()->create(['role' => 'super_admin']); $event = Event::factory()->create([ 'date' => now()->addDays(10), ]); $token = $event->joinTokens()->latest('id')->first(); $this->bootSuperAdminPanel($user); Livewire::test(ListEvents::class) ->callAction( [ TestAction::make('join_tokens')->table($event), TestAction::make('set_demo_read_only') ->arguments(['token_id' => $token->id]), ], [ 'demo_read_only' => true, ] ) ->assertHasNoErrors(); $token->refresh(); $this->assertTrue((bool) data_get($token->metadata, 'demo_read_only', false)); Livewire::test(ListEvents::class) ->callAction( [ TestAction::make('join_tokens')->table($event), TestAction::make('set_demo_read_only') ->arguments(['token_id' => $token->id]), ], [ 'demo_read_only' => false, ] ) ->assertHasNoErrors(); $token->refresh(); $this->assertFalse((bool) data_get($token->metadata, 'demo_read_only', false)); } private function bootSuperAdminPanel(User $user): void { $panel = Filament::getPanel('superadmin'); $this->assertNotNull($panel); Filament::setCurrentPanel($panel); Filament::bootCurrentPanel(); Filament::auth()->login($user); } }