Files
WMS/tests/Feature/Modules/NavigatorHeaderCoverageTest.php
T
2026-06-23 15:51:01 +01:00

118 lines
5.0 KiB
PHP

<?php
namespace Tests\Feature\Modules;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Route;
use Modules\Platform\app\Models\PlatformPrice;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
class NavigatorHeaderCoverageTest extends TestCase
{
use RefreshDatabase;
/**
* Ensure every navigator page renders the professional single page hero baseline.
*/
#[DataProvider('navigatorPages')]
public function test_every_navigator_page_has_single_professional_header(string $routeName, string $title, string $description): void
{
$this->assertTrue(Route::has($routeName), "Missing navigator route [{$routeName}].");
$user = User::factory()->mpbaPlatformAdmin()->create();
$content = $this->actingAs($user)
->get(route($routeName))
->assertOk()
->assertSee('wms-page-hero', false)
->getContent();
if ($title !== '') {
$this->assertStringContainsString($title, $content);
}
if ($description !== '') {
$this->assertStringContainsString($description, $content);
}
$this->assertSame(
1,
preg_match_all('/<section\b[^>]*class="[^"]*\bwms-page-hero\b/', $content),
"Navigator route [{$routeName}] must render exactly one professional header section.",
);
}
/**
* Ensure the platform dashboard keeps pricing cards visible on Platform.
*/
public function test_platform_dashboard_does_not_show_pricing_display_cards(): void
{
$user = User::factory()->mpbaPlatformAdmin()->create();
PlatformPrice::query()->updateOrCreate(
['code' => 'basic'],
[
'name' => 'Basic',
'strapline' => 'Starter WMS platform access.',
'description' => 'Core warehouse management tools.',
'monthly_amount' => 4900,
'annual_amount' => 49000,
'currency' => 'gbp',
'features' => ['2 warehouses', '10 users', 'Standard support'],
'sort_order' => 10,
'is_active' => true,
'is_featured' => false,
],
);
$this->actingAs($user)
->get(route('platform.dashboard'))
->assertOk()
->assertDontSee('Pricing plans', false)
->assertSee(route('platform.pricing.index'), false)
->assertSee(route('platform.prices.index'), false);
}
/**
* Ensure the public Platform pricing route is separate from Administration price CRUD.
*/
public function test_pricing_routes_are_in_correct_platform_and_administration_menus(): void
{
$this->assertSame('/platform/pricing', parse_url(route('platform.pricing.index'), PHP_URL_PATH));
$this->assertSame('/admin/prices', parse_url(route('platform.prices.index'), PHP_URL_PATH));
$this->assertSame('/admin/prices/create', parse_url(route('platform.prices.create'), PHP_URL_PATH));
}
/**
* @return array<int, array{0: string, 1: string, 2: string}>
*/
public static function navigatorPages(): array
{
return [
['platform.dashboard', 'Platform Dashboard', 'System-level tenant'],
['platform.pricing.index', 'Pricing', 'Clear platform pricing'],
['platform.companies.index', 'Companies', 'Manage tenant companies'],
['platform.licenses.index', 'Licence Keys', 'Issue and monitor company licence keys'],
['platform.payments.index', 'Payments and Overrides', 'Record platform payments'],
['platform.prices.index', 'Pricing Administration', 'Create, edit and publish'],
['dashboard', '', ''],
['warehouses.index', 'Warehouses', 'Create and manage warehouse records'],
['warehouse-rules.index', 'Validation Rules', 'Configure warehouse validation'],
['analytics.index', 'Analytics', 'Display KPIs'],
['inventory-management.index', 'Inventory Management', 'Track inventory movement'],
['replenishment.index', 'Replenishment', 'Configure replenishment thresholds'],
['shipping.index', 'Shipping', 'Monitor shipment activity'],
['transportation.index', 'Transportation', 'Manage truck closure'],
['carrier-management.index', 'Carrier Management', 'Maintain carriers'],
['m3-integration.index', 'M3 Integration', 'Observe M3 transactions'],
['sentinel-integration.index', 'Sentinel Integration', 'Track Sentinel API activity'],
['document-archive.index', 'Document Archive', 'Search cached Sentinel documents'],
['reporting.index', 'Reporting', 'Provide operational reports'],
['configuration.index', 'Configuration', 'Centralise system settings'],
['security.index', 'Security', 'Control roles'],
['audit.index', 'Audit', 'Review activity logs'],
];
}
}