//go:build browser package mapatest import ( "testing" "time" "github.com/chromedp/chromedp" ) // The import page's vertical rhythm (Paul, 2026-11-22: "The spacing is // all over the place here"), held by Fiesta's rhythm audit in every // state the page has: connect, connected, reading, stopped, writing, // interrupted, failed and done, and the three confirm pages. In each, // every gap between two blocks is a step of the spacing scale, no text // sits closer than --rst-sp-2 to a control, and every heading is closer // to its own content than to the block before it. // importRhythmSkip is what the audit leaves alone on the import page: // rst-form is Fiesta's form, whose rhythm (and the extra air above its // closing row) is Fiesta's to set and its own gates' to check. var importRhythmSkip = []string{"[rst-form]"} func TestImportPageRhythm(t *testing.T) { rig, server, database := importRig(t) rig.Run(scripts(false)) page := rig.Origin + "/import/notion" audit := func(stage string) { auditRhythm(t, rig, stage, importRhythmSkip) } drive(t, rig, chromedp.Navigate(page)) audit("connect") drive(t, rig, chromedp.SendKeys(`input[name="token"]`, "secret_test"), press(`form[action="/import/notion/connect"] button`), chromedp.WaitVisible(`form[action="/import/notion/start"]`)) audit("connected") server.Lock() drive(t, rig, press(`form[action="/import/notion/start"] button`), chromedp.WaitVisible(`form[action="/import/notion/stop"]`)) audit("reading") drive(t, rig, press(`form[action="/import/notion/stop"] button`), chromedp.WaitVisible(`form[action="/import/notion/resume"]`)) server.Unlock() audit("stopped") now := time.Now().UTC() for _, state := range []string{"writing", "interrupted", "failed"} { database().Exec("UPDATE notion_runs SET state = ?, total = 5,"+ " written = 2, error_code = 'unauthorized', heartbeat_at = ?,"+ " progress_at = ?", state, now, now) drive(t, rig, chromedp.Navigate(page)) audit(state) } database().Exec("UPDATE notion_runs SET state = 'stopped', total = 0," + " written = 0, error_code = ''") drive(t, rig, chromedp.Navigate(page), press(`form[action="/import/notion/resume"] button`)) waitFor(t, rig, "Run complete") audit("done") for _, act := range []string{"finish", "disconnect", "forget"} { drive(t, rig, chromedp.Navigate(page+"/"+act)) audit("confirm " + act) } }