Automated PR provided by Codex via Gitea API. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #486
96 lines
4.1 KiB
PHP
96 lines
4.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\TenantConfiguration\CoverageV2Readiness;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\User;
|
|
use App\Services\TenantConfiguration\ResourceTypeRegistry;
|
|
use App\Services\TenantConfiguration\SupportedScopeResolver;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
pest()->browser()->timeout(60_000);
|
|
|
|
it('Spec419 smokes active M365 registry rows on the Coverage v2 operator surface', function (): void {
|
|
[$user, $environment] = spec419M365RegistryBrowserFixture();
|
|
spec419AuthenticateM365RegistryBrowser($this, $user, $environment);
|
|
|
|
visit(CoverageV2Readiness::getUrl(tenant: $environment, panel: 'admin'))
|
|
->resize(1440, 1100)
|
|
->waitForText('Coverage v2 Readiness')
|
|
->assertSee('Spec419 Browser Environment')
|
|
->assertSee('Resource type registry')
|
|
->assertSee('Resource instances')
|
|
->assertSee('Conditional Access policy')
|
|
->assertSee('Application registration')
|
|
->assertSee('Security defaults')
|
|
->assertSee('Accepted domain')
|
|
->assertSee('TCM')
|
|
->assertSee('Out of scope')
|
|
->assertSee('Detected')
|
|
->assertSee('Not included')
|
|
->assertSee('Internal only')
|
|
->assertDontSee('100% Microsoft 365 coverage')
|
|
->assertDontSee('100% M365 coverage')
|
|
->assertDontSee('Full M365 coverage')
|
|
->assertDontSee('Certified M365 coverage')
|
|
->assertDontSee('Restore-ready M365 coverage')
|
|
->assertDontSee('M365 TCM registry detected')
|
|
->assertDontSee('m365_tcm_registry_detected')
|
|
->assertScript('typeof window.Livewire !== "undefined"', true)
|
|
->assertScript('(() => document.querySelectorAll("table tbody tr").length >= 8)()', true)
|
|
->assertScript("(() => Array.from(document.querySelectorAll('table button, table a')).filter((element) => /^(Capture|Start capture|Restore|Restore ready|Certify|Certified|Publish|Export|Download|Report)$/i.test(element.textContent.trim())).length)()", 0)
|
|
->assertScript("(() => ! /M365 full coverage|Microsoft 365 full coverage|M365 certified coverage|Microsoft 365 certified coverage|M365 restore-ready coverage|Microsoft 365 restore-ready coverage/i.test(document.body.textContent))()", true)
|
|
->assertScript("(() => ! /m365_tcm_registry_detected|entra_tcm_registry_detected|exchange_tcm_registry_detected|teams_tcm_registry_detected|security_compliance_tcm_registry_detected|m365_tcm_generic_future|m365_tcm_certified_none/i.test(document.body.textContent))()", true)
|
|
->assertScript("(() => performance.getEntriesByType('resource').filter((entry) => /graph\\.microsoft\\.com|\\/tcm\\b|provider-remote/i.test(entry.name)).length)()", 0)
|
|
->assertNoJavaScriptErrors()
|
|
->assertNoConsoleLogs()
|
|
->screenshot(true, 'spec419-m365-registry-operator-surface');
|
|
});
|
|
|
|
/**
|
|
* @return array{0: User, 1: ManagedEnvironment}
|
|
*/
|
|
function spec419M365RegistryBrowserFixture(): array
|
|
{
|
|
$environment = ManagedEnvironment::factory()->active()->create([
|
|
'name' => 'Spec419 Browser Environment',
|
|
'external_id' => 'spec419-browser-environment',
|
|
]);
|
|
|
|
[$user, $environment] = createUserWithTenant(
|
|
tenant: $environment,
|
|
role: 'owner',
|
|
workspaceRole: 'owner',
|
|
clearCapabilityCaches: true,
|
|
);
|
|
|
|
(new ResourceTypeRegistry)->syncDefaults();
|
|
(new SupportedScopeResolver)->syncDefaults();
|
|
|
|
return [$user, $environment->refresh()];
|
|
}
|
|
|
|
function spec419AuthenticateM365RegistryBrowser(
|
|
mixed $test,
|
|
User $user,
|
|
ManagedEnvironment $environment,
|
|
): void {
|
|
$workspaceId = (int) $environment->workspace_id;
|
|
|
|
$test->actingAs($user)->withSession([
|
|
WorkspaceContext::SESSION_KEY => $workspaceId,
|
|
WorkspaceContext::LAST_ENVIRONMENT_IDS_SESSION_KEY => [
|
|
(string) $workspaceId => (int) $environment->getKey(),
|
|
],
|
|
]);
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, $workspaceId);
|
|
session()->put(WorkspaceContext::LAST_ENVIRONMENT_IDS_SESSION_KEY, [
|
|
(string) $workspaceId => (int) $environment->getKey(),
|
|
]);
|
|
}
|