Nest Branches and Team under Settings as Pro features.
Deploy Ladill Queue / deploy (push) Successful in 50s
Deploy Ladill Queue / deploy (push) Successful in 50s
Match Frontdesk: settings cards and nested routes, Pro-gated access, and legacy /admin redirects to /settings/branches and /settings/team.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\User;
|
||||
use App\Services\Qms\OrganizationResolver;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SettingsBranchesTeamTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected User $owner;
|
||||
|
||||
protected \App\Models\Organization $organization;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->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_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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user