Some checks failed
Main Confidence / confidence (push) Failing after 54s
Integrates latest TenantPilot platform changes from `platform-dev` into `dev`. Refresh method in this update: merge from `origin/dev` into `platform-dev` on explicit user request. This PR was created by agent on user request; do not merge automatically. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #308
82 lines
3.4 KiB
PHP
82 lines
3.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\CrossTenantComparePage;
|
|
use App\Filament\Resources\TenantResource;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\Feature\Concerns\BuildsPortfolioCompareFixtures;
|
|
|
|
uses(RefreshDatabase::class, BuildsPortfolioCompareFixtures::class);
|
|
|
|
it('renders a reproducible compare preview and promotion preflight for two authorized tenants', function (): void {
|
|
$fixture = $this->makeCrossTenantCompareFixture();
|
|
|
|
$this->createPortfolioCompareSubject(
|
|
tenant: $fixture['sourceTenant'],
|
|
displayName: 'WiFi Corp',
|
|
snapshot: ['settings' => [['key' => 'wifi', 'value' => 1]]],
|
|
);
|
|
$this->createPortfolioCompareSubject(
|
|
tenant: $fixture['targetTenant'],
|
|
displayName: 'WiFi Corp',
|
|
snapshot: ['settings' => [['key' => 'wifi', 'value' => 1]]],
|
|
);
|
|
$this->createPortfolioCompareSubject(
|
|
tenant: $fixture['sourceTenant'],
|
|
displayName: 'Windows Compliance',
|
|
snapshot: ['settings' => [['key' => 'compliance', 'value' => 1]]],
|
|
);
|
|
$this->createPortfolioCompareSubject(
|
|
tenant: $fixture['targetTenant'],
|
|
displayName: 'Windows Compliance',
|
|
snapshot: ['settings' => [['key' => 'compliance', 'value' => 2]]],
|
|
);
|
|
|
|
$session = $this->setAdminWorkspaceContext($fixture['user'], $fixture['workspace']);
|
|
$query = [
|
|
'source_tenant_id' => (int) $fixture['sourceTenant']->getKey(),
|
|
'target_tenant_id' => (int) $fixture['targetTenant']->getKey(),
|
|
'policy_type' => ['deviceConfiguration'],
|
|
];
|
|
|
|
$this->withSession($session)
|
|
->get(CrossTenantComparePage::getUrl(parameters: $query, panel: 'admin'))
|
|
->assertOk()
|
|
->assertSee('Cross-tenant compare')
|
|
->assertSee('Compare preview')
|
|
->assertSee('WiFi Corp')
|
|
->assertSee('Windows Compliance')
|
|
->assertSee('Source tenant: '.$fixture['sourceTenant']->name)
|
|
->assertSee('Target tenant: '.$fixture['targetTenant']->name)
|
|
->assertSee(TenantResource::getUrl('view', ['record' => $fixture['sourceTenant']], panel: 'admin'), false)
|
|
->assertSee(TenantResource::getUrl('view', ['record' => $fixture['targetTenant']], panel: 'admin'), false);
|
|
|
|
Livewire::withQueryParams($query)
|
|
->actingAs($fixture['user'])
|
|
->test(CrossTenantComparePage::class)
|
|
->assertActionVisible('generatePromotionPreflight')
|
|
->assertActionEnabled('generatePromotionPreflight')
|
|
->call('generatePromotionPreflight')
|
|
->assertHasNoErrors()
|
|
->assertSee('Promotion preflight')
|
|
->assertSee('WiFi Corp')
|
|
->assertSee('Windows Compliance');
|
|
});
|
|
|
|
it('rejects the same tenant as source and target without rendering compare results', function (): void {
|
|
$fixture = $this->makeCrossTenantCompareFixture();
|
|
|
|
$session = $this->setAdminWorkspaceContext($fixture['user'], $fixture['workspace']);
|
|
|
|
$this->withSession($session)
|
|
->get(CrossTenantComparePage::getUrl(parameters: [
|
|
'source_tenant_id' => (int) $fixture['sourceTenant']->getKey(),
|
|
'target_tenant_id' => (int) $fixture['sourceTenant']->getKey(),
|
|
], panel: 'admin'))
|
|
->assertOk()
|
|
->assertSee('Choose two different tenants.')
|
|
->assertDontSee('data-testid="cross-tenant-compare-preview"', false)
|
|
->assertDontSee('Promotion preflight');
|
|
}); |