oficina / docs Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3package docs_test
4
5import (
6 "encoding/json"
7 "strings"
8 "testing"
9)
10
11// An undo or a redo made while a resync is pending ends as the person saw
12// it, in Chromium and WebKit, through the real editor (fixtures/engines/
13// undo.mjs; Claude Fable's seventeen cases on #29/#90). An undo is the undo
14// manager's Yjs change, kept with a replay derived from ySync's mirror of
15// it, so the resync makes it again on the rebuilt text — taking text away
16// or putting it back — whatever ids the change it undoes was replayed
17// under. The refused x is gone afterwards unless an undo or a redo put it
18// back. The server must hold what the sheet shows. Slides has the same
19// test.
20func TestEnginesUndoAndRedoWhileARefusalIsPendingEndAsSeen(t *testing.T) {
21 out, app, err := runEnginesApp(t, "undo.mjs")
22 if err != nil {
23 t.Fatalf("an undo or a redo made while the resync was pending did not end as it was seen: %v\n%s", err, out)
24 }
25 n := 0
26 for _, line := range strings.Split(out, "\n") {
27 rest, ok := strings.CutPrefix(line, "RESULT ")
28 if !ok {
29 continue
30 }
31 var r struct {
32 Label, Deck string
33 Want []string
34 }
35 if err := json.Unmarshal([]byte(rest), &r); err != nil {
36 t.Fatal(err)
37 }
38 n++
39 if got := serverParagraphs(t, app, r.Deck); strings.Join(got, "\n") != strings.Join(r.Want, "\n") {
40 t.Errorf("%s: the server holds %q, the sheet %q", r.Label, got, r.Want)
41 }
42 }
43 if n != 34 {
44 t.Errorf("%d cases reported, want 34 (seventeen in each engine)", n)
45 }
46}
47