191 行
9.5 KiB
PowerShell
191 行
9.5 KiB
PowerShell
# ==============================================================================
|
|
# BTP-18 Pipeline Kanban & Stage Transition End-to-End Test
|
|
# ==============================================================================
|
|
$session = "btp18"
|
|
$evidenceDir = "docs/test-evidence/round-5"
|
|
$screenshotPath = "$evidenceDir/btp-18-crm-pipeline.png"
|
|
$initScript = "docs/test-evidence/round-5/browser-init.js"
|
|
|
|
Write-Host "=================================================================="
|
|
Write-Host "BTP-18 Pipeline Kanban and Stage Transition Test"
|
|
Write-Host "Session ID: $session"
|
|
Write-Host "Screenshot: $screenshotPath"
|
|
Write-Host "=================================================================="
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Step 1: Login
|
|
# ------------------------------------------------------------------------------
|
|
Write-Host "`n>>> [Step 1/5] Login to http://localhost:5173/login ..."
|
|
agent-browser --session $session open "http://localhost:5173/login" --init-script $initScript
|
|
Start-Sleep -Seconds 1
|
|
agent-browser --session $session click "button.arco-btn-primary"
|
|
Start-Sleep -Seconds 2
|
|
$loginUrl = agent-browser --session $session get url
|
|
Write-Host "Logged in. URL: $loginUrl"
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Step 2: Navigate to Pipeline Kanban
|
|
# ------------------------------------------------------------------------------
|
|
Write-Host "`n>>> [Step 2/5] Navigate to http://localhost:5173/crm/pipeline ..."
|
|
agent-browser --session $session open "http://localhost:5173/crm/pipeline" --init-script $initScript
|
|
Start-Sleep -Seconds 3
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Step 3: Check 5 Core Kanban Lanes and Lead Cards
|
|
# ------------------------------------------------------------------------------
|
|
Write-Host "`n>>> [Step 3/5] Capture initial snapshot of 5 Kanban lanes and cards ..."
|
|
$initialSnapshot = agent-browser --session $session snapshot -i
|
|
Write-Host "--- Initial Kanban DOM Snapshot ---"
|
|
Write-Host $initialSnapshot
|
|
|
|
# 5 Core lanes verification
|
|
$hasNew = $initialSnapshot -match "New"
|
|
$hasContacted = $initialSnapshot -match "Contacted"
|
|
$hasHot = $initialSnapshot -match "Hot"
|
|
$hasWon = $initialSnapshot -match "Won"
|
|
$hasArchived = $initialSnapshot -match "Archived"
|
|
|
|
Write-Host "`n[Kanban Lanes Verification]:"
|
|
Write-Host "1. New Lane: $(if ($hasNew) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "2. Contacted Lane: $(if ($hasContacted) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "3. Hot Lane: $(if ($hasHot) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "4. Won Lane: $(if ($hasWon) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "5. Archived Lane: $(if ($hasArchived) { '[PASS]' } else { '[FAIL]' })"
|
|
|
|
# Lead cards information verification
|
|
$hasJohn = $initialSnapshot -match "John Doe"
|
|
$hasAisha = $initialSnapshot -match "Aisha Al-Mansoor"
|
|
$hasKenji = $initialSnapshot -match "Kenji Sato"
|
|
$hasElena = $initialSnapshot -match "Elena Rostova"
|
|
$hasMarcus = $initialSnapshot -match "Marcus Vance"
|
|
|
|
Write-Host "`n[Lead Card Customers Verification]:"
|
|
Write-Host "John Doe (New): $(if ($hasJohn) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "Aisha Al-Mansoor (Contacted): $(if ($hasAisha) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "Kenji Sato (Hot): $(if ($hasKenji) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "Elena Rostova (Won): $(if ($hasElena) { '[PASS]' } else { '[FAIL]' })"
|
|
Write-Host "Marcus Vance (Archived): $(if ($hasMarcus) { '[PASS]' } else { '[FAIL]' })"
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Step 4: Verify Filtering & Stage Transition Interaction
|
|
# ------------------------------------------------------------------------------
|
|
Write-Host "`n>>> [Step 4/5] Verify Filtering & Stage Transition Interaction ..."
|
|
|
|
# 4.1 Keyword filtering: Search "John"
|
|
Write-Host "--- Test 4.1: Keyword filter (John) ---"
|
|
agent-browser --session $session eval "(() => {
|
|
const inputs = Array.from(document.querySelectorAll('input'));
|
|
const kw = inputs.find(i => i.placeholder && i.placeholder.includes('name'));
|
|
if (kw) {
|
|
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
setter.call(kw, 'John');
|
|
kw.dispatchEvent(new Event('input', { bubbles: true }));
|
|
kw.dispatchEvent(new Event('change', { bubbles: true }));
|
|
}
|
|
const btns = Array.from(document.querySelectorAll('button'));
|
|
const refreshBtn = btns.find(b => b.textContent.includes('Refresh'));
|
|
if (refreshBtn) { refreshBtn.click(); }
|
|
})()"
|
|
Start-Sleep -Seconds 2
|
|
$kwSnapshot = agent-browser --session $session snapshot -i
|
|
$filterKwPass = ($kwSnapshot -match "John Doe") -and (-not ($kwSnapshot -match "Kenji Sato"))
|
|
Write-Host "Keyword Filter: $(if ($filterKwPass) { '[PASS] Matched John Doe exclusively' } else { '[FAIL]' })"
|
|
|
|
# 4.2 Card ID filter: Clear kw and set Card ID = 1
|
|
Write-Host "--- Test 4.2: Card ID filter (Card ID = 1) ---"
|
|
agent-browser --session $session eval "(() => {
|
|
const inputs = Array.from(document.querySelectorAll('input'));
|
|
const kw = inputs.find(i => i.placeholder && i.placeholder.includes('name'));
|
|
if (kw) {
|
|
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
setter.call(kw, '');
|
|
kw.dispatchEvent(new Event('input', { bubbles: true }));
|
|
kw.dispatchEvent(new Event('change', { bubbles: true }));
|
|
}
|
|
const cardIdInput = inputs.find(i => i.placeholder && i.placeholder.includes('card'));
|
|
if (cardIdInput) {
|
|
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
setter.call(cardIdInput, '1');
|
|
cardIdInput.dispatchEvent(new Event('input', { bubbles: true }));
|
|
cardIdInput.dispatchEvent(new Event('change', { bubbles: true }));
|
|
}
|
|
const btns = Array.from(document.querySelectorAll('button'));
|
|
const refreshBtn = btns.find(b => b.textContent.includes('Refresh'));
|
|
if (refreshBtn) { refreshBtn.click(); }
|
|
})()"
|
|
Start-Sleep -Seconds 2
|
|
$cardSnapshot = agent-browser --session $session snapshot -i
|
|
$filterCardPass = ($cardSnapshot -match "John Doe") -and ($cardSnapshot -match "Aisha Al-Mansoor")
|
|
Write-Host "Card ID Filter: $(if ($filterCardPass) { '[PASS] Matched Card #1 leads successfully' } else { '[FAIL]' })"
|
|
|
|
# 4.3 Reset filters & Trigger Stage Transition
|
|
Write-Host "--- Test 4.3: Reset filters & Stage Transition (John Doe -> Hot) ---"
|
|
agent-browser --session $session eval "(() => {
|
|
const inputs = Array.from(document.querySelectorAll('input'));
|
|
inputs.forEach(input => {
|
|
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
setter.call(input, '');
|
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
});
|
|
const btns = Array.from(document.querySelectorAll('button'));
|
|
const refreshBtn = btns.find(b => b.textContent.includes('Refresh'));
|
|
if (refreshBtn) { refreshBtn.click(); }
|
|
})()"
|
|
Start-Sleep -Seconds 2
|
|
|
|
# Transition lead #101 to 'hot'
|
|
agent-browser --session $session eval "(() => {
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/api/admin/crm/lead/updateStatus');
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.send(JSON.stringify({ id: 101, status: 'hot' }));
|
|
})()"
|
|
Start-Sleep -Milliseconds 500
|
|
agent-browser --session $session eval "(() => {
|
|
const btns = Array.from(document.querySelectorAll('button'));
|
|
const refreshBtn = btns.find(b => b.textContent.includes('Refresh'));
|
|
if (refreshBtn) { refreshBtn.click(); }
|
|
})()"
|
|
Start-Sleep -Seconds 2
|
|
$transitionSnapshot = agent-browser --session $session snapshot -i
|
|
$transitionPass = ($transitionSnapshot -match "Hot") -and ($transitionSnapshot -match "John Doe")
|
|
Write-Host "Stage Transition Interaction: $(if ($transitionPass) { '[PASS] Status transition triggered and board updated' } else { '[FAIL]' })"
|
|
|
|
# Reset back to initial 5-lane distribution for canonical screenshot
|
|
agent-browser --session $session eval "(() => {
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/api/admin/crm/lead/updateStatus');
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.send(JSON.stringify({ id: 101, status: 'new' }));
|
|
})()"
|
|
Start-Sleep -Milliseconds 500
|
|
agent-browser --session $session eval "(() => {
|
|
const btns = Array.from(document.querySelectorAll('button'));
|
|
const refreshBtn = btns.find(b => b.textContent.includes('Refresh'));
|
|
if (refreshBtn) { refreshBtn.click(); }
|
|
})()"
|
|
Start-Sleep -Seconds 2
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Step 5: Capture Full Evidence Screenshot
|
|
# ------------------------------------------------------------------------------
|
|
Write-Host "`n>>> [Step 5/5] Capture full evidence screenshot to $screenshotPath ..."
|
|
agent-browser --session $session screenshot --full $screenshotPath
|
|
Write-Host "Screenshot saved: $screenshotPath"
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Conclusion
|
|
# ------------------------------------------------------------------------------
|
|
$passAll = $hasNew -and $hasContacted -and $hasHot -and $hasWon -and $hasArchived -and `
|
|
$hasJohn -and $hasAisha -and $hasKenji -and $hasElena -and $hasMarcus -and `
|
|
$filterKwPass -and $filterCardPass -and $transitionPass
|
|
|
|
Write-Host "`n=================================================================="
|
|
if ($passAll) {
|
|
Write-Host "[FINAL RESULT]: PASS - All BTP-18 Pipeline Kanban tests passed successfully!"
|
|
} else {
|
|
Write-Host "[FINAL RESULT]: FAIL - Verification failed."
|
|
}
|
|
Write-Host "=================================================================="
|