CI / go (Media) (push) Successful in 13m40s
CI / go (Server) (push) Failing after 23m20s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 10m35s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Failing after 3h4m42s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / mobile (push) Failing after 9m19s
CI / docker (push) Successful in 2h2m57s
- Columns: /columns puts 2 to 4 columns side by side, with widths dragged between them; they stack on phones. HTML export and import keep them (also Notion column lists and Confluence page layouts). - Suggesting mode: edits become suggested insertions and deletions that editors accept or reject one by one or all at once. Text only. - Verified pages: editors verify a page for a while or without end; the verifier is notified when it runs out (migration 1764700000). - Scanned PDFs attached to pages are read by AI for search where a workspace turns it on. - The server writes error messages, emails, digests and phone notifications in English, Polish, German, French and Spanish; the apps send their language with each request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
2.8 KiB
Go
80 lines
2.8 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package convert
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func colTypes(doc Node) []string {
|
|
var out []string
|
|
for _, n := range doc.Content {
|
|
out = append(out, n.Type)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func TestColumnsRoundTripThroughHTML(t *testing.T) {
|
|
doc := Node{Type: "doc", Content: []Node{{Type: "columns", Content: []Node{
|
|
{Type: "column", Attrs: map[string]any{"width": 70.0}, Content: []Node{cpara("Left")}},
|
|
{Type: "column", Attrs: map[string]any{"width": 30.0}, Content: []Node{cpara("Right")}},
|
|
}}}}
|
|
out := HTML(doc, Options{})
|
|
if !strings.Contains(out, `data-type="columns"`) || !strings.Contains(out, `data-width="70"`) {
|
|
t.Fatalf("html: %s", out)
|
|
}
|
|
back, err := FromHTML(out)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := colTypes(back); len(got) != 1 || got[0] != "columns" {
|
|
t.Fatalf("types: %v", got)
|
|
}
|
|
row := back.Content[0]
|
|
if len(row.Content) != 2 || columnWidth(row.Content[0]) != 70 || PlainText(row.Content[1]) != "Right" {
|
|
t.Fatalf("row: %+v", row)
|
|
}
|
|
}
|
|
|
|
func TestColumnsFlattenInMarkdown(t *testing.T) {
|
|
doc := Node{Type: "doc", Content: []Node{{Type: "columns", Content: []Node{
|
|
{Type: "column", Content: []Node{cpara("Left")}},
|
|
{Type: "column", Content: []Node{cpara("Right")}},
|
|
}}}}
|
|
md := Markdown(doc, Options{})
|
|
if !strings.Contains(md, "Left") || !strings.Contains(md, "Right") || strings.Index(md, "Left") > strings.Index(md, "Right") {
|
|
t.Fatalf("markdown: %q", md)
|
|
}
|
|
}
|
|
|
|
func TestNotionAndConfluenceColumns(t *testing.T) {
|
|
notion := `<div class="column-list"><div class="column" style="width:25%"><p>A</p></div>` +
|
|
`<div class="column" style="width:75%"><p>B</p></div></div>`
|
|
doc, _ := FromHTML(notion)
|
|
if colTypes(doc)[0] != "columns" || columnWidth(doc.Content[0].Content[1]) != 75 {
|
|
t.Fatalf("notion: %+v", doc)
|
|
}
|
|
conf := `<div class="columnLayout two-right-sidebar"><div class="cell normal"><div class="innerCell"><p>Main</p></div></div>` +
|
|
`<div class="cell aside"><div class="innerCell"><p>Side</p></div></div></div>`
|
|
doc, _ = FromHTML(conf)
|
|
if colTypes(doc)[0] != "columns" || columnWidth(doc.Content[0].Content[0]) != 70 || columnWidth(doc.Content[0].Content[1]) != 30 {
|
|
t.Fatalf("confluence: %+v", doc)
|
|
}
|
|
// A layout with one cell is just its blocks.
|
|
doc, _ = FromHTML(`<div class="columnLayout single"><div class="cell normal"><p>Only</p></div></div>`)
|
|
if got := colTypes(doc); len(got) != 1 || got[0] != "paragraph" {
|
|
t.Fatalf("single: %v", got)
|
|
}
|
|
}
|
|
|
|
func TestColumnsPastFourJoinTheFourth(t *testing.T) {
|
|
bodies := [][]Node{{cpara("1")}, {cpara("2")}, {cpara("3")}, {cpara("4")}, {cpara("5")}}
|
|
row := newColumns(bodies, nil)[0]
|
|
if len(row.Content) != 4 || len(row.Content[3].Content) != 2 {
|
|
t.Fatalf("row: %+v", row)
|
|
}
|
|
}
|
|
|
|
func cpara(s string) Node { return Node{Type: "paragraph", Content: []Node{{Type: "text", Text: s}}} }
|