['pessoas' => false, 'armazem_avancado' => false, 'fornecimento' => false]]); $tenant = Tenant::query()->create(['name' => 'Empresa do núcleo']); $department = Department::query()->create(['tenant_id' => $tenant->id, 'name' => 'Operações']); $this->admin = User::factory()->create(['tenant_id' => $tenant->id, 'department_id' => $department->id, 'purchasing_role' => PurchasingRole::Admin]); }); test('core purchasing pages stay available with every lateral module off', function (string $path) { $this->actingAs($this->admin)->get($path)->assertOk(); })->with([ '/dashboard', '/requisicoes', '/fornecedores', '/cotacoes', '/ordens', '/recepcoes', '/stock', '/stock/operacoes', '/facturas', '/pagamentos', '/orcamentos', '/regras-investimento', '/empresa', '/conflitos', '/relatorios', ]); test('lateral module routes answer as missing when their module is off', function (string $path) { $this->actingAs($this->admin)->get($path)->assertNotFound(); })->with([ 'pessoas' => '/pessoas', 'pessoas: relatórios' => '/pessoas/relatorios', 'pessoas: portal público' => '/candidaturas/1', 'armazém: requisições internas' => '/stock/requisicoes', 'armazém: reposição automática' => '/stock/reposicao', 'armazém: lotes' => '/stock/lotes', 'fornecimento: planeado' => '/compras/fornecimento', 'fornecimento: equipamentos' => '/equipamentos', 'fornecimento: projectos e imobilizado' => '/projectos-imobilizado', ]); test('a module switched on serves its routes again', function () { config(['modules.enabled.fornecimento' => true]); expect(app(ProductModules::class)->enabled('fornecimento'))->toBeTrue(); $this->actingAs($this->admin)->get('/equipamentos')->assertStatus(200); }); test('menus receive the paths of disabled modules and keep the core ones', function () { $this->actingAs($this->admin)->get('/dashboard')->assertOk()->assertInertia(fn (Assert $page) => $page ->where('modules', ['pessoas' => false, 'armazem_avancado' => false, 'fornecimento' => false]) ->where('disabledModulePaths', fn ($paths) => collect($paths)->contains('/pessoas') && collect($paths)->contains('/stock/requisicoes') && collect($paths)->contains('/equipamentos') && ! collect($paths)->contains('/stock') && ! collect($paths)->contains('/requisicoes') && ! collect($paths)->contains('/compras'))); }); test('people work contexts are not offered while the people module is off', function () { config(['work_context.composition' => 'sgc', 'work_context.entitlements' => [$this->admin->tenant_id => array_keys(WorkContext::OPTIONS)]]); expect(app(WorkContext::class)->purchased($this->admin))->not->toContain('people.internal')->not->toContain('people.third_party') ->toContain('procurement.internal'); config(['modules.enabled.pessoas' => true]); expect(app(WorkContext::class)->purchased($this->admin))->toContain('people.internal'); });