| 1 | package headless |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | ) |
| 9 | |
| 10 | func TestHeadlessStagingPlacement(t *testing.T) { |
| 11 | env, _, r := localEnv(t) |
| 12 | r.start(t) |
| 13 | s := open(t, env) |
| 14 | // Create a real repository as a fixture; the staging assertion must reject |
| 15 | // that outcome when its request did not consent to a new repository. |
| 16 | for _, tc := range []struct { |
| 17 | name, prompt, want string |
| 18 | required bool |
| 19 | }{ |
| 20 | {"question", "tool:ask_person:Where should it go?|oficina/sample|Elsewhere", "", false}, |
| 21 | {"named project", "tool:add_project:oficina/sample", "", false}, |
| 22 | {"clarification", "tool:add_project:oficina/sample\ntool:ask_person:Which README words should change?|Title|Summary", "", true}, |
| 23 | {"missing card", "tool:ask_person:Which README words should change?|Title|Summary", "missing project card", true}, |
| 24 | {"unauthorized creation", "Create a new project called oficina/suite-site", "created without consent", false}, |
| 25 | {"wrong project", "tool:add_project:oficina/notes", "unnamed project", false}, |
| 26 | } { |
| 27 | t.Run(tc.name, func(t *testing.T) { |
| 28 | sent := s.send(t, tc.prompt) |
| 29 | s.waitTurn(t, sent.Turn.ID, wire.TurnReplied) |
| 30 | err := s.placement(sent.Turn.ID, []string{"oficina/sample"}, tc.required) |
| 31 | if tc.want == "" { |
| 32 | if err != nil { |
| 33 | t.Fatal(err) |
| 34 | } |
| 35 | return |
| 36 | } |
| 37 | if err == nil || !strings.Contains(err.Error(), tc.want) { |
| 38 | t.Fatalf("guard = %v, want %q", err, tc.want) |
| 39 | } |
| 40 | }) |
| 41 | } |
| 42 | } |
| 43 | |