test-excel-pack.ps1 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Test script for Excel transformation pack
  2. Write-Host "Testing Excel Transformation Pack API..." -ForegroundColor Cyan
  3. # Test 1: Get pack data
  4. Write-Host ""
  5. Write-Host "1. Fetching pack data..." -ForegroundColor Yellow
  6. try {
  7. $packResponse = Invoke-RestMethod -Uri "http://127.0.0.1:8765/api/pack.php?pack=transformation-excel" -Method GET
  8. Write-Host " OK Pack ID: $($packResponse.pack_id)" -ForegroundColor Green
  9. Write-Host " OK Title: $($packResponse.pack_title)" -ForegroundColor Green
  10. Write-Host " OK Questions: $($packResponse.questions.Count)" -ForegroundColor Green
  11. Write-Host " OK Pillars: $($packResponse.pillars.Count)" -ForegroundColor Green
  12. }
  13. catch {
  14. Write-Host " ERROR Failed to fetch pack: $_" -ForegroundColor Red
  15. exit 1
  16. }
  17. # Test 2: Submit high-severity answers
  18. Write-Host ""
  19. Write-Host "2. Submitting high-severity answers..." -ForegroundColor Yellow
  20. $answersData = @{
  21. pack_id = "transformation-excel"
  22. answers = @{
  23. X1 = "x1_3"
  24. X2 = "x2_3"
  25. X3 = "x3_3"
  26. X4 = "x4_3"
  27. X5 = "x5_3"
  28. X6 = "x6_3"
  29. X7 = "x7_3"
  30. X8 = "x8_3"
  31. X9 = "x9_3"
  32. X10 = "x10_3"
  33. X11 = "x11_3"
  34. X12 = "x12_3"
  35. X13 = "x13_3"
  36. X14 = "x14_3"
  37. }
  38. optional = @{}
  39. }
  40. $jsonBody = $answersData | ConvertTo-Json -Depth 10
  41. try {
  42. $scoreResponse = Invoke-RestMethod -Uri "http://127.0.0.1:8765/api/score.php" -Method POST -Body $jsonBody -ContentType "application/json"
  43. Write-Host " OK Score: $($scoreResponse.score_total)/100" -ForegroundColor Green
  44. Write-Host " OK Level: $($scoreResponse.level) - $($scoreResponse.level_label)" -ForegroundColor Green
  45. Write-Host " OK Pillars:" -ForegroundColor Green
  46. foreach ($p in $scoreResponse.pillars) {
  47. Write-Host " - $($p.label): $($p.score)/$($p.max)" -ForegroundColor Gray
  48. }
  49. if ($scoreResponse.excel_diagnostic) {
  50. $xd = $scoreResponse.excel_diagnostic
  51. Write-Host " OK Excel Diagnostic:" -ForegroundColor Green
  52. Write-Host " - Douleur: $($xd.douleur)/100" -ForegroundColor Gray
  53. Write-Host " - Complexite: $($xd.complexite)/100" -ForegroundColor Gray
  54. Write-Host " - Verdict: $($xd.verdict.label)" -ForegroundColor Gray
  55. Write-Host " - Tag: $($xd.tag_label)" -ForegroundColor Gray
  56. }
  57. else {
  58. Write-Host " ERROR Excel diagnostic missing!" -ForegroundColor Red
  59. }
  60. Write-Host " OK Quick wins: $($scoreResponse.quick_wins_top5.Count)" -ForegroundColor Green
  61. Write-Host " OK Risks: $($scoreResponse.risks_top3.Count)" -ForegroundColor Green
  62. }
  63. catch {
  64. Write-Host " ERROR Failed to score: $_" -ForegroundColor Red
  65. exit 1
  66. }
  67. Write-Host ""
  68. Write-Host "SUCCESS All tests passed!" -ForegroundColor Green