create(); $user = User::factory()->create(); $startedBy = User::factory()->create(['name' => 'Primary Owner']); $updatedBy = User::factory()->create(['name' => 'Second Operator']); foreach ([$user, $startedBy, $updatedBy] as $member) { WorkspaceMembership::factory()->create([ 'workspace_id' => (int) $workspace->getKey(), 'user_id' => (int) $member->getKey(), 'role' => 'owner', ]); } session()->put(WorkspaceContext::SESSION_KEY, (int) $workspace->getKey()); createOnboardingDraft([ 'workspace' => $workspace, 'started_by' => $startedBy, 'updated_by' => $updatedBy, 'state' => [ 'entra_tenant_id' => '11111111-1111-1111-1111-111111111111', 'tenant_name' => 'Contoso', 'environment' => 'prod', 'primary_domain' => 'contoso.example', ], ]); createOnboardingDraft([ 'workspace' => $workspace, 'started_by' => $updatedBy, 'updated_by' => $startedBy, 'current_step' => 'connection', 'state' => [ 'entra_tenant_id' => '22222222-2222-2222-2222-222222222222', 'tenant_name' => 'Fabrikam', 'environment' => 'staging', ], ]); $this->actingAs($user) ->get(route('admin.onboarding')) ->assertSuccessful() ->assertSee('Multiple onboarding drafts are available.') ->assertSee('Contoso') ->assertSee('Fabrikam') ->assertSee('Current stage') ->assertSee('Started by') ->assertSee('Last updated by') ->assertSee('Primary Owner') ->assertSee('Second Operator') ->assertSee('Resume onboarding') ->assertSee('View summary'); }); it('excludes completed and cancelled drafts from the landing picker', function (): void { $workspace = Workspace::factory()->create(); $user = User::factory()->create(); WorkspaceMembership::factory()->create([ 'workspace_id' => (int) $workspace->getKey(), 'user_id' => (int) $user->getKey(), 'role' => 'owner', ]); session()->put(WorkspaceContext::SESSION_KEY, (int) $workspace->getKey()); createOnboardingDraft([ 'workspace' => $workspace, 'started_by' => $user, 'updated_by' => $user, 'state' => [ 'entra_tenant_id' => '33333333-3333-3333-3333-333333333333', 'tenant_name' => 'Visible Draft A', ], ]); createOnboardingDraft([ 'workspace' => $workspace, 'started_by' => $user, 'updated_by' => $user, 'state' => [ 'entra_tenant_id' => '44444444-4444-4444-4444-444444444444', 'tenant_name' => 'Visible Draft B', ], ]); createOnboardingDraft([ 'workspace' => $workspace, 'started_by' => $user, 'updated_by' => $user, 'status' => 'completed', 'state' => [ 'entra_tenant_id' => '55555555-5555-5555-5555-555555555555', 'tenant_name' => 'Completed Draft', ], ]); createOnboardingDraft([ 'workspace' => $workspace, 'started_by' => $user, 'updated_by' => $user, 'status' => 'cancelled', 'state' => [ 'entra_tenant_id' => '66666666-6666-6666-6666-666666666666', 'tenant_name' => 'Cancelled Draft', ], ]); $this->actingAs($user) ->get(route('admin.onboarding')) ->assertSuccessful() ->assertSee('Visible Draft A') ->assertSee('Visible Draft B') ->assertDontSee('Completed Draft') ->assertDontSee('Cancelled Draft'); });