3 files changed,
+38
−2
internal/equipo/card_option_test.go
+14 −0
internal/equipo/chat/direction_options_test.go
+21 −0
internal/equipo/chat/explore.go
+3 −2
| index 7a87553e..cdbd7bed 100644 |
| --- a/internal/equipo/card_option_test.go |
| +++ b/internal/equipo/card_option_test.go |
| @@ -1,6 +1,7 @@ |
| package equipo |
| |
| import ( |
| + "fmt" |
| "net/http" |
| "net/http/httptest" |
| "net/url" |
| @@ -38,3 +39,16 @@ func TestFormOption(t *testing.T) { |
| t.Fatalf("no step: %+v", got) |
| } |
| } |
| + |
| +// TestBuildOptionCopy: the brief's option line is copy.go's |
| +// work.explore.build_option, taking the option's number, Design's name |
| +// for it (quoted), the branch, the commit and the folder. |
| +func TestBuildOptionCopy(t *testing.T) { |
| + text := copyText("work.explore.build_option") |
| + if text != "Build option %d (Design's name for it: %s), from branch %s at commit %s, folder %s." { |
| + t.Fatalf("work.explore.build_option is %q", text) |
| + } |
| + if got := fmt.Sprintf(text, 2, wire.QuotedData("Writing desk"), "equipo/tk1-x", "c0ffee0", "mockups/tk1/writing-desk/"); strings.Contains(got, "%!") { |
| + t.Fatalf("formatted %q", got) |
| + } |
| +} |
| index a745ebc2..347c67e2 100644 |
| --- a/internal/equipo/chat/direction_options_test.go |
| +++ b/internal/equipo/chat/direction_options_test.go |
| @@ -398,3 +398,24 @@ func TestFixRoundInheritsAsk(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// TestBuildOptionNeedsItsWords: the option line's words live only in |
| +// copy.go; with no copy for work.explore.build_option, Build this one |
| +// on an option builds nothing (never words of its own) and the card |
| +// stays open. |
| +func TestBuildOptionNeedsItsWords(t *testing.T) { |
| + r, _, task, s, c := roundOfThree(t) |
| + words := r.s.authority.Copy |
| + r.s.authority.Copy = func(key string) string { |
| + if key == "work.explore.build_option" { |
| + return "" |
| + } |
| + return words(key) |
| + } |
| + if err := r.answerCard(c, wire.AnswerCard{Choice: wire.ChoiceBuild, Option: &wire.OptionRef{Step: s.ID, Index: 1}}); !errors.Is(err, ErrInvalid) { |
| + t.Fatalf("Build with no words for the option: %v", err) |
| + } |
| + if k := r.load(task); k.BuiltAs != "" || r.openDirection(task).ID != c.ID { |
| + t.Fatalf("built %q", k.BuiltAs) |
| + } |
| +} |
| index d72e2ccc..b0d010f5 100644 |
| --- a/internal/equipo/chat/explore.go |
| +++ b/internal/equipo/chat/explore.go |
| @@ -4,7 +4,6 @@ import ( |
| "context" |
| "encoding/json" |
| "errors" |
| - "fmt" |
| "slices" |
| "strings" |
| |
| @@ -391,9 +390,11 @@ func (t *txn) buildThisOne(k *taskRecord, p progress, note string, chosen *chose |
| folder += chosen.Option.Page + "/" |
| } |
| name := wire.QuotedData(chosen.Option.Name) |
| + // Its words live only in copy.go: without them nothing names the |
| + // option, so nothing is built. |
| line := t.words("work.explore.build_option", chosen.Index+1, name, k.Branch, short(ref), folder) |
| if line == "" { |
| - line = fmt.Sprintf("Build option %d (Design's name for it: %s), from branch %s at commit %s, folder %s.", chosen.Index+1, name, k.Branch, short(ref), folder) |
| + return ErrInvalid |
| } |
| more += "\n\n" + line |
| } |