--- name: orchardcore-tester description: Tests OrchardCore CMS features through browser automation. Use when the user needs to build, run, setup, or test OrchardCore functionality including admin features, content management, media library, and module testing. --- # OrchardCore Feature Testing This skill guides you through testing OrchardCore CMS features using browser automation with `playwright-cli`. ## Prerequisites - OrchardCore repository (working directory) - .NET SDK 10.0+ installed - `playwright-cli` skill available, with a browser engine installed. On macOS (or any machine without Chrome) use webkit: ```bash playwright-cli --browser webkit install ``` Then pass `--browser webkit` on the first `open` of a session. See `references/playwright-cli.md`. > The examples below show PowerShell and bash. The repo targets macOS/.NET 10; > bash works everywhere. Use whichever matches your shell. ## Core Workflow Testing an OrchardCore feature follows these steps: 1. **Build** the application 2. **Run** the application server (background) 3. **Setup** a test site (AutoSetup is the recommended unattended path) 4. **Test** the feature via browser 5. **Verify** results and clean up ## TL;DR (fastest reliable path) ```bash # 1. build dotnet build src/OrchardCore.Cms.Web -c Debug -f net10.0 # 2. fresh state + pick a port rm -rf src/OrchardCore.Cms.Web/App_Data PORT=$(( (RANDOM % 1000) + 5000 )); echo -n $PORT > .orchardcore-port # 3. run with AutoSetup (provisions Default tenant on first request, no wizard) cd src/OrchardCore.Cms.Web OrchardCore__OrchardCore_AutoSetup__AutoSetupPath= \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__ShellName=Default \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__SiteName=TestSite \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__SiteTimeZone=America/Los_Angeles \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__AdminUsername=admin \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__AdminEmail=admin@test.com \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__AdminPassword=Password1! \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__DatabaseProvider=Sqlite \ OrchardCore__OrchardCore_AutoSetup__Tenants__0__RecipeName=Blog \ dotnet run -f net10.0 --no-build --urls "http://localhost:$PORT" > autosetup-console.log 2>&1 & cd ../.. # 4. trigger + confirm curl -s -o /dev/null "http://localhost:$PORT/" grep -m1 "successfully provisioned" src/OrchardCore.Cms.Web/autosetup-console.log ``` Then log in (see Step 4 — the login password field needs the native-setter workaround). Full AutoSetup details and gotchas: `references/autosetup.md`. ## Step 1: Build ```powershell dotnet build src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj -c Debug -f net10.0 ``` ## Step 2: Run Application (Background) Since multiple agents may run OrchardCore from different worktrees simultaneously, use a random port and run in background. ### Get or Create Session Port ```powershell # Check for existing port file, or generate random port (5000-5999) $portFile = ".orchardcore-port" if (Test-Path $portFile) { $port = Get-Content $portFile } else { $port = Get-Random -Minimum 5000 -Maximum 6000 $port | Out-File $portFile -NoNewline } Write-Host "Using port: $port" ``` ### Start Application in Background ```powershell # Start OrchardCore in background process $proc = Start-Process dotnet ` -ArgumentList "run","-f","net10.0","--no-build","--urls","http://localhost:$port" ` -WorkingDirectory "src/OrchardCore.Cms.Web" ` -PassThru -NoNewWindow # Save PID for later cleanup $proc.Id | Out-File ".orchardcore-pid" -NoNewline Write-Host "Started OrchardCore (PID: $($proc.Id)) on http://localhost:$port" ``` ### Wait for Application Ready ```powershell # Poll until app responds (max 60 seconds) $port = Get-Content ".orchardcore-port" $timeout = 60; $elapsed = 0 while ($elapsed -lt $timeout) { try { $response = Invoke-WebRequest -Uri "http://localhost:$port" -UseBasicParsing -TimeoutSec 2 Write-Host "Application ready at http://localhost:$port" break } catch { Start-Sleep -Seconds 2 $elapsed += 2 } } ``` ### Stop Application ```powershell # Stop the background process if (Test-Path ".orchardcore-pid") { $pid = Get-Content ".orchardcore-pid" Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue Remove-Item ".orchardcore-pid" -Force Write-Host "Stopped OrchardCore (PID: $pid)" } ``` ```bash # bash: find the process actually listening on the port and kill it. # (Backgrounding dotnet via a subshell makes $! unreliable, so resolve by port.) PORT=$(cat .orchardcore-port) PID=$(lsof -ti tcp:$PORT -sTCP:LISTEN | head -1) [ -n "$PID" ] && kill "$PID" && echo "Stopped OrchardCore (PID: $PID)" rm -f .orchardcore-pid ``` ## Step 3: Setup Test Site A fresh `App_Data` is uninitialized, so the site must be provisioned. There are two paths. ### Option A — AutoSetup (recommended, unattended) Provision the `Default` tenant from configuration on first request — **no browser, no wizard**. `OrchardCore.Cms.Web` already wires AutoSetup in (`Program.cs` → `.AddSetupFeatures("OrchardCore.AutoSetup")`); you just supply env vars when starting the app (see the TL;DR above, or run them inline with `dotnet run` from Step 2). Key rules (full details in `references/autosetup.md`): - Prefix is `OrchardCore__OrchardCore_AutoSetup__Tenants__0__