no-real-llm.test.ts 978 B

123456789101112131415161718192021222324252627
  1. import { describe, expect, test } from "bun:test"
  2. import path from "node:path"
  3. import { fileURLToPath } from "node:url"
  4. const dir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../e2e")
  5. function hasPrompt(src: string) {
  6. if (!src.includes("withProject(")) return false
  7. if (src.includes("withNoReplyPrompt(")) return false
  8. if (src.includes("session.promptAsync({") && !src.includes("noReply: true")) return true
  9. if (!src.includes("promptSelector")) return false
  10. return src.includes('keyboard.press("Enter")') || src.includes('prompt.press("Enter")')
  11. }
  12. describe("e2e llm guard", () => {
  13. test("withProject specs do not submit prompt replies", async () => {
  14. const bad: string[] = []
  15. for await (const file of new Bun.Glob("**/*.spec.ts").scan({ cwd: dir, absolute: true })) {
  16. const src = await Bun.file(file).text()
  17. if (!hasPrompt(src)) continue
  18. bad.push(path.relative(dir, file))
  19. }
  20. expect(bad).toEqual([])
  21. })
  22. })