文件
OmniCard/docs/test-evidence/round-5/test-btp-19.ps1

174 行
9.4 KiB
PowerShell

# ==============================================================================
# OmniCard AI (CRMmp) - BTP-19 Lead Scoring Algorithm & Profile Test
# ==============================================================================
$session = "btp19"
$evidenceDir = "docs/test-evidence/round-5"
$initScript = "$evidenceDir/browser-init-btp19.js"
$leadsScreenshot = "$evidenceDir/btp-19-leads-list.png"
$profileScreenshot = "$evidenceDir/btp-19-lead-profile.png"
$finalScreenshot = "$evidenceDir/btp-19-lead-score.png"
Write-Host "=================================================================="
Write-Host "[BTP-19] Lead Scoring Radar Algorithm and Panoramic Profile Test (P1)"
Write-Host "Session ID: $session"
Write-Host "Final Screenshot Target: $finalScreenshot"
Write-Host "=================================================================="
# ------------------------------------------------------------------------------
# Step 0: Login
# ------------------------------------------------------------------------------
Write-Host "`n>>> [Step 0/2] Open login page http://localhost:5173/login ..."
agent-browser --session $session open "http://localhost:5173/login" --init-script $initScript
Start-Sleep -Seconds 2
Write-Host "Click sign-in button (button.arco-btn-primary) ..."
agent-browser --session $session click "button.arco-btn-primary"
Start-Sleep -Seconds 2
$loginUrl = agent-browser --session $session get url
Write-Host "Logged in. Current URL: $loginUrl"
# ------------------------------------------------------------------------------
# Step 1: Navigate to Leads List http://localhost:5173/crm/leads
# ------------------------------------------------------------------------------
Write-Host "`n>>> [Step 1/2] Navigate to leads list http://localhost:5173/crm/leads ..."
agent-browser --session $session open "http://localhost:5173/crm/leads" --init-script $initScript
Start-Sleep -Seconds 3
$leadsSnapshot = agent-browser --session $session snapshot -i
Write-Host "`n---------- Leads List Interactive Snapshot ----------"
Write-Host $leadsSnapshot
Write-Host "-----------------------------------------------------"
# Table columns validation
$uName = [regex]::Unescape("\u59D3\u540D")
$uCompany = [regex]::Unescape("\u516C\u53F8")
$uEmail = [regex]::Unescape("\u90AE\u7BB1")
$uPhone = [regex]::Unescape("\u7535\u8BDD")
$uStatus = [regex]::Unescape("\u72B6\u6001")
$uIntent = [regex]::Unescape("\u610F\u5411")
$uProfile = [regex]::Unescape("\u753B\u50CF")
$hasColName = ($leadsSnapshot -match "Name") -or ($leadsSnapshot -match $uName)
$hasColCompany = ($leadsSnapshot -match "Company") -or ($leadsSnapshot -match $uCompany)
$hasColEmail = ($leadsSnapshot -match "Email") -or ($leadsSnapshot -match $uEmail)
$hasColPhone = ($leadsSnapshot -match "Phone") -or ($leadsSnapshot -match $uPhone)
$hasColStatus = ($leadsSnapshot -match "Status") -or ($leadsSnapshot -match $uStatus)
$hasColIntent = ($leadsSnapshot -match "Intent") -or ($leadsSnapshot -match $uIntent)
$hasColAction = ($leadsSnapshot -match "Profile") -or ($leadsSnapshot -match $uProfile)
# Data row names
$hasFatima = $leadsSnapshot -match "Fatima Al-Mansoor"
$hasMichael = $leadsSnapshot -match "Michael Scott"
$hasElena = $leadsSnapshot -match "Elena Rostova"
$hasKenji = $leadsSnapshot -match "Kenji Sato"
# Intent Scores
$hasScore92 = $leadsSnapshot -match "92"
$hasScore85 = $leadsSnapshot -match "85"
$hasScore65 = $leadsSnapshot -match "65"
$hasScore98 = $leadsSnapshot -match "98"
# Status Tags
$uHot = [regex]::Unescape("\u9AD8\u610F\u5411")
$uContacted = [regex]::Unescape("\u5DF2\u8054\u7CFB")
$uNew = [regex]::Unescape("\u65B0\u7EBF\u7D22")
$uWon = [regex]::Unescape("\u5DF2\u6210\u4EA4")
$hasStatusHot = ($leadsSnapshot -match "Hot") -or ($leadsSnapshot -match $uHot)
$hasStatusContacted = ($leadsSnapshot -match "Contacted") -or ($leadsSnapshot -match $uContacted)
$hasStatusNew = ($leadsSnapshot -match "New") -or ($leadsSnapshot -match $uNew)
$hasStatusWon = ($leadsSnapshot -match "Won") -or ($leadsSnapshot -match $uWon)
Write-Host "`n[Step 1 Assertions]:"
Write-Host "1. Columns completeness: $(if ($hasColName -and $hasColCompany -and $hasColEmail -and $hasColPhone -and $hasColStatus -and $hasColIntent -and $hasColAction) { '[PASS]' } else { '[FAIL]' })"
Write-Host "2. Lead contacts loaded (Fatima, Michael, Elena, Kenji): $(if ($hasFatima -and $hasMichael -and $hasElena -and $hasKenji) { '[PASS]' } else { '[FAIL]' })"
Write-Host "3. Radar scoring outputs (92, 85, 65, 98): $(if ($hasScore92 -and $hasScore85 -and $hasScore65 -and $hasScore98) { '[PASS]' } else { '[FAIL]' })"
Write-Host "4. Status lifecycle tags (hot/contacted/new/won): $(if ($hasStatusHot -and $hasStatusContacted -and $hasStatusNew -and $hasStatusWon) { '[PASS]' } else { '[FAIL]' })"
# Take screenshot of leads table
agent-browser --session $session screenshot $leadsScreenshot
Write-Host "Leads list screenshot saved: $leadsScreenshot"
# ------------------------------------------------------------------------------
# Step 2: Navigate to Panoramic Lead Profile http://localhost:5173/crm/lead-profile?id=1
# ------------------------------------------------------------------------------
Write-Host "`n>>> [Step 2/2] Navigate to panoramic lead profile http://localhost:5173/crm/lead-profile?id=1 ..."
agent-browser --session $session open "http://localhost:5173/crm/lead-profile?id=1" --init-script $initScript
Start-Sleep -Seconds 3
# Full snapshot captures non-interactive Descriptions nodes as well
$profileFullSnapshot = agent-browser --session $session snapshot
Write-Host "`n---------- Lead Panoramic Profile Full Snapshot ----------"
Write-Host $profileFullSnapshot
Write-Host "----------------------------------------------------------"
# Verify profile descriptions
$hasProfileFatima = $profileFullSnapshot -match "Fatima Al-Mansoor"
$hasProfileCompany = $profileFullSnapshot -match "Al-Mansoor Enterprises"
$hasProfileEmail = $profileFullSnapshot -match "fatima@almansoor.ae"
$hasProfilePhone = $profileFullSnapshot -match "\+971-50-9876543"
$hasProfileScore = $profileFullSnapshot -match "92"
$hasProfileHot = ($profileFullSnapshot -match "Hot") -or ($profileFullSnapshot -match $uHot)
$hasProfileNotes = ($profileFullSnapshot -match "Gitex") -or ($profileFullSnapshot -match "5,000")
# Verify radar footstep tracks table
$uRadarTitle = [regex]::Unescape("\u8BBF\u5BA2\u8DB3\u8FF9")
$hasRadarTitle = ($profileFullSnapshot -match "Visitor trail") -or ($profileFullSnapshot -match $uRadarTitle)
$hasDubaiTrack = ($profileFullSnapshot -match "United Arab Emirates") -or ($profileFullSnapshot -match "Dubai")
$hasFrankfurtTrack = ($profileFullSnapshot -match "Germany") -or ($profileFullSnapshot -match "Frankfurt")
$hasSanFranTrack = ($profileFullSnapshot -match "United States") -or ($profileFullSnapshot -match "San Francisco")
$hasDuration = ($profileFullSnapshot -match "320.0s") -or ($profileFullSnapshot -match "320s") -or ($profileFullSnapshot -match "85.0s")
$hasDepth = ($profileFullSnapshot -match "95%") -or ($profileFullSnapshot -match "60%")
Write-Host "`n[Step 2 Assertions]:"
Write-Host "1. Descriptions base profile (Name/Company/Email/Phone): $(if ($hasProfileFatima -and $hasProfileCompany -and $hasProfileEmail -and $hasProfilePhone) { '[PASS]' } else { '[FAIL]' })"
Write-Host "2. Intent level & score badge (Hot / 92): $(if ($hasProfileScore -and $hasProfileHot) { '[PASS]' } else { '[FAIL]' })"
Write-Host "3. Lead notes & inquiry requirements: $(if ($hasProfileNotes) { '[PASS]' } else { '[FAIL]' })"
Write-Host "4. Associated radar tracks (UAE Dubai, Germany Frankfurt, USA SF): $(if ($hasRadarTitle -and $hasDubaiTrack -and $hasFrankfurtTrack -and $hasSanFranTrack) { '[PASS]' } else { '[FAIL]' })"
# Take screenshot of profile
agent-browser --session $session screenshot $profileScreenshot
Write-Host "Profile screenshot saved: $profileScreenshot"
# ------------------------------------------------------------------------------
# Image Composite: Stitch leads list and panoramic profile
# ------------------------------------------------------------------------------
Write-Host "`n>>> Stitching dual screenshots into $finalScreenshot ..."
Add-Type -AssemblyName System.Drawing
$img1 = [System.Drawing.Bitmap]::FromFile((Resolve-Path $leadsScreenshot).Path)
$img2 = [System.Drawing.Bitmap]::FromFile((Resolve-Path $profileScreenshot).Path)
$w = [Math]::Max($img1.Width, $img2.Width)
$h = $img1.Height + $img2.Height
$combo = New-Object System.Drawing.Bitmap($w, $h)
$g = [System.Drawing.Graphics]::FromImage($combo)
$g.Clear([System.Drawing.Color]::White)
$g.DrawImage($img1, 0, 0)
$g.DrawImage($img2, 0, $img1.Height)
$fullOut = [System.IO.Path]::GetFullPath($finalScreenshot)
$combo.Save($fullOut, [System.Drawing.Imaging.ImageFormat]::Png)
$g.Dispose()
$combo.Dispose()
$img1.Dispose()
$img2.Dispose()
Write-Host "Composite dual evidence saved successfully: $finalScreenshot"
# ------------------------------------------------------------------------------
# Final Conclusion
# ------------------------------------------------------------------------------
$passAll = $hasColName -and $hasFatima -and $hasScore92 -and $hasStatusHot -and $hasProfileFatima -and $hasProfileScore -and $hasDubaiTrack
Write-Host "`n=================================================================="
if ($passAll) {
Write-Host "[BTP-19 TEST RESULT]: [PASS] Lead Scoring Algorithm and Profile Test Passed!"
} else {
Write-Host "[BTP-19 TEST RESULT]: [FAIL] One or more assertions failed!"
}
Write-Host "Evidence file: $finalScreenshot"
Write-Host "=================================================================="