MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestHookPromptSubmitShowsContextAndProgress

Function TestHookPromptSubmitShowsContextAndProgress

cmd/hooks_more_test.go:397–444  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func TestHookPromptSubmitShowsContextAndProgress(t *testing.T) {
398 root := t.TempDir()
399 writeProjectConfig(t, root, config.ProjectConfig{
400 Routing: config.RoutingConfig{
401 Retrieval: config.RetrievalConfig{Strategy: "keyword", TopK: 2},
402 Subsystems: []config.Subsystem{
403 {
404 ID: "watching",
405 Keywords: []string{"hook", "daemon", "events"},
406 Docs: []string{"docs/HOOKS.md"},
407 },
408 },
409 },
410 })
411 writeWatchState(t, root, watch.State{
412 UpdatedAt: time.Now(),
413 FileCount: 5,
414 Importers: map[string][]string{
415 "pkg/types.go": {"a.go", "b.go", "c.go"},
416 },
417 RecentEvents: []watch.Event{
418 {Path: "pkg/types.go", Op: "WRITE", IsHub: true},
419 {Path: "cmd/run.go", Op: "WRITE"},
420 },
421 })
422
423 withStdinInput(t, mustJSONInput(t, map[string]string{
424 "prompt": "please inspect pkg/types.go because hook daemon events are noisy",
425 }), func() {
426 var hookErr error
427 out := captureOutput(func() { hookErr = hookPromptSubmit(root) })
428 if hookErr != nil {
429 t.Fatalf("hookPromptSubmit() error: %v", hookErr)
430 }
431 checks := []string{
432 "Context for mentioned files",
433 "pkg/types.go is a HUB",
434 "Suggested context routes",
435 "watching",
436 "Session so far: 2 files edited, 1 hub edits",
437 }
438 for _, check := range checks {
439 if !strings.Contains(out, check) {
440 t.Fatalf("expected %q in output, got:\n%s", check, out)
441 }
442 }
443 })
444}
445
446func TestHookPromptSubmitInjectsConfigSetupSkillWhenConfigMissing(t *testing.T) {
447 root := t.TempDir()

Callers

nothing calls this directly

Calls 6

writeProjectConfigFunction · 0.85
writeWatchStateFunction · 0.85
withStdinInputFunction · 0.85
mustJSONInputFunction · 0.85
captureOutputFunction · 0.85
hookPromptSubmitFunction · 0.85

Tested by

no test coverage detected