mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 05:10:59 +00:00
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
86 lines
2.7 KiB
PHP
86 lines
2.7 KiB
PHP
<?php
|
|
|
|
use App\Domains\Accounts\Models\User;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use InvoiceShelf\Modules\Registry;
|
|
use Laravel\Sanctum\Sanctum;
|
|
|
|
use function Pest\Laravel\getJson;
|
|
|
|
beforeEach(function () {
|
|
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
|
|
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
|
|
|
|
$user = User::find(1);
|
|
$this->withHeaders([
|
|
'company' => $user->companies()->first()->id,
|
|
]);
|
|
Sanctum::actingAs($user, ['*']);
|
|
|
|
Registry::flush();
|
|
});
|
|
|
|
afterEach(function () {
|
|
Registry::flush();
|
|
});
|
|
|
|
test('bootstrap merges module menu items into main_menu', function () {
|
|
Registry::registerMenu('sales-tax-us', [
|
|
'title' => 'sales_tax_us::menu.title',
|
|
'link' => '/admin/modules/sales-tax-us/settings',
|
|
'icon' => 'CalculatorIcon',
|
|
]);
|
|
|
|
$response = getJson('api/v1/bootstrap')->assertOk();
|
|
|
|
$mainMenu = collect($response->json('main_menu'));
|
|
$moduleItem = $mainMenu->firstWhere('name', 'module-sales-tax-us');
|
|
|
|
expect($moduleItem)->not->toBeNull();
|
|
expect($moduleItem['link'])->toBe('/admin/modules/sales-tax-us/settings');
|
|
expect($moduleItem['icon'])->toBe('CalculatorIcon');
|
|
expect($moduleItem['group'])->toBe('modules');
|
|
});
|
|
|
|
test('module items support custom group and priority', function () {
|
|
Registry::registerMenu('sales-tax-us', [
|
|
'title' => 'sales_tax_us::menu.title',
|
|
'link' => '/admin/modules/sales-tax-us/settings',
|
|
'icon' => 'CalculatorIcon',
|
|
'group' => 'documents',
|
|
'priority' => 25,
|
|
]);
|
|
|
|
$response = getJson('api/v1/bootstrap')->assertOk();
|
|
|
|
$mainMenu = collect($response->json('main_menu'));
|
|
$moduleItem = $mainMenu->firstWhere('name', 'module-sales-tax-us');
|
|
|
|
expect($moduleItem['group'])->toBe('documents');
|
|
expect($moduleItem['priority'])->toBe(25);
|
|
});
|
|
|
|
test('bootstrap has no module items when nothing is registered', function () {
|
|
$response = getJson('api/v1/bootstrap')->assertOk();
|
|
|
|
$mainMenu = collect($response->json('main_menu'));
|
|
$moduleItems = $mainMenu->filter(fn ($item) => str_starts_with($item['name'], 'module-'));
|
|
|
|
expect($moduleItems)->toBeEmpty();
|
|
});
|
|
|
|
test('admin-mode bootstrap does not include module items', function () {
|
|
Registry::registerMenu('sales-tax-us', [
|
|
'title' => 'sales_tax_us::menu.title',
|
|
'link' => '/admin/modules/sales-tax-us/settings',
|
|
'icon' => 'CalculatorIcon',
|
|
]);
|
|
|
|
$response = getJson('api/v1/bootstrap?admin_mode=1');
|
|
|
|
$mainMenu = collect($response->json('main_menu'));
|
|
$moduleItems = $mainMenu->filter(fn ($item) => str_starts_with($item['name'] ?? '', 'module-'));
|
|
|
|
expect($moduleItems)->toBeEmpty();
|
|
});
|