oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1package docs
2
3import (
4 "context"
5 "testing"
6)
7
8// Every way a document is made keeps its title one line (cleanTitle): an
9// import and an agent's create, as a rename and a new document already do
10// (Fable's delta on #179).
11func TestImportsAndAgentsMakeOneLineTitles(t *testing.T) {
12 app, _ := sealedApp(t, Config{})
13 owner := app.TestPerson(t, "owner@example.com")
14 ctx := context.Background()
15 imp, err := convertImport(ctx, app.store.core, nestedDoc(t))
16 if err != nil {
17 t.Fatal(err)
18 }
19 doc, err := app.store.CreateImported(ctx, owner, "Board\nminutes\t\x07draft", "title-paths", imp)
20 if err != nil {
21 t.Fatal(err)
22 }
23 if doc.Title != "Board minutes draft" {
24 t.Errorf("an import kept its title as %q", doc.Title)
25 }
26
27 f := newDocAgentFixture(t)
28 in := initialAgentInput()
29 in.Title = "Agent\r\nnotes
here"
30 body := decodeAgentBody(t, f.call(t, "docs_create", in))
31 var made Document
32 if err := f.a.store.db.Where("sqid=?", body.ID).First(&made).Error; err != nil {
33 t.Fatal(err)
34 }
35 if made.Title != "Agent notes here" {
36 t.Errorf("an agent's create kept its title as %q", made.Title)
37 }
38}
39