//go:build browser package slidestest import ( "encoding/json" "strings" "testing" ) // An undo or a redo made while a resync is pending ends as the person saw // it, in Chromium and WebKit, through the real editor (fixtures/engines/ // undo.mjs; Claude Fable's seventeen cases on #29/#90). An undo is the undo // manager's Yjs change, kept with a replay derived from ySync's mirror of // it, so the resync makes it again on the rebuilt text — taking text away // or putting it back — whatever ids the change it undoes was replayed // under. The refused x is gone afterwards unless an undo or a redo put it // back. The server must hold what the page shows. func TestEnginesUndoAndRedoWhileARefusalIsPendingEndAsSeen(t *testing.T) { out, fr, err := runEnginesRig(t, "undo.mjs") if err != nil { 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) } n := 0 for _, line := range strings.Split(out, "\n") { rest, ok := strings.CutPrefix(line, "RESULT ") if !ok { continue } var r struct { Label, Deck string Want []string } if err := json.Unmarshal([]byte(rest), &r); err != nil { t.Fatal(err) } n++ if got := serverParagraphs(t, fr, r.Deck); strings.Join(got, "\n") != strings.Join(r.Want, "\n") { t.Errorf("%s: the server holds %q, the page %q", r.Label, got, r.Want) } } if n != 34 { t.Errorf("%d cases reported, want 34 (seventeen in each engine)", n) } }