Files
compound-engineering-plugin…/tests/commit-push-pr-contract.test.ts

50 lines
2.5 KiB
TypeScript

import { readFile } from "fs/promises"
import path from "path"
import { describe, expect, test } from "bun:test"
async function readRepoFile(relativePath: string): Promise<string> {
return readFile(path.join(process.cwd(), relativePath), "utf8")
}
describe("ce-commit-push-pr contract", () => {
test("existing PR rewrites carry the old body into composition", async () => {
const content = await readRepoFile("skills/ce-commit-push-pr/SKILL.md")
expect(content).toContain("gh pr view --json url,title,body,state")
expect(content).toContain("Note the existing PR URL and body from the PR check")
expect(content).toContain("If Step 1 found an existing PR, pass its URL to Step 4")
expect(content).toContain("existing body")
expect(content).toMatch(/preserve.+Related.+Fixes/is)
})
test("requires related work references to use tracker-specific closing semantics", async () => {
const content = await readRepoFile(
"skills/ce-commit-push-pr/references/pr-description-writing.md",
)
expect(content).toContain("## Step B1: Resolve related work references")
expect(content).toContain("closing reference")
expect(content).toContain("non-closing reference")
expect(content).toContain("Do not invent a closing keyword")
expect(content).toMatch(/git log\s+--format=fuller/)
expect(content).toContain("full commit messages")
expect(content).toContain("Do not put a non-closing reference next to close/fix/resolve/address/report wording")
expect(content).toContain("Use the table's non-closing reference labels exactly")
expect(content).toContain("Non-closing references always get their own sentence or `## Related` block")
expect(content).toContain("For a non-closing reference, the tracker ID appears only in that related-reference sentence or block, never in the summary/opening/body prose")
expect(content).toContain('Bad: "closing one corruption path from #123"')
expect(content).toContain('Bad: "This addresses the retry-related corruption path reported in #123."')
expect(content).toContain('Good: "This covers the duplicate-row retry path; concurrent cancellation remains follow-up work."')
expect(content).toContain("GitHub Issues")
expect(content).toContain("Fixes #123")
expect(content).toContain("Fixes owner/repo#123")
expect(content).toMatch(/target.+default branch/i)
expect(content).toContain("Linear")
expect(content).toContain("Fixes ENG-123")
expect(content).toContain("Related to ENG-123")
expect(content).toMatch(/PR description.+not.+comment/i)
})
})