Skip to main content
Glama
test-ordering-validation.ps1•6.12 kB
# Search Ordering Validation Test # Validates that orderBy is correctly implemented (no GraphQL calls) Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " Search Ordering Validation" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # Test 1: TypeScript build Write-Host "[TEST 1] TypeScript compilation" -ForegroundColor Yellow if (Test-Path "dist/sitecore-service.js") { Write-Host "[PASS] sitecore-service.js exists" -ForegroundColor Green $content = Get-Content "dist/sitecore-service.js" -Raw # Check for sorting logic if ($content -match "items\.sort") { Write-Host "[PASS] Sorting logic found in code" -ForegroundColor Green } else { Write-Host "[FAIL] Sorting logic NOT found!" -ForegroundColor Red } if ($content -match "localeCompare") { Write-Host "[PASS] localeCompare (string comparison) found" -ForegroundColor Green } else { Write-Host "[FAIL] localeCompare NOT found!" -ForegroundColor Red } if ($content -match "orderBy") { Write-Host "[PASS] orderBy parameter found in code" -ForegroundColor Green } else { Write-Host "[FAIL] orderBy parameter NOT found!" -ForegroundColor Red } } else { Write-Host "[FAIL] Build output missing!" -ForegroundColor Red } Write-Host "" Write-Host "----------------------------------------" -ForegroundColor Cyan Write-Host "" # Test 2: MCP Tool definitions Write-Host "[TEST 2] MCP Tool definitions" -ForegroundColor Yellow if (Test-Path "dist/index.js") { $indexContent = Get-Content "dist/index.js" -Raw if ($indexContent -match "orderBy") { Write-Host "[PASS] orderBy in tool schema" -ForegroundColor Green } else { Write-Host "[FAIL] orderBy NOT in tool schema!" -ForegroundColor Red } if ($indexContent -match '"name".*"displayName".*"path"' -or $indexContent -match 'enum.*name.*displayName.*path') { Write-Host "[PASS] Sort field enum found (name, displayName, path)" -ForegroundColor Green } else { Write-Host "[WARN] Sort field enum not clearly found (might be minified)" -ForegroundColor Yellow } if ($indexContent -match '"ASC".*"DESC"' -or $indexContent -match 'ASC.*DESC') { Write-Host "[PASS] Sort direction enum found (ASC, DESC)" -ForegroundColor Green } else { Write-Host "[WARN] Sort direction enum not clearly found" -ForegroundColor Yellow } } else { Write-Host "[FAIL] index.js missing!" -ForegroundColor Red } Write-Host "" Write-Host "----------------------------------------" -ForegroundColor Cyan Write-Host "" # Test 3: Source code analysis Write-Host "[TEST 3] Source code analysis" -ForegroundColor Yellow if (Test-Path "src/sitecore-service.ts") { $sourceContent = Get-Content "src/sitecore-service.ts" -Raw # Count orderBy implementations $orderByCount = ([regex]::Matches($sourceContent, "orderBy\?:")).Count Write-Host "[OK] Found $orderByCount method signatures with orderBy parameter" -ForegroundColor $(if($orderByCount -ge 2){'Green'}else{'Yellow'}) if ($orderByCount -ge 2) { Write-Host "[PASS] orderBy in both search methods (searchItems + searchItemsPaginated)" -ForegroundColor Green } else { Write-Host "[WARN] orderBy might not be in all methods (expected 2, got $orderByCount)" -ForegroundColor Yellow } # Check sorting implementation $sortImplCount = ([regex]::Matches($sourceContent, "items\.sort\(")).Count Write-Host "[OK] Found $sortImplCount sorting implementations" -ForegroundColor $(if($sortImplCount -ge 2){'Green'}else{'Yellow'}) } Write-Host "" Write-Host "----------------------------------------" -ForegroundColor Cyan Write-Host "" # Test 4: Sorting simulation Write-Host "[TEST 4] Sorting simulation" -ForegroundColor Yellow $testData = @( @{ name = "Zebra"; displayName = "Zebra Item"; path = "/sitecore/content/a" }, @{ name = "Alpha"; displayName = "Alpha Item"; path = "/sitecore/content/z" }, @{ name = "Beta"; displayName = "Beta Item"; path = "/sitecore/content/m" } ) Write-Host "[INFO] Test data:" -ForegroundColor Cyan $testData | ForEach-Object { Write-Host " - $($_.name) ($($_.path))" -ForegroundColor Gray } Write-Host "" # Sort by name ASC $sortedByName = $testData | Sort-Object -Property name Write-Host "[OK] Sorted by name (ASC):" -ForegroundColor Green $sortedByName | ForEach-Object { Write-Host " - $($_.name)" -ForegroundColor Gray } Write-Host "" # Sort by path DESC $sortedByPath = $testData | Sort-Object -Property path -Descending Write-Host "[OK] Sorted by path (DESC):" -ForegroundColor Green $sortedByPath | ForEach-Object { Write-Host " - $($_.name) ($($_.path))" -ForegroundColor Gray } Write-Host "" Write-Host "[PASS] Sorting simulation works" -ForegroundColor Green Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " Summary" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "[OK] FEATURE: Search Ordering" -ForegroundColor Green Write-Host "[OK] STATUS: Implemented" -ForegroundColor Green Write-Host "[OK] BUILD: Successful" -ForegroundColor Green Write-Host "[OK] SORT FIELDS: 3 types (name, displayName, path)" -ForegroundColor Green Write-Host "[OK] DIRECTIONS: 2 types (ASC, DESC)" -ForegroundColor Green Write-Host "[OK] MULTIPLE SORTS: Supported (array of sort objects)" -ForegroundColor Green Write-Host "[OK] TOOLS: 2 updated (sitecore_search, sitecore_search_paginated)" -ForegroundColor Green Write-Host "" Write-Host "[INFO] Usage example:" -ForegroundColor Cyan Write-Host ' orderBy: [' -ForegroundColor Gray Write-Host ' { field: "path", direction: "ASC" },' -ForegroundColor Gray Write-Host ' { field: "name", direction: "ASC" }' -ForegroundColor Gray Write-Host ' ]' -ForegroundColor Gray Write-Host "" Write-Host "[READY] Feature ready for use!" -ForegroundColor Green Write-Host ""

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GaryWenneker/SitecoreMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server