@@ -68,11 +68,65 @@ Describe 'GitHubIntake.psm1' {
6868 $route.targetKey | Should - Be ' human-change'
6969 $route.targetPath | Should - Be ' .github/PULL_REQUEST_TEMPLATE/human-change.md'
7070 $route.helperPath | Should - Be ' tools/New-GitHubIntakeDraft.ps1'
71- $route.executeCommand | Should - Be ' gh pr create --title "<title>" --body-file pr-body.md'
72- $route.executionKind | Should - Be ' gh -pr-create'
71+ $route.executeCommand | Should - Be ' node tools/npm/run-script.mjs priority: pr -- --issue <number> --repo <owner/repo> --branch <branch> --base <base> --title "<title>" --body-file pr-body.md'
72+ $route.executionKind | Should - Be ' priority -pr-create'
7373 $route.execution.branchSource | Should - Be ' current-or-input'
7474 }
7575
76+ It ' normalizes legacy gh-pr-create execution kinds to the priority helper contract' {
77+ $catalogPath = Join-Path $TestDrive ' github-intake-catalog.json'
78+ @'
79+ {
80+ "schema": "github-intake/catalog@v1",
81+ "issueTemplates": [],
82+ "pullRequestTemplates": [
83+ {
84+ "key": "human-change",
85+ "path": ".github/PULL_REQUEST_TEMPLATE/human-change.md",
86+ "templateLabel": "human-change",
87+ "metadataMode": "human",
88+ "summary": "Human-authored PR template."
89+ }
90+ ],
91+ "contactLinks": [],
92+ "routes": [
93+ {
94+ "scenario": "legacy-human-pr",
95+ "routeType": "pull-request-template",
96+ "targetKey": "human-change",
97+ "helperPath": "tools/New-GitHubIntakeDraft.ps1",
98+ "command": "pwsh -File tools/New-GitHubIntakeDraft.ps1 -Scenario legacy-human-pr -OutputPath pr-body.md",
99+ "executeCommand": "gh pr create --title \"<title>\" --body-file pr-body.md",
100+ "execution": {
101+ "kind": "gh-pr-create",
102+ "titleSource": "issue-derived",
103+ "bodySource": "draft-output",
104+ "baseSource": "input-or-default",
105+ "branchSource": "current-or-input",
106+ "issueSource": "input-or-snapshot"
107+ },
108+ "summary": "Legacy route."
109+ }
110+ ]
111+ }
112+ '@ | Set-Content - LiteralPath $catalogPath - Encoding utf8
113+
114+ $previous = $env: COMPAREVI_GITHUB_INTAKE_CATALOG_PATH
115+ try {
116+ $env: COMPAREVI_GITHUB_INTAKE_CATALOG_PATH = $catalogPath
117+ $route = Resolve-GitHubIntakeRoute - Scenario ' legacy-human-pr'
118+ } finally {
119+ if ($null -eq $previous ) {
120+ Remove-Item Env:COMPAREVI_GITHUB_INTAKE_CATALOG_PATH - ErrorAction SilentlyContinue
121+ } else {
122+ $env: COMPAREVI_GITHUB_INTAKE_CATALOG_PATH = $previous
123+ }
124+ }
125+
126+ $route.executionKind | Should - Be ' priority-pr-create'
127+ $route.execution.kind | Should - Be ' priority-pr-create'
128+ }
129+
76130 It ' resolves an issue snapshot from the override directory when present' {
77131 $snapshotDir = Join-Path $TestDrive ' issue'
78132 New-Item - ItemType Directory - Path $snapshotDir - Force | Out-Null
@@ -95,6 +149,35 @@ Describe 'GitHubIntake.psm1' {
95149 $snapshot.title | Should - Be ' Catalog issue'
96150 }
97151
152+ It ' falls back to GitHub issue lookup when no local snapshot exists for an explicit issue' {
153+ Mock - ModuleName GitHubIntake Resolve-GitHubIssueSnapshotFromGitHub {
154+ param ([int ]$Issue )
155+ [pscustomobject ]@ {
156+ number = $Issue
157+ title = ' Live catalog issue'
158+ url = ' https://example.test/issues/963'
159+ labels = @ (' enhancement' )
160+ }
161+ }
162+
163+ $snapshotDir = Join-Path $TestDrive ' missing-issue-dir'
164+ $previous = $env: COMPAREVI_GITHUB_INTAKE_SNAPSHOT_DIR
165+ try {
166+ $env: COMPAREVI_GITHUB_INTAKE_SNAPSHOT_DIR = $snapshotDir
167+ $snapshot = Resolve-GitHubIssueSnapshot - Issue 963
168+ } finally {
169+ if ($null -eq $previous ) {
170+ Remove-Item Env:COMPAREVI_GITHUB_INTAKE_SNAPSHOT_DIR - ErrorAction SilentlyContinue
171+ } else {
172+ $env: COMPAREVI_GITHUB_INTAKE_SNAPSHOT_DIR = $previous
173+ }
174+ }
175+
176+ $snapshot.number | Should - Be 963
177+ $snapshot.title | Should - Be ' Live catalog issue'
178+ Should - Invoke Resolve-GitHubIssueSnapshotFromGitHub - ModuleName GitHubIntake - Times 1 - Exactly
179+ }
180+
98181 It ' loads the intake catalog from the override path when present' {
99182 $catalogPath = Join-Path $TestDrive ' github-intake-catalog.json'
100183 @'
@@ -184,6 +267,24 @@ Describe 'GitHubIntake.psm1' {
184267 $context.snapshotResolved | Should - BeTrue
185268 }
186269
270+ It ' treats label objects from live snapshots as standing-priority markers' {
271+ Mock - ModuleName GitHubIntake Resolve-GitHubIssueSnapshot {
272+ [pscustomobject ]@ {
273+ number = 963
274+ title = ' Live GH issue'
275+ url = ' https://example.test/issues/963'
276+ labels = @ ([pscustomobject ]@ { name = ' standing-priority' })
277+ }
278+ }
279+
280+ $context = Resolve-GitHubIntakeDraftContext - Scenario ' human-pr' - Issue 963 - CurrentBranch ' issue/963-org-owned-fork-pr-helper'
281+
282+ $context.issueTitle | Should - Be ' Live GH issue'
283+ $context.issueUrl | Should - Be ' https://example.test/issues/963'
284+ $context.standingPriority | Should - BeTrue
285+ $context.snapshotResolved | Should - BeTrue
286+ }
287+
187288 It ' preserves a null execute command when the catalog route omits it' {
188289 $catalogPath = Join-Path $TestDrive ' github-intake-catalog.json'
189290 @'
0 commit comments