oficina / mapa Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3package mapatest
4
5import (
6 "context"
7 "strings"
8 "testing"
9
10 "github.com/chromedp/chromedp"
11
12 "amadan.net/oficina/mapa/internal/mapa"
13)
14
15// L9 end to end for Fable's re-review of 14ab6a6 (round 4, M-B): a page
16// deleted before the tab stored any draft on it. The store refuses the
17// draft (404); the bar offers the text as a new scratch page, and the
18// button makes one holding everything typed.
19func TestL9APageDeletedBeforeAnyDraftOffersAScratchPage(t *testing.T) {
20 rig, store := browserRig(t, 0)
21 page := teamPage(t, rig, store, "One.")
22 if err := store.Delete(context.Background(), Bo, page.ID); err != nil {
23 t.Fatal(err)
24 }
25 offer := `[mapa-editor-notice] form[action="/scratch"]`
26 drive(t, rig, caretAt(0), chromedp.KeyEvent(" Ana."),
27 chromedp.WaitVisible(offer), chromedp.KeyEvent(" More."))
28 if got := read(t, rig, chromedp.Evaluate[string](statusText)); got !=
29 "Not saved" {
30 t.Fatalf("the status says %q", got)
31 }
32 drive(t, rig, chromedp.Click(offer+" button"))
33 eventually(t, "the scratch page", func() bool {
34 return !strings.HasSuffix(read(t, rig, chromedp.Location()),
35 mapa.PagePath(page))
36 })
37 drive(t, rig, chromedp.WaitVisible(mounted))
38 if got := typed(t, rig); got != "One. Ana. More." {
39 t.Fatalf("the scratch page holds %q", got)
40 }
41}
42