oficina / slides Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3package slidestest
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 page shows.
19func TestEnginesUndoAndRedoWhileARefusalIsPendingEndAsSeen(t *testing.T) {
20 out, fr, err := runEnginesRig(t, "undo.mjs")
21 if err != nil {
22 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)
23 }
24 n := 0
25 for _, line := range strings.Split(out, "\n") {
26 rest, ok := strings.CutPrefix(line, "RESULT ")
27 if !ok {
28 continue
29 }
30 var r struct {
31 Label, Deck string
32 Want []string
33 }
34 if err := json.Unmarshal([]byte(rest), &r); err != nil {
35 t.Fatal(err)
36 }
37 n++
38 if got := serverParagraphs(t, fr, r.Deck); strings.Join(got, "\n") != strings.Join(r.Want, "\n") {
39 t.Errorf("%s: the server holds %q, the page %q", r.Label, got, r.Want)
40 }
41 }
42 if n != 34 {
43 t.Errorf("%d cases reported, want 34 (seventeen in each engine)", n)
44 }
45}
46