Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 3m43s
Refactored the customer-review workspace to emphasize the Operator Summary, tightening the hierarchy. Readiness flow and acknowledgment details were adjusted, and supporting proof panels moved to secondary visual weight.
132 lines
5.4 KiB
PHP
132 lines
5.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Reviews\CustomerReviewWorkspace;
|
|
use App\Models\EnvironmentReview;
|
|
use App\Models\EvidenceSnapshot;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\User;
|
|
use App\Support\EnvironmentReviewStatus;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
pest()->browser()->timeout(60_000);
|
|
|
|
beforeEach(function (): void {
|
|
Storage::fake('exports');
|
|
});
|
|
|
|
it('Spec344 smokes the customer review workspace hierarchy and density changes', function (): void {
|
|
[$user, $environment] = createUserWithTenant(role: 'owner', workspaceRole: 'manager');
|
|
$environment->forceFill(['name' => 'Spec344 Browser Workspace'])->save();
|
|
|
|
$snapshot = seedEnvironmentReviewEvidence($environment, findingCount: 0, driftCount: 0);
|
|
spec344BrowserCreatePublishedReview($environment, $user, $snapshot);
|
|
|
|
spec344AuthenticateBrowser($this, $user, $environment);
|
|
|
|
$page = visit(CustomerReviewWorkspace::environmentFilterUrl($environment))
|
|
->resize(1236, 900)
|
|
->waitForText(__('localization.review.review_acknowledgement'))
|
|
->assertSee(__('localization.review.review_consumption_flow'))
|
|
->assertNoJavaScriptErrors()
|
|
->assertNoConsoleLogs();
|
|
|
|
$page->assertScript('document.querySelector("[data-testid=\"customer-review-readiness-flow\"]")?.open === false', true);
|
|
$page->assertScript(
|
|
'(() => { const ack = document.querySelector("[data-testid=\"customer-review-acknowledgement-card\"]"); const flow = document.querySelector("[data-testid=\"customer-review-readiness-flow\"]"); if (!ack || !flow) return false; return ack.getBoundingClientRect().top < flow.getBoundingClientRect().top; })()',
|
|
true,
|
|
);
|
|
|
|
$page->script('window.scrollTo(0, 0);');
|
|
$page->screenshot(true, spec344BrowserScreenshotName('01-operator-summary'));
|
|
spec344CopyBrowserScreenshot('01-operator-summary');
|
|
|
|
$page->script('document.querySelector("[data-testid=\"customer-review-acknowledgement-card\"]")?.scrollIntoView({ block: "start" });');
|
|
$page->screenshot(true, spec344BrowserScreenshotName('02-acknowledgement-prominent'));
|
|
spec344CopyBrowserScreenshot('02-acknowledgement-prominent');
|
|
|
|
$page->script('document.querySelector("[data-testid=\"customer-review-readiness-flow\"]")?.scrollIntoView({ block: "start" });');
|
|
$page->assertScript('document.querySelector("[data-testid=\"customer-review-readiness-flow\"]")?.open === false', true);
|
|
$page->screenshot(true, spec344BrowserScreenshotName('03-supporting-details-demoted'));
|
|
spec344CopyBrowserScreenshot('03-supporting-details-demoted');
|
|
|
|
$page->script('document.querySelector("[data-testid=\"customer-review-diagnostics\"]")?.scrollIntoView({ block: "start" });');
|
|
$page->assertScript('document.querySelector("[data-testid=\"customer-review-diagnostics\"]")?.open === false', true);
|
|
$page->screenshot(true, spec344BrowserScreenshotName('04-diagnostics-collapsed'));
|
|
spec344CopyBrowserScreenshot('04-diagnostics-collapsed');
|
|
|
|
$page->script("document.documentElement.classList.add('dark');");
|
|
$page->script('window.scrollTo(0, 0);');
|
|
$page->assertScript('document.documentElement.classList.contains("dark")', true);
|
|
$page->screenshot(true, spec344BrowserScreenshotName('05-dark-mode'));
|
|
spec344CopyBrowserScreenshot('05-dark-mode');
|
|
});
|
|
|
|
function spec344BrowserScreenshotName(string $name): string
|
|
{
|
|
return 'spec344-customer-review-workspace-'.$name;
|
|
}
|
|
|
|
function spec344CopyBrowserScreenshot(string $name): void
|
|
{
|
|
$filename = spec344BrowserScreenshotName($name).'.png';
|
|
$source = base_path('tests/Browser/Screenshots/'.$filename);
|
|
$targetDirectory = repo_path('specs/344-customer-review-workspace-density-audience-polish/artifacts/screenshots');
|
|
|
|
if (! is_dir($targetDirectory)) {
|
|
@mkdir($targetDirectory, 0755, true);
|
|
}
|
|
|
|
if (! is_file($source)) {
|
|
$source = \Pest\Browser\Support\Screenshot::path($filename);
|
|
}
|
|
|
|
for ($attempt = 0; $attempt < 10 && ! is_file($source); $attempt++) {
|
|
usleep(100_000);
|
|
clearstatcache(true, $source);
|
|
}
|
|
|
|
if (is_file($source) && is_dir($targetDirectory) && is_writable($targetDirectory)) {
|
|
@copy($source, $targetDirectory.DIRECTORY_SEPARATOR.$name.'.png');
|
|
}
|
|
}
|
|
|
|
function spec344AuthenticateBrowser(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(),
|
|
]);
|
|
|
|
setAdminPanelContext($environment);
|
|
}
|
|
|
|
function spec344BrowserCreatePublishedReview(ManagedEnvironment $environment, User $user, EvidenceSnapshot $snapshot): EnvironmentReview
|
|
{
|
|
$review = composeEnvironmentReviewForTest($environment, $user, $snapshot);
|
|
|
|
$review->forceFill([
|
|
'status' => EnvironmentReviewStatus::Published->value,
|
|
'generated_at' => now(),
|
|
'published_at' => now(),
|
|
'published_by_user_id' => (int) $user->getKey(),
|
|
])->save();
|
|
|
|
return $review->refresh();
|
|
}
|
|
|