CI / go (Server) (push) Failing after 4m38s
CI / go (Web-App) (push) Successful in 12m18s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / frontend (push) Failing after 7m49s
CI / desktop (ubuntu-latest) (push) Successful in 1h25m30s
CI / mobile (push) Failing after 5m14s
CI / docker (push) Successful in 39m26s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Databases (ADR-13 follow-ups):
- Relation properties link records to another database, on the same page
or on any page the reader can open (read live and read-only, like synced
pages). Cells list the linked titles; clicking one opens the record.
- Rollup properties work out counts, sums, averages, medians, min/max,
ranges, earliest/latest dates and checked counts over related records.
Neither is stored: views compute them before drawing (linked.ts), so they
follow both databases live, and rollups sort and filter as numbers.
- Exports (Markdown, HTML, PDF, Word) resolve them for same-page databases.
- A record opens as a full page at /p/<page>/r/<database>/<record>, with
"Open as full page" on the side panel and "Back to the page".
Edgeless mode (ADR-14 follow-ups):
- History previews show a version's canvas and count canvas changes.
- Comments can be anchored to canvas elements (anchor {element}); elements
with open threads show a badge that opens the thread.
- Workspaces choose how new pages open (workspaces.default_page_mode); the
per-device choice now defaults to following the workspace.
- Phones edit the canvas once a page is opened for editing; the page note
shows the page title.
Languages:
- The admin panel speaks English, Polish, German, French and Spanish, with
a picker sharing the web app's setting and a key parity test.
- The phone app speaks the same five, follows the phone's language (and
Android's per-app language setting), and has its own parity test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.7 KiB
Go
99 lines
3.7 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package convert
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDatabaseExportsAsTable(t *testing.T) {
|
|
doc, err := Parse([]byte(`{"type":"doc","content":[{"type":"callout","content":[{"type":"database","attrs":{"id":"d","data":{
|
|
"title":"Tasks",
|
|
"columns":[
|
|
{"id":"t","name":"Name","type":"title"},
|
|
{"id":"s","name":"Status","type":"select","options":[{"id":"o","name":"Doing","color":"blue"}]},
|
|
{"id":"m","name":"Tags","type":"multiSelect","options":[{"id":"a","name":"red"},{"id":"b","name":"blue"}]},
|
|
{"id":"c","name":"Done","type":"checkbox"},
|
|
{"id":"h","name":"Secret","type":"text"}
|
|
],
|
|
"rows":[
|
|
{"id":"r1","createdAt":1,"cells":{"t":"Write","s":"o","m":["a","b"],"c":true,"h":"x"}},
|
|
{"id":"r2","createdAt":2,"cells":{"t":"Ship"}}
|
|
],
|
|
"views":[{"id":"v","type":"table","hidden":["h"]}]
|
|
}}}]}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
md := Markdown(doc, Options{})
|
|
for _, want := range []string{"**Tasks**", "| Name | Status | Tags | Done |", "| Write | Doing | red, blue | ✓ |", "| Ship |"} {
|
|
if !strings.Contains(md, want) {
|
|
t.Errorf("markdown lacks %q:\n%s", want, md)
|
|
}
|
|
}
|
|
if strings.Contains(md, "Secret") {
|
|
t.Errorf("hidden column exported:\n%s", md)
|
|
}
|
|
h := HTML(doc, Options{})
|
|
if !strings.Contains(h, "<th>") || !strings.Contains(h, "Doing") {
|
|
t.Errorf("html lacks the table:\n%s", h)
|
|
}
|
|
if _, err := DOCX("T", doc, DOCXOptions{}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := PDF("T", doc, PDFOptions{}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestRecordsForSearch(t *testing.T) {
|
|
recs, err := Records([]byte(`{"type":"doc","content":[{"type":"callout","content":[{"type":"database","attrs":{"id":"d","data":{
|
|
"columns":[
|
|
{"id":"t","name":"Name","type":"title"},
|
|
{"id":"s","name":"Status","type":"select","options":[{"id":"o","name":"Doing"}]},
|
|
{"id":"c","name":"Done","type":"checkbox"}
|
|
],
|
|
"rows":[
|
|
{"id":"r1","cells":{"t":"Write","s":"o","c":true},"body":[{"type":"paragraph","content":[{"type":"text","text":"draft first"}]}]},
|
|
{"id":"r2","cells":{}},
|
|
{"cells":{"t":"no id"}}
|
|
]
|
|
}}}]}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []Record{{Database: "d", Row: "r1", Title: "Write", Text: "Doing draft first"}, {Database: "d", Row: "r2"}}
|
|
if len(recs) != len(want) {
|
|
t.Fatalf("records = %+v", recs)
|
|
}
|
|
for i := range want {
|
|
if recs[i] != want[i] {
|
|
t.Errorf("record %d = %+v, want %+v", i, recs[i], want[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRelationsAndRollupsExport(t *testing.T) {
|
|
doc, err := Parse([]byte(`{"type":"doc","content":[
|
|
{"type":"database","attrs":{"id":"p","data":{"title":"Projects",
|
|
"columns":[{"id":"t","name":"Name","type":"title"},
|
|
{"id":"rel","name":"Tasks","type":"relation","relation":{"page":"","database":"k"}},
|
|
{"id":"n","name":"Hours","type":"rollup","rollup":{"relation":"rel","property":"h","fn":"sum"}},
|
|
{"id":"d","name":"Done","type":"rollup","rollup":{"relation":"rel","property":"c","fn":"percentChecked"}},
|
|
{"id":"far","name":"Elsewhere","type":"relation","relation":{"page":"other","database":"x"}}],
|
|
"rows":[{"id":"p1","cells":{"t":"Launch","rel":["k1","k2","gone"],"far":["a","b"]}}],
|
|
"views":[{"id":"v","type":"table"}]}}},
|
|
{"type":"database","attrs":{"id":"k","data":{"title":"Tasks",
|
|
"columns":[{"id":"t","name":"Name","type":"title"},{"id":"h","name":"Hours","type":"number"},{"id":"c","name":"Done","type":"checkbox"}],
|
|
"rows":[{"id":"k1","cells":{"t":"Write","h":2.5,"c":true}},{"id":"k2","cells":{"t":"Ship","h":4}}],
|
|
"views":[{"id":"v","type":"table"}]}}}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
md := Markdown(doc, Options{})
|
|
if want := "| Launch | Write, Ship | 6.5 | 50% | 2 linked |"; !strings.Contains(md, want) {
|
|
t.Errorf("markdown lacks %q:\n%s", want, md)
|
|
}
|
|
}
|