78 lines
2.8 KiB
PHP
78 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Modules;
|
|
|
|
use Database\Factories\UserFactory;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Tests\TestCase;
|
|
|
|
class ModuleSidebarAndStatusTest extends TestCase
|
|
{
|
|
/**
|
|
* @return array<int, array{0: string, 1: string}>
|
|
*/
|
|
public static function moduleRoutes(): array
|
|
{
|
|
return [
|
|
['analytics.index', 'Analytics'],
|
|
['audit.index', 'Audit'],
|
|
['carrier-management.index', 'Carrier Management'],
|
|
['configuration.index', 'Configuration'],
|
|
['document-archive.index', 'Document Archive'],
|
|
['inventory-management.index', 'Inventory Management'],
|
|
['m3-integration.index', 'M3 Integration'],
|
|
['replenishment.index', 'Replenishment'],
|
|
['reporting.index', 'Reporting'],
|
|
['security.index', 'Security'],
|
|
['sentinel-integration.index', 'Sentinel Integration'],
|
|
['shipping.index', 'Shipping'],
|
|
['transportation.index', 'Transportation'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider moduleRoutes
|
|
*/
|
|
public function test_enabled_module_route_renders(string $routeName, string $label): void
|
|
{
|
|
$this->assertTrue(Route::has($routeName), "Missing route [{$routeName}].");
|
|
|
|
$user = UserFactory::new()->mpbaPlatformAdmin()->create();
|
|
|
|
$this->actingAs($user)
|
|
->get(route($routeName))
|
|
->assertOk()
|
|
->assertSee($label, false)
|
|
->assertSee('Warehouse Management System', false);
|
|
}
|
|
|
|
public function test_sidebar_contains_all_enabled_web_modules(): void
|
|
{
|
|
$user = UserFactory::new()->mpbaPlatformAdmin()->create();
|
|
|
|
$response = $this->actingAs($user)->get(route('platform.dashboard'))->assertOk();
|
|
|
|
foreach (self::moduleRoutes() as [$routeName, $label]) {
|
|
$response->assertSee(route($routeName), false);
|
|
}
|
|
|
|
foreach (['Analytics', 'Inventory', 'Replenishment', 'Shipping', 'Transportation', 'Carriers', 'M3 Integration', 'Sentinel', 'Documents', 'Reporting', 'Configuration', 'Security', 'Audit'] as $label) {
|
|
$response->assertSee($label, false);
|
|
}
|
|
}
|
|
|
|
public function test_modules_statuses_file_enables_all_modules(): void
|
|
{
|
|
$statuses = json_decode(file_get_contents(base_path('modules_statuses.json')), true, 512, JSON_THROW_ON_ERROR);
|
|
|
|
foreach ([
|
|
'Analytics', 'Audit', 'CarrierManagement', 'Configuration', 'DocumentArchive', 'InternalApi',
|
|
'InventoryManagement', 'M3Integration', 'Platform', 'Replenishment', 'Reporting', 'Security',
|
|
'SentinelIntegration', 'Shipping', 'Transportation', 'Warehouse',
|
|
] as $module) {
|
|
$this->assertArrayHasKey($module, $statuses);
|
|
$this->assertTrue($statuses[$module], "Module [{$module}] is not enabled.");
|
|
}
|
|
}
|
|
}
|