| 1 | package mapatest |
| 2 | |
| 3 | import ( |
| 4 | "net/url" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | // The scriptless floor (level-up §6.10): every page the editor mounts |
| 10 | // on also offers Edit as Markdown, in View and in the kicker, and that |
| 11 | // opens today's textarea with Save. An unwritten day and New scratch |
| 12 | // page draw the empty page; their textarea is one link away. |
| 13 | func TestEveryEditorPageOffersEditAsMarkdown(t *testing.T) { |
| 14 | rig := newRig(t) |
| 15 | acme := rig.createPage(t, Ana, "Acme", "Customer.") |
| 16 | rig.post(t, Ana, "/d/2026-11-12", url.Values{"body": {"Day."}}) |
| 17 | for path, markdown := range map[string]string{ |
| 18 | acme: acme + "/edit", "/d/2026-11-12": "/d/2026-11-12/edit", |
| 19 | "/d/2026-11-13": "/d/2026-11-13/edit", |
| 20 | "/scratch/new": "/scratch/new?markdown=1", |
| 21 | } { |
| 22 | page := rig.page(t, Ana, path) |
| 23 | link := `href="` + strings.ReplaceAll(markdown, "&", "&") + `"` |
| 24 | if strings.Count(page, link) < 2 || |
| 25 | !strings.Contains(page, "Edit as Markdown") { |
| 26 | t.Errorf("%s: no Edit as Markdown (%s) in View and the kicker", |
| 27 | path, markdown) |
| 28 | } |
| 29 | if strings.Contains(page, "<textarea") { |
| 30 | t.Errorf("%s: the editor's page holds a textarea", path) |
| 31 | } |
| 32 | if !strings.Contains(rig.page(t, Ana, markdown), "<textarea") { |
| 33 | t.Errorf("%s: no textarea", markdown) |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |