//go:build browser package mapatest import ( "context" "strings" "testing" "github.com/chromedp/chromedp" "amadan.net/oficina/mapa/internal/mapa" ) // L9 end to end for Fable's re-review of 14ab6a6 (round 4, M-B): a page // deleted before the tab stored any draft on it. The store refuses the // draft (404); the bar offers the text as a new scratch page, and the // button makes one holding everything typed. func TestL9APageDeletedBeforeAnyDraftOffersAScratchPage(t *testing.T) { rig, store := browserRig(t, 0) page := teamPage(t, rig, store, "One.") if err := store.Delete(context.Background(), Bo, page.ID); err != nil { t.Fatal(err) } offer := `[mapa-editor-notice] form[action="/scratch"]` drive(t, rig, caretAt(0), chromedp.KeyEvent(" Ana."), chromedp.WaitVisible(offer), chromedp.KeyEvent(" More.")) if got := read(t, rig, chromedp.Evaluate[string](statusText)); got != "Not saved" { t.Fatalf("the status says %q", got) } drive(t, rig, chromedp.Click(offer+" button")) eventually(t, "the scratch page", func() bool { return !strings.HasSuffix(read(t, rig, chromedp.Location()), mapa.PagePath(page)) }) drive(t, rig, chromedp.WaitVisible(mounted)) if got := typed(t, rig); got != "One. Ana. More." { t.Fatalf("the scratch page holds %q", got) } }