Editor:
- Toggles (Tiptap Details). Open state is per reader, not saved.
- Embeds for YouTube, Vimeo, Loom, Figma, CodePen, Spotify, Google Docs
and Maps, in sandboxed frames. Other addresses become link cards.
- Link cards with title, description and picture read by docwell-server
(GET /link-preview). The fetcher refuses private, loopback, link-local
and CGNAT addresses after DNS resolution, redirects included.
- Block links: a margin button gives a block a short id and copies
/p/<id>#b-<block>. Opening one jumps to the block and flashes it.
- Markdown, HTML and PDF exports handle the new blocks; HTML import reads
<details> as a toggle.
Pages and spaces:
- History gets a Changes view: block and word diff against the previous
version or the page as it is now.
- Archive: archived pages leave the tree and become read-only but stay
readable; a space's Archive lists them with Unarchive. New migration
(pages.archived_at) and page.archived / page.unarchived webhook events.
- Full space export (GET /spaces/{id}/export): a zip of Markdown or HTML
files with subpages in folders, an index, and attachments under _files/.
Links between exported pages and to attachments become relative paths.
Desktop 1.0:
- Several servers, each with its own sign-in; old settings files carry over.
- Session tokens in the system keychain (go-keyring), moved out of
localStorage on first start.
- Native menu bar (File, Edit, View, Window, Help) with a Server submenu.
- docwell:// links may point at a block.
- Release workflow builds Windows NSIS, macOS DMG and Linux deb, rpm and
AppImage installers and attaches them to the release;
build/set-version.mjs stamps the version into their metadata.
Not yet run: the release workflow, the desktop menus by eye, and macOS or
Linux builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.1 KiB
Go
69 lines
2.1 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestSettingsRoundTrip(t *testing.T) {
|
|
s := &SettingsService{path: filepath.Join(t.TempDir(), "settings.json")}
|
|
|
|
got, err := s.Get()
|
|
if err != nil || got.ServerURL != defaultServerURL {
|
|
t.Fatalf("default = %+v, %v", got, err)
|
|
}
|
|
|
|
if _, err := s.SetServerURL("https://docs.example.test/"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, _ = s.Get()
|
|
if got.ServerURL != "https://docs.example.test" {
|
|
t.Errorf("saved = %q", got.ServerURL)
|
|
}
|
|
}
|
|
|
|
func TestSettingsRejectsBadURL(t *testing.T) {
|
|
s := &SettingsService{path: filepath.Join(t.TempDir(), "settings.json")}
|
|
for _, bad := range []string{"", "ftp://x", "not a url", "http://"} {
|
|
if _, err := s.SetServerURL(bad); err == nil {
|
|
t.Errorf("SetServerURL(%q) should fail", bad)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestServers(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "settings.json")
|
|
// A file from the first desktop builds: one address, no list.
|
|
if err := os.WriteFile(path, []byte(`{"serverUrl":"https://old.example.test"}`), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := &SettingsService{path: path}
|
|
got, _ := s.Get()
|
|
if len(got.Servers) != 1 || got.ServerURL != "https://old.example.test" || got.Servers[0].Name != "old.example.test" {
|
|
t.Fatalf("migrated = %+v", got)
|
|
}
|
|
|
|
got, err := s.AddServer("Work", "https://work.example.test/")
|
|
if err != nil || len(got.Servers) != 2 || got.ServerURL != "https://work.example.test" {
|
|
t.Fatalf("added = %+v, %v", got, err)
|
|
}
|
|
work := got.Active
|
|
// The same address again switches to it instead of adding a copy.
|
|
got, _ = s.AddServer("", "https://OLD.example.test")
|
|
if len(got.Servers) != 2 || got.ServerURL != "https://old.example.test" {
|
|
t.Fatalf("re-added = %+v", got)
|
|
}
|
|
if got, _ = s.SetActive(work); got.ServerURL != "https://work.example.test" {
|
|
t.Fatalf("switched = %+v", got)
|
|
}
|
|
if got, _ = s.RemoveServer(work); len(got.Servers) != 1 || got.ServerURL != "https://old.example.test" {
|
|
t.Fatalf("removed = %+v", got)
|
|
}
|
|
if _, err := s.RemoveServer(got.Active); err == nil {
|
|
t.Fatal("removed the last server")
|
|
}
|
|
}
|