@@ -49,6 +49,27 @@ afterEach(function () {
|
||||
}
|
||||
});
|
||||
|
||||
test('company preparation and bootstrap protect history without configuration or access writes', function () {
|
||||
DB::table('organization_access')->where('tenant_id', $this->f['tenant']->id)->update(['active' => false]);
|
||||
$legacyAdmin = User::factory()->create(['tenant_id' => $this->f['tenant']->id, 'department_id' => $this->f['r']->department_id, 'purchasing_role' => PurchasingRole::Admin]);
|
||||
$starter = User::factory()->create(['tenant_id' => null, 'department_id' => null, 'purchasing_role' => PurchasingRole::Requester]);
|
||||
$tables = ['tenants', 'departments', 'cost_centers', 'users', 'organization_profiles', 'organization_memberships', 'organization_access', 'audit_logs'];
|
||||
$snapshot = static function () use ($tables): array {
|
||||
$frames = [];
|
||||
foreach ($tables as $table) {
|
||||
$frames[$table] = DB::table($table)->get()->map(fn (object $row) => json_encode((array) $row, JSON_THROW_ON_ERROR))->sort()->values()->all();
|
||||
}
|
||||
|
||||
return $frames;
|
||||
};
|
||||
$before = $snapshot();
|
||||
foreach ([[$legacyAdmin, '/empresa', 'company/index'], [$starter, '/empresa/iniciar', 'company/setup']] as [$actor, $url, $component]) {
|
||||
$response = $this->actingAs($actor)->get($url)->assertOk()->assertViewHas('page', fn (array $page) => $page['component'] === $component && $page['encryptHistory'] === true);
|
||||
expect($response->headers->get('Cache-Control'))->toContain('private')->toContain('no-store');
|
||||
}
|
||||
expect($snapshot())->toBe($before);
|
||||
});
|
||||
|
||||
test('intelligence settings are independently configurable audited and scoped without rewriting processes', function () {
|
||||
if (DB::getDriverName() === 'pgsql') {
|
||||
// The real report opens its own read-only snapshot, outside the test wrapper.
|
||||
|
||||
Reference in New Issue
Block a user