withoutMiddleware(EnsurePlatformSession::class); $this->owner = User::create([ 'public_id' => 'queue-settings-owner-001', 'name' => 'Owner', 'email' => 'settings-owner@example.com', 'password' => bcrypt('password'), ]); $this->organization = app(OrganizationResolver::class)->completeOnboarding($this->owner, [ 'organization_name' => 'Settings Org', 'industry' => 'retail', 'appointment_mode' => 'hybrid', 'branch_name' => 'Main', 'timezone' => 'UTC', ]); } public function test_settings_page_links_to_branches_and_team_with_pro_badges(): void { $this->actingAs($this->owner) ->get(route('qms.settings.edit')) ->assertOk() ->assertSee('Branches & team') ->assertSee('Branches') ->assertSee('Team') ->assertSee('Pro') ->assertSee(route('qms.branches.index', absolute: false)) ->assertSee(route('qms.members.index', absolute: false)); } public function test_org_admin_can_save_settings(): void { $this->actingAs($this->owner) ->put(route('qms.settings.update'), [ 'name' => 'Settings Org Updated', 'timezone' => 'Africa/Accra', 'appointment_mode' => 'walk_in_only', 'industry' => 'retail', 'notifications_enabled' => '1', 'frontdesk_integration_enabled' => '1', ]) ->assertRedirect() ->assertSessionHas('success'); $this->organization->refresh(); $this->assertSame('Settings Org Updated', $this->organization->name); $this->assertSame('Africa/Accra', $this->organization->timezone); $this->assertSame('walk_in_only', data_get($this->organization->settings, 'appointment_mode')); $this->assertTrue((bool) data_get($this->organization->settings, 'integrations.frontdesk_enabled')); } public function test_settings_page_does_not_nest_reinstall_form(): void { $html = $this->actingAs($this->owner) ->get(route('qms.settings.edit')) ->assertOk() ->getContent(); $this->assertSame(1, substr_count($html, 'action="'.route('qms.settings.update').'"')); $this->assertSame(1, substr_count($html, 'action="'.route('qms.settings.package.reinstall').'"')); // Reinstall form must appear after the settings form closes. $updatePos = strpos($html, 'action="'.route('qms.settings.update').'"'); $closePos = strpos($html, '', $updatePos); $reinstallPos = strpos($html, 'action="'.route('qms.settings.package.reinstall').'"'); $this->assertNotFalse($closePos); $this->assertNotFalse($reinstallPos); $this->assertGreaterThan($closePos, $reinstallPos); } public function test_free_plan_branches_shows_upgrade_screen(): void { $this->actingAs($this->owner) ->get(route('qms.branches.index')) ->assertOk() ->assertSee('Upgrade your plan') ->assertSee('View plans') ->assertSee(route('qms.pro.index', absolute: false)); } public function test_free_plan_team_shows_upgrade_screen(): void { $this->actingAs($this->owner) ->get(route('qms.members.index')) ->assertOk() ->assertSee('Upgrade your plan') ->assertSee('Team'); } public function test_free_plan_cannot_store_member(): void { $this->actingAs($this->owner) ->post(route('qms.members.store'), [ 'email' => 'colleague@example.com', 'role' => 'queue_operator', ]) ->assertRedirect(route('qms.pro.index')) ->assertSessionHas('error'); } public function test_pro_plan_can_view_branches(): void { $this->organization->update([ 'settings' => array_merge($this->organization->settings ?? [], [ 'plan' => 'pro', 'plan_expires_at' => now()->addMonth()->toIso8601String(), 'pro_billed_branches' => 1, ]), ]); $this->actingAs($this->owner) ->get(route('qms.branches.index')) ->assertOk() ->assertSee('All branches') ->assertSee('Main') ->assertSee('Settings'); } public function test_legacy_admin_routes_redirect_to_settings(): void { $this->actingAs($this->owner) ->get('/admin/branches') ->assertRedirect('/settings/branches'); $this->actingAs($this->owner) ->get('/admin/members') ->assertRedirect('/settings/team'); } }