Merge origin/ux/fixes-1 into fix/title-rename
New team page's popover, the rail's tooltips and the one-field New page screen (build note 77) beside the in-page title rename, whose build note is renumbered 78 (and note 13's amendment with it). No textual conflicts; the spec's §13 keeps both notes in order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 files changed,
+539
−52
AGENTS.md+1 −1docs/superpowers/specs/2026-11-14-mapa-level-up.md+12 −3editor/title.mjs+1 −1editor/title.test.mjs+1 −1internal/mapa/handlers_pages.go+20 −2internal/mapa/handlers_title.go+1 −1internal/mapa/static/frame.css+77 −21internal/mapa/static/mapa.css+1 −1internal/mapa/static/mapa.js+93 −0internal/mapa/templates/frame.html+20 −9internal/mapa/templates/page_new.html+6 −2internal/mapa/templates/partials.html+1 −1internal/mapa/templates/shell.html+1 −0internal/mapatest/browser_test.go+14 −4internal/mapatest/gate1_test.go+1 −1internal/mapatest/layout_browser_test.go+1 −1internal/mapatest/newpage_browser_test.go+258 −0internal/mapatest/share_json_test.go+27 −0internal/mapatest/title_browser_test.go+1 −1internal/mapatest/title_quality_browser_test.go+1 −1internal/mapatest/title_test.go+1 −1
diff --git a/AGENTS.md b/AGENTS.md| index 1c67215..45b68c9 100644 |
| --- a/AGENTS.md |
| +++ b/AGENTS.md |
| @@ -82,7 +82,7 @@ Makefile, estilo's files served straight from the module). |
| `maketeam.mjs` Make team page from a selection; `accessory.mjs` the |
| phone's row; `notices.mjs` the bars and the lead's save status; |
| `title.mjs` the title renamed in place, shared with the header's |
| - field (build note 77). |
| + field (build note 78). |
| `saver.test.mjs` is L9's client half; in `internal/mapatest/`, |
| `editor_browser_test.go` holds L5 and L9 end to end, |
| `editor_typing_browser_test.go` the typing, and |
diff --git a/docs/superpowers/specs/2026-11-14-mapa-level-up.md b/docs/superpowers/specs/2026-11-14-mapa-level-up.md| index b25c495..19f179c 100644 |
| --- a/docs/superpowers/specs/2026-11-14-mapa-level-up.md |
| +++ b/docs/superpowers/specs/2026-11-14-mapa-level-up.md |
| @@ -1049,7 +1049,7 @@ Phase 1's choices where this spec was silent, or where the build chose different |
| 10. **The fold is two submit buttons,** one per state, and CSS shows the one that fits the screen. So it works with scripts off and with no cookie. `POST /view/sidebar` and `/view/links` set cookies, write no row and log no event; gate 8 drives them as view-only routes. Their `return` must be a local path. |
| 11. **Recently edited leaves out bulk edits by transaction:** any transaction whose events share one actor and one `at` and hold more than one `edited` (§3.2). It reads at most the person's last 200 qualifying events. |
| 12. **Pins** are sealed in `members.sealed_pins` (migration 0003): at most 12 page ids, newest first. The plaintext is always 12 eight-byte slots, empty ones zero (review L11), so the ciphertext's length does not say how many pages anyone pinned. The event is `pins` on the member. |
| -13. **Rename still lands on the existing Update links confirm page** (`/p/{id}/links`), not an in-page notice. It was already a confirm page with the honest count, and gate 1 compares it as one. *Amended by note 77:* with script, the in-page notice; without it, still this confirm page. |
| +13. **Rename still lands on the existing Update links confirm page** (`/p/{id}/links`), not an in-page notice. It was already a confirm page with the honest count, and gate 1 compares it as one. *Amended by note 78:* with script, the in-page notice; without it, still this confirm page. |
| 14. **The kicker's "Edited by"** reads the current revision's plaintext row, and names a teammate by their address's local part. History and presence do the same. |
| 15. **The Links panel's foot fallback stays on phones,** beside the sheet. The sheet is a script enhancement (`links.js`), not a modal `<dialog>`, so the lists are reachable with scripts off. |
| 16. **The map** is a 284×200 viewBox with the ring at 104×66, starting at −150°. Its labels are clamped inside the box. Edges between neighbours are drawn once per pair. |
| @@ -1141,7 +1141,17 @@ Phase 1's choices where this spec was silent, or where the build chose different |
| 74. **A page deleted before the tab stored any draft on it** (M-B; corrects note 58). `mayDraft` refuses it (404): the person has no draft for the store to keep. The saver takes a 404 from the drafts route as that state: it sends nothing more there, the status says "Not saved", and the bar offers Save as a scratch page, which posts the text to the existing `POST /scratch`. Leaving inside Mapa shows the offer again beside Leave anyway; a close makes the scratch page with one keepalive `POST /scratch`, so what was typed is never only in a closed tab. |
| 75. **A bar's action does not go on a failed flush; a hung POST times out** (L2, L3). Save as a scratch page and Discard are not sent when the flush before them failed, and the bar says so; Show the saved version offers Leave anyway instead of going. `post.mjs` aborts a request after 10 seconds (never a keepalive one), and the saver retries. An aborted request may have landed; every draft write is version-checked, so the retry meets a 409 whose body is the text that request sent, and the saver takes that as its own: its version, and the typing since autosaved, never replaced. |
| 76. **The first scratch commit's tokens are held per person** (L4; amends notes 31 and 66): at most 256 each, refused past that, so one person's tabs never use up anyone else's. |
| -77. **The in-page title renames, as §4.1 asked** (Paul: "Why can't I click a title to edit it?"; amends note 13). |
| + |
| +**New team page and the rail's tooltips, unclipped** (Paul, 14 November: clicking New team page showed nothing usable): |
| + |
| +77. **Nothing leaves the sidebar by overflowing it.** `[mapa-side]` scrolls (`overflow: auto`), and two things drew outside it and were cut off: New team page's form (285px wide in a 224px sidebar, so its right side went; beside the rail, all of it) and every rail tooltip. The sidebar keeps its scrolling (long Pinned and Recently edited lists need it); what leaves it no longer belongs to its box. |
| + - **The popover** is a native `popover` (`#mapa-new-page`, `role="dialog"`), opened by a `popovertarget` button at the sidebar's foot, so it needs no script: the top layer, which no overflow clips, and the platform's own Esc, click outside (light dismiss) and focus, which moves to the title (`autofocus` inside a popover) and back to the button on close. Placed by CSS anchor positioning: above the button in the open sidebar, beside it on the rail and in the default between 800px and 80rem, with `position-try-fallbacks: flip-block`. An engine without anchoring puts it fixed beside the sidebar's foot (`inset-inline-start: var(--mapa-side-w) + 10px`, 12px up); one without popovers shows a plain link to `/new` instead of the button. It is drawn after `<main>`, not in the sidebar: WebKit gives a page's autofocus to the first `[autofocus]` in the document even when hidden, and the popover's field took it from the New page and Rename screens' own (measured: `<div popover><input autofocus></div><input autofocus>` focuses nothing in WebKit 2388). The menus' `name="estilo-menus"` group: a popover is not a `<details>`, so the name does not apply, but the exclusivity holds both ways where it can. Pressing on a menu's title light-dismisses the popover with no script, and opening the popover closes an open menu through estilo's chrome.js (a click outside it); with scripts off a menu left open stays open under the popover, as two `<details>` menus never could. Esc closes whichever is open. |
| + - **With script** (`mapa.js`, `newTeamPage`) the popover posts `POST /pages` itself with `Accept: application/json`, held 650ms with the busy spinner (the form carries `data-busy="false"` so busy.js leaves it), and goes to the page the reply names, where the editor takes the caret (note 57). A refused title (taken, empty after trimming, too long, a date) answers 422 with the sentence and, for a taken title, its page; the popover shows it under the field with "Open the page with that title", the typing kept and focus back in the field. An empty field is refused by `required` before anything is sent. Esc gives focus back to the button: WebKit does not focus a button on a click, so a mouse-opened popover returned focus to the body. Without script the POST goes as a form, and a refusal is the New page screen with the sentence and what was typed. |
| + - **The tooltips** are `position: fixed`, which escapes a scroller that is not the box's containing block. Where the engine anchors, each is tied to its own row (`anchor-name` with `anchor-scope`, so every row's one name means that row) and follows the rail when it scrolls; elsewhere it sits at its static position, the row's corner, moved out 50px by margin. The static position does not follow a scrolled rail, which only scrolls below about 330px of window height. |
| + - **New page is one title field** (bug 3): the screen behind Page → New team page, `/new`, ⌘K's Create and a pending link drew the Markdown textarea under the title, borderless and half the window tall, so Create and Cancel sat 490 to 530px under the field and off a 877px window. It is now the title and the buttons, as Rename is and as §4.7's popover is; the page's text is written on the page once it exists, with the caret already there with script, and through the page's Edit as Markdown without. A body that comes with a refused POST (no screen sends one now) rides along in a hidden field, so nothing is lost. Gate 7's walk creates Acme, then writes its text through Edit as Markdown. |
| + - **Gates** (`newpage_browser_test.go`, `make browser`), each failing on `1e92f29`: `TestNewTeamPageShowsTheWholeForm` opens New team page in six sidebar states (1400 and 900 wide; no cookie, `open` and `rail`) and at 390 by Page → New team page, scripts off and on, asks `elementFromPoint` at the four corners of the title field and Create (3px in, past their rounded borders) for the form, checks focus is in the title, then types a title and presses Enter and waits for the page (on `1e92f29`: the corners hit `main` in every sidebar state, focus stayed on the summary, Enter made no page, and at 390 Create was below the window); `TestNewTeamPageRefusesATakenTitleInPlace`; `TestTheNewPageScreenKeepsItsButtonsUnderTheField` (within 48px at 1402×877 and 390×844, scripts off and on; 488 to 526px on `1e92f29`); `TestTheRailsTooltipsAreWhole`, which hovers every rail row by width and by cookie and hit-tests the tooltip's corners (every one cut off on `1e92f29`). `TestNewTeamPageAnswersThePopover` holds the JSON replies. By hand in Playwright's WebKit (build 2388): the popover's box in all five states matches Chromium's to the pixel, every corner hits, focus goes to the title and back to the button on Esc, a taken title is refused in place with scripts and on the screen without, Enter creates in both, and the tooltips are whole, a scrolled rail included. |
| + |
| +78. **The in-page title renames, as §4.1 asked** (Paul: "Why can't I click a title to edit it?"; amends note 13). |
| - **The field.** On a team page the editor mounts on (`/p/{id}`, not History, not `?saved=1`, not the Markdown editor), the server marks the H1 `mapa-rename` and wraps its text in `<span mapa-title-text>`; without script that is the plain heading it was. `editor/title.mjs` makes the span `contenteditable`, `role="textbox"`, named "Title, renames the page". The heading keeps the title as its own name, read from the textbox's value, so heading navigation is unchanged. An input styled as the H1 was not chosen: a title wraps and an input does not, so a long title would shift the page, and a click on its second line could not place the caret. It is `contenteditable="true"`, not `plaintext-only`, which Chromium forces to `pre-wrap` (a line's end space kept and measured, so a wrapped title's box changed at mount); breaks and formatting are refused on `beforeinput`, and paste inserts text only, one line. CSS gives the span the heading's own `white-space`, `overflow-wrap` and `line-break`, so nothing moves when it becomes editable; the focus ring is an outline on the H1. |
| - **Keys.** Click, tap or Tab to it; Enter, ⌘S or blur renames; Esc puts the title back and writes nothing; an empty or unchanged title sends nothing (blur restores the title). Enter is never acted on while composing (`isComposing`, keyCode 229). A refused title left by blur is not sent again until it changes. |
| - **One pending state.** The header's title field, on that page, goes through the same `Renamer`: its submit is taken over (the busy shim leaves a cancelled submit alone). While one rename is out, both show the title on its way, the header field is read-only, the H1 refuses typing, and a second rename is not sent. The state holds at least 650ms (the busy rule), with estilo's spinner and "Renaming…" in the note under the H1, and on the header's Rename button when it sent. |
| @@ -1152,7 +1162,6 @@ Phase 1's choices where this spec was silent, or where the build chose different |
| - **The draft follows the rename.** A rename mints a revision holding exactly the body of the one before (base §3.2), so the store moves every draft on the page based on that revision to the new one, in the rename's transaction (`carryDrafts`; only the base, never the text, the version or the time written). The tab's saver moves its own base the same way (`Saver.renamed`). Before, a draft open across a rename committed as `Merged`, "merged with a teammate's changes", against a revision that changed only the title, and the editor rebased for it. |
| - **Gates.** `internal/mapatest/title_test.go` (JSON answers, refusals, Update links, the draft carried, which pages are renamable); `title_browser_test.go` and `title_quality_browser_test.go` in `make browser` (click, type, Enter; Esc; a taken title; no double submit; not on daily, scratch or History; no shift at three widths and the caret where clicked; typing and draft kept with no rebase; axe in each state); `editor/title.test.mjs` (the shared state). Gate 1 compares the JSON answers. WebKit (Playwright 1.65.1, build 2388) by hand on the preview: no shift at 1440, 1000 and 390px, the caret where clicked, Esc, rename, refusal and the header all as in Chromium. IME composition was not driven by hand; it rests on the `isComposing` guard. |
| - |
| ## 14. Findings and what changed |
| ### Round 1: Fable on revision 1 (`4027e10`), answered in revision 2 |
diff --git a/editor/title.mjs b/editor/title.mjs| index 709ae12..05d2b8a 100644 |
| --- a/editor/title.mjs |
| +++ b/editor/title.mjs |
| @@ -1,5 +1,5 @@ |
| // title.mjs — a team page's title, renamed in place (level-up §4.1, |
| -// build note 77). The H1's text and the header's title field rename |
| +// build note 78). The H1's text and the header's title field rename |
| // through the same POST /p/{id}/rename, asking for JSON, with one |
| // pending state between them (mock-up risk 9): while one is out, both |
| // show the title on its way and neither can send another. When it |
diff --git a/editor/title.test.mjs b/editor/title.test.mjs| index 26daea2..bf03a8d 100644 |
| --- a/editor/title.test.mjs |
| +++ b/editor/title.test.mjs |
| @@ -1,5 +1,5 @@ |
| // title.test.mjs — the in-page title's one pending state (level-up |
| -// §4.1, build note 77), without a browser: the H1 and the header share |
| +// §4.1, build note 78), without a browser: the H1 and the header share |
| // one Renamer, so a second rename while one is out is never sent; an |
| // empty or unchanged title sends nothing; a refusal keeps what was |
| // typed; and the saver's base follows a rename made over it. The page |
diff --git a/internal/mapa/handlers_pages.go b/internal/mapa/handlers_pages.go| index 497cca1..ce2fcc6 100644 |
| --- a/internal/mapa/handlers_pages.go |
| +++ b/internal/mapa/handlers_pages.go |
| @@ -179,17 +179,35 @@ func (app *app) createPage(writer http.ResponseWriter, |
| form := pageForm{Title: title, Body: body, Error: err.Error(), |
| Action: "/pages", Label: "Create page", |
| Taken: app.index.TitleHref(request.Context(), title)} |
| - app.showForm(writer, request, http.StatusUnprocessableEntity, |
| - "page_new", form) |
| + app.refuseCreate(writer, request, form) |
| return |
| } |
| if err != nil { |
| app.fail(writer, request, err) |
| return |
| } |
| + if wantsJSON(request) { |
| + answer(writer, map[string]any{"href": PagePath(page)}) |
| + return |
| + } |
| seeOther(writer, request, PagePath(page)) |
| } |
| +// refuseCreate asks for another title: the New page screen again, with |
| +// what was typed, or, for the sidebar's popover, the sentence as JSON, |
| +// shown where the title was typed (level-up §4.7). |
| +func (app *app) refuseCreate(writer http.ResponseWriter, |
| + request *http.Request, form pageForm) { |
| + if !wantsJSON(request) { |
| + app.showForm(writer, request, http.StatusUnprocessableEntity, |
| + "page_new", form) |
| + return |
| + } |
| + writer.Header().Set("Content-Type", "application/json; charset=utf-8") |
| + writer.WriteHeader(http.StatusUnprocessableEntity) |
| + answer(writer, map[string]any{"error": form.Error, "taken": form.Taken}) |
| +} |
| + |
| // notice is the sentence a redirect after a POST asked for. |
| func notice(request *http.Request) string { |
| query := request.URL.Query() |
diff --git a/internal/mapa/handlers_title.go b/internal/mapa/handlers_title.go| index b6abdeb..5f435d6 100644 |
| --- a/internal/mapa/handlers_title.go |
| +++ b/internal/mapa/handlers_title.go |
| @@ -6,7 +6,7 @@ import ( |
| "strconv" |
| ) |
| -// The in-page title's answers (level-up §4.1, build note 77). The H1 |
| +// The in-page title's answers (level-up §4.1, build note 78). The H1 |
| // and the header's title field rename through the same POST |
| // /p/{id}/rename as the form, asking for JSON; the form's redirect to |
| // the Update links confirm page is unchanged, and stays the floor. |
diff --git a/internal/mapa/static/frame.css b/internal/mapa/static/frame.css| index c106f6a..9915dac 100644 |
| --- a/internal/mapa/static/frame.css |
| +++ b/internal/mapa/static/frame.css |
| @@ -129,7 +129,10 @@ kbd[mapa-kbd] { |
| } |
| /* ── The rail (Página's): the same rows, icons only, on one axis. The |
| - label stays in the accessibility tree and is the tooltip. ── */ |
| + label stays in the accessibility tree and is the tooltip. The tooltip |
| + is fixed where its row puts it (its static position, insets left |
| + auto), then moved out beside the 40px row: a fixed box escapes the |
| + sidebar's scrolling, which clipped an absolute one. ── */ |
| @media (min-width: 800px) { |
| [mapa-app][data-side="rail"] [mapa-side] { padding-inline: 8px; align-items: center; } |
| [mapa-app][data-side="rail"] [mapa-side-item] { |
| @@ -156,8 +159,10 @@ kbd[mapa-kbd] { |
| background: var(--rst-accent); |
| } |
| [mapa-app][data-side="rail"] [mapa-side-label] { |
| - position: absolute; |
| - inset-inline-start: calc(100% + 10px); |
| + position: fixed; |
| + margin-inline-start: 50px; |
| + margin-block-start: 19px; |
| + translate: 0 -50%; |
| z-index: 30; |
| padding: 4px 8px; |
| border-radius: 6px; |
| @@ -201,8 +206,10 @@ kbd[mapa-kbd] { |
| background: var(--rst-accent); |
| } |
| [mapa-app]:not([data-side]) [mapa-side-label] { |
| - position: absolute; |
| - inset-inline-start: calc(100% + 10px); |
| + position: fixed; |
| + margin-inline-start: 50px; |
| + margin-block-start: 19px; |
| + translate: 0 -50%; |
| z-index: 30; |
| padding: 4px 8px; |
| border-radius: 6px; |
| @@ -373,31 +380,80 @@ textarea[mapa-editor]:focus { outline: none; box-shadow: none; } |
| [mapa-unsaved] p { margin: 0; flex: 1 1 16rem; } |
| -/* New team page: a popover from the sidebar's foot (§4.7). */ |
| -details[mapa-new-page] { position: relative; } |
| -details[mapa-new-page] > summary { list-style: none; } |
| -details[mapa-new-page] > summary::-webkit-details-marker { display: none; } |
| -form[mapa-new-page-form] { |
| - position: absolute; |
| - z-index: 40; |
| - inset-block-end: calc(100% + 6px); |
| - inset-inline-start: 0; |
| - display: grid; |
| - gap: 8px; |
| - inline-size: 260px; |
| +/* New team page (§4.7): a popover in the top layer, so the sidebar's |
| + overflow never clips it, whatever its state. Anchored to its button |
| + where the engine anchors: above it in the open sidebar, beside it on |
| + the rail. Elsewhere it sits fixed beside the sidebar's foot. */ |
| +[mapa-new-page-link] { display: none; } |
| +@supports not selector(:popover-open) { |
| + [mapa-new-page-open], [mapa-new-page] { display: none; } |
| + [mapa-new-page-link] { display: grid; } |
| +} |
| +[mapa-new-page-open] { anchor-name: --mapa-new-page; } |
| +[mapa-new-page] { |
| + box-sizing: border-box; |
| + inline-size: min(286px, calc(100vw - 16px)); |
| + margin: 0; |
| + inset: auto; |
| + inset-block-end: 12px; |
| + inset-inline-start: calc(var(--mapa-side-w) + 10px); |
| padding: 12px; |
| + overflow: visible; |
| border: 1px solid var(--rst-line); |
| border-radius: 12px; |
| background: var(--rst-surface); |
| + color: var(--rst-text); |
| box-shadow: 0 18px 40px -16px rgb(23 32 60 / 0.35); |
| + font-size: 13px; |
| } |
| +form[mapa-new-page-form] { display: grid; gap: 8px; margin: 0; } |
| form[mapa-new-page-form] label { font-size: 12px; font-weight: 650; color: var(--rst-text-muted); } |
| form[mapa-new-page-form] p { margin: 0; font-size: 12px; } |
| -@media (min-width: 800px) { |
| - [mapa-app][data-side="rail"] form[mapa-new-page-form] { inset-block-end: 0; inset-inline-start: calc(100% + 10px); } |
| +[mapa-new-page-error][hidden] { display: none; } |
| +[mapa-new-page-error] a { color: inherit; } |
| +@supports (anchor-name: --mapa-new-page) { |
| + [mapa-new-page] { |
| + position-anchor: --mapa-new-page; |
| + inset-block-end: calc(anchor(start) + 6px); |
| + inset-inline-start: anchor(start); |
| + position-try-fallbacks: flip-block; |
| + } |
| + @media (min-width: 800px) { |
| + [mapa-app][data-side="rail"] [mapa-new-page] { |
| + inset-block-end: anchor(end); |
| + inset-inline-start: calc(anchor(end) + 10px); |
| + } |
| + } |
| + @media (min-width: 800px) and (max-width: 79.99rem) { |
| + [mapa-app]:not([data-side]) [mapa-new-page] { |
| + inset-block-end: anchor(end); |
| + inset-inline-start: calc(anchor(end) + 10px); |
| + } |
| + } |
| } |
| -@media (min-width: 800px) and (max-width: 79.99rem) { |
| - [mapa-app]:not([data-side]) form[mapa-new-page-form] { inset-block-end: 0; inset-inline-start: calc(100% + 10px); } |
| + |
| +/* Where the engine anchors, each tooltip is tied to its own row |
| + (anchor-scope keeps the name to that row), so it follows the rail as |
| + it scrolls; a static position is fixed where layout put it. */ |
| +@supports (anchor-name: --mapa-side-item) { |
| + @media (min-width: 800px) { |
| + [mapa-side-item] { anchor-name: --mapa-side-item; anchor-scope: --mapa-side-item; } |
| + [mapa-new-page-open] { anchor-name: --mapa-new-page, --mapa-side-item; } |
| + [mapa-app][data-side="rail"] [mapa-side-label] { |
| + position-anchor: --mapa-side-item; |
| + inset-block-start: anchor(center); |
| + inset-inline-start: calc(anchor(end) + 10px); |
| + margin: 0; |
| + } |
| + } |
| + @media (min-width: 800px) and (max-width: 79.99rem) { |
| + [mapa-app]:not([data-side]) [mapa-side-label] { |
| + position-anchor: --mapa-side-item; |
| + inset-block-start: anchor(center); |
| + inset-inline-start: calc(anchor(end) + 10px); |
| + margin: 0; |
| + } |
| + } |
| } |
| /* Below 800px there is no sidebar: its places are rows in estilo's |
diff --git a/internal/mapa/static/mapa.css b/internal/mapa/static/mapa.css| index daac22e..9f0dc58 100644 |
| --- a/internal/mapa/static/mapa.css |
| +++ b/internal/mapa/static/mapa.css |
| @@ -489,7 +489,7 @@ img.ProseMirror-separator { |
| /* The Links sheet hides while the keyboard is up (§4.3). */ |
| html[data-mapa-keyboard] aside[mapa-links] [mapa-peek] { display: none; } |
| -/* The in-page title, renamed in place (level-up §4.1, build note 77). |
| +/* The in-page title, renamed in place (level-up §4.1, build note 78). |
| Its look does not change when it is edited: the text keeps its face, |
| size and wrap, and the ring is an outline, which takes no room. The |
| note under it is empty, and so takes no room, until a rename says |
diff --git a/internal/mapa/static/mapa.js b/internal/mapa/static/mapa.js| index 359e922..d3d7567 100644 |
| --- a/internal/mapa/static/mapa.js |
| +++ b/internal/mapa/static/mapa.js |
| @@ -715,6 +715,98 @@ |
| }); |
| } |
| + // ---- New team page --------------------------------------------------------- |
| + // The sidebar's popover (level-up §4.7) needs no script: it opens, closes |
| + // and takes focus by itself, and posts; a refusal is then the New page |
| + // screen. This keeps a refusal in the popover, beside what was typed, |
| + // holds the POST for HOLD_MS as busy.js holds a form (so busy.js leaves |
| + // this one alone), and gives focus back to the button after Esc: WebKit |
| + // does not focus a button on a click, so it would leave focus nowhere. |
| + var HOLD_MS = 650; |
| + |
| + function newTeamPage() { |
| + var pop = document.getElementById("mapa-new-page"); |
| + var form = pop && pop.querySelector("form[mapa-new-page-form]"); |
| + var opener = document.querySelector("[mapa-new-page-open]"); |
| + if (!form || !opener || typeof pop.showPopover !== "function") return; |
| + var field = form.querySelector('input[name="title"]'); |
| + var said = form.querySelector("[mapa-new-page-error]"); |
| + var button = form.querySelector('button[type="submit"]'); |
| + var escaped = false, sending = false; |
| + form.setAttribute("data-busy", "false"); |
| + pop.addEventListener("keydown", function (event) { |
| + if (event.key === "Escape") escaped = true; |
| + }); |
| + pop.addEventListener("toggle", function (event) { |
| + if (event.newState === "open") { escaped = false; return; } |
| + // WebKit still names the hidden field as focused here. |
| + var here = document.activeElement; |
| + if (escaped && (!here || here === document.body || pop.contains(here))) { |
| + opener.focus({ preventScroll: true }); |
| + } |
| + }); |
| + field.addEventListener("input", function () { say(""); }); |
| + |
| + // say shows a refusal under the field, or clears it. |
| + function say(text, taken) { |
| + said.textContent = text; |
| + said.hidden = !text; |
| + if (taken) { |
| + var link = document.createElement("a"); |
| + link.href = taken; |
| + link.textContent = "Open the page with that title"; |
| + said.append(" ", link); |
| + } |
| + if (text) { |
| + field.setAttribute("aria-invalid", "true"); |
| + field.setAttribute("aria-describedby", "mapa-new-page-error mapa-new-page-said"); |
| + } else { |
| + field.removeAttribute("aria-invalid"); |
| + field.setAttribute("aria-describedby", "mapa-new-page-said"); |
| + } |
| + } |
| + |
| + function busy(on) { |
| + sending = on; |
| + button.disabled = on; |
| + var spin = button.querySelector("[rst-spin]"); |
| + if (on && !spin) { |
| + spin = document.createElement("span"); |
| + spin.setAttribute("rst-spin", ""); |
| + spin.setAttribute("aria-hidden", "true"); |
| + button.insertBefore(spin, button.firstChild); |
| + } else if (!on && spin) { |
| + spin.remove(); |
| + } |
| + if (on) button.setAttribute("aria-busy", "true"); else button.removeAttribute("aria-busy"); |
| + } |
| + |
| + form.addEventListener("submit", function (event) { |
| + event.preventDefault(); |
| + if (sending) return; |
| + busy(true); |
| + var wait = new Promise(function (resolve) { setTimeout(resolve, HOLD_MS); }); |
| + var sent = post(form.action, { title: field.value }).then(function (response) { |
| + return response.json().then(function (reply) { return { ok: response.ok, reply: reply }; }); |
| + }); |
| + Promise.all([sent, wait]).then(function (both) { |
| + var answer = both[0]; |
| + if (answer.ok && answer.reply.href) { |
| + window.location.assign(answer.reply.href); |
| + return; |
| + } |
| + if (!answer.reply.error) throw new Error("no answer"); |
| + busy(false); |
| + say(answer.reply.error, answer.reply.taken); |
| + field.focus(); |
| + }).catch(function () { |
| + busy(false); |
| + say("The page could not be created just now. Try again."); |
| + field.focus(); |
| + }); |
| + }); |
| + } |
| + |
| // ---- Start ---------------------------------------------------------------- |
| function start() { |
| @@ -743,6 +835,7 @@ |
| fold(); |
| } |
| }); |
| + newTeamPage(); |
| offerZone(); |
| } |
diff --git a/internal/mapa/templates/frame.html b/internal/mapa/templates/frame.html| index cfa281f..8507aa0 100644 |
| --- a/internal/mapa/templates/frame.html |
| +++ b/internal/mapa/templates/frame.html |
| @@ -133,15 +133,10 @@ |
| {{- range .}}{{template "mapa-side-link" .}}{{end}} |
| {{- end}} |
| <div mapa-side-foot> |
| - <details mapa-new-page name="estilo-menus"> |
| - <summary mapa-side-item>{{icon "plus"}}<span mapa-side-label>New team page</span></summary> |
| - <form method="post" action="/pages" mapa-new-page-form> |
| - <label for="mapa-new-title">Title of the new team page</label> |
| - <input rst-input id="mapa-new-title" name="title" required maxlength="120" autocomplete="off"> |
| - <p mapa-meta>Everyone in the team can open it.</p> |
| - <button rst-btn="primary" type="submit">Create page</button> |
| - </form> |
| - </details> |
| + {{- /* New team page (§4.7) opens mapa-new-page, a popover. The link |
| + is for an engine without popovers (frame.css shows it there). */}} |
| + <button mapa-side-item type="button" popovertarget="mapa-new-page" mapa-new-page-open>{{icon "plus"}}<span mapa-side-label>New team page</span></button> |
| + <a mapa-side-item href="/new" mapa-new-page-link>{{icon "plus"}}<span mapa-side-label>New team page</span></a> |
| <form method="post" action="/view/sidebar" mapa-fold> |
| <input type="hidden" name="return" value="{{.Return}}"> |
| <button mapa-side-item type="submit" name="state" value="rail" mapa-fold-to="rail" data-mapa-command="toggle-sidebar">{{icon "panel-left"}}<span mapa-side-label>Fold sidebar</span><kbd mapa-kbd aria-hidden="true">⌘\</kbd></button> |
| @@ -151,6 +146,22 @@ |
| </nav>{{end}} |
| {{define "mapa-side-link"}}<a mapa-side-item mapa-side-page href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{icon .Icon}}<span mapa-side-label>{{.Label}}</span></a>{{end}} |
| +{{/* mapa-new-page: New team page's popover (§4.7), opened by the |
| + sidebar's button. In the top layer, so the sidebar's scrolling never |
| + clips it, and the platform's own Esc, click outside and focus, with |
| + no script. Drawn after <main>: WebKit gives the page's autofocus to |
| + the first [autofocus] in the document, even a hidden one, so this |
| + field must come after a screen's own. */}} |
| +{{define "mapa-new-page"}}<div popover id="mapa-new-page" mapa-new-page role="dialog" aria-label="New team page"> |
| + <form method="post" action="/pages" mapa-new-page-form> |
| + <label for="mapa-new-title">Title of the new team page</label> |
| + <input rst-input id="mapa-new-title" name="title" required maxlength="120" autocomplete="off" autofocus aria-describedby="mapa-new-page-said"> |
| + <p rst-field-error mapa-new-page-error id="mapa-new-page-error" role="alert" hidden></p> |
| + <p mapa-meta id="mapa-new-page-said">Everyone in the team can open it.</p> |
| + <button rst-btn="primary" type="submit">Create page</button> |
| + </form> |
| +</div>{{end}} |
| + |
| {{/* mapa-keys: Help → Keyboard shortcuts. A <dialog> estilo's invoker |
| command opens, with no script. */}} |
| {{define "mapa-keys"}}<dialog id="mapa-keys" mapa-dialog aria-labelledby="mapa-keys-title"> |
diff --git a/internal/mapa/templates/page_new.html b/internal/mapa/templates/page_new.html| index b6289f7..fddc402 100644 |
| --- a/internal/mapa/templates/page_new.html |
| +++ b/internal/mapa/templates/page_new.html |
| @@ -1,10 +1,14 @@ |
| {{define "content"}} |
| {{template "back-nav" dict "Href" "/pages" "Label" "Pages"}} |
| {{template "page-header" dict "Title" "New page" "Sub" "A team page: everyone in the team can open it, and its title is the team's."}} |
| -<form rst-form method="post" action="{{.Data.Action}}" mapa-edit-form> |
| +{{/* One title field, as the sidebar's popover (level-up §4.7): the page |
| + opens once it is made, and its text is written there. A body that |
| + came with a refused POST rides along unseen, so nothing typed is |
| + lost. */}} |
| +<form rst-form method="post" action="{{.Data.Action}}"> |
| {{template "field-text" dict "Name" "title" "Label" "Title" "Value" .Data.Title "Error" .Data.Error "Required" true "Autofocus" true}} |
| {{with .Data.Taken}}<p mapa-meta><a href="{{.}}">Open the page with that title</a></p>{{end}} |
| -{{template "mapa-editor" dict "Body" .Data.Body}} |
| +{{with .Data.Body}}<input type="hidden" name="body" value="{{.}}">{{end}} |
| {{template "form-foot" dict "Submit" .Data.Label "CancelHref" "/pages" "CancelLabel" "Cancel"}} |
| </form> |
| {{end}} |
diff --git a/internal/mapa/templates/partials.html b/internal/mapa/templates/partials.html| index 423688f..ec18b14 100644 |
| --- a/internal/mapa/templates/partials.html |
| +++ b/internal/mapa/templates/partials.html |
| @@ -60,7 +60,7 @@ |
| on the editor itself), Day (*dayPill, daily notes), Rename (the |
| rename POST, on a team page the editor mounts on; "" elsewhere). |
| With Rename, the editor's script makes the title's text editable |
| - in place (editor/title.mjs, build note 77); without script it is |
| + in place (editor/title.mjs, build note 78); without script it is |
| the plain heading it always was. */}} |
| {{define "mapa-doc-head"}}{{$page := .Page}}<header mapa-page-head> |
| <div mapa-doc-kicker> |
diff --git a/internal/mapa/templates/shell.html b/internal/mapa/templates/shell.html| index 9bfe97e..e3ccd36 100644 |
| --- a/internal/mapa/templates/shell.html |
| +++ b/internal/mapa/templates/shell.html |
| @@ -41,6 +41,7 @@ |
| {{template "content" .}} |
| </div> |
| </main> |
| +{{template "mapa-new-page"}} |
| {{with .Frame.History}}{{template "mapa-history" .}}{{end}} |
| </div> |
| {{template "mapa-keys"}} |
diff --git a/internal/mapatest/browser_test.go b/internal/mapatest/browser_test.go| index c4691e4..678cae4 100644 |
| --- a/internal/mapatest/browser_test.go |
| +++ b/internal/mapatest/browser_test.go |
| @@ -146,10 +146,7 @@ func walk(t *testing.T, rig *harness.Rig, store *mapa.Store, live bool) { |
| searchByPage(t, rig) |
| } |
| rig.Screen(`main input[name="title"]`, "create, offered") |
| - drive(t, rig, |
| - chromedp.SendKeys("textarea[mapa-editor]", "Acme is a customer."), |
| - press(save), |
| - ) |
| + createAcme(t, rig) |
| rig.Screen("header[mapa-page-head]", "the new page") |
| if !strings.Contains(text(t, rig, "#backlinks ~ *, [mapa-linked]"), |
| "November") { |
| @@ -162,6 +159,19 @@ func walk(t *testing.T, rig *harness.Rig, store *mapa.Store, live bool) { |
| historyAndRestore(t, rig) |
| } |
| +// createAcme creates the offered page, then writes its text. New page |
| +// is one title field (build note 77), so the text is written on the |
| +// page, here through Edit as Markdown, the floor. |
| +func createAcme(t *testing.T, rig *harness.Rig) { |
| + t.Helper() |
| + drive(t, rig, press(save), chromedp.WaitVisible("h1[mapa-title]")) |
| + path := strings.TrimPrefix(read(t, rig, chromedp.Location()), |
| + rig.Origin) |
| + drive(t, rig, chromedp.Navigate(rig.Origin+path+"/edit"), |
| + chromedp.SendKeys("textarea[mapa-editor]", "Acme is a customer."), |
| + press(save)) |
| +} |
| + |
| // writeToday writes today's note: in the page editor with scripts, and |
| // with them off through Edit as Markdown, the floor (level-up §6.10). |
| func writeToday(t *testing.T, rig *harness.Rig, live bool) { |
diff --git a/internal/mapatest/gate1_test.go b/internal/mapatest/gate1_test.go| index f4c9a57..5cf11ef 100644 |
| --- a/internal/mapatest/gate1_test.go |
| +++ b/internal/mapatest/gate1_test.go |
| @@ -130,7 +130,7 @@ func boSees(t *testing.T, rig *rig, acme string) map[string]string { |
| updated := rig.post(t, Bo, acme+"/links", nil) |
| seen["links report"] = updated.Header().Get("Location") |
| seen["after"] = rig.page(t, Bo, acme) |
| - // The in-page title's answers (build note 77): the offer's count and |
| + // The in-page title's answers (build note 78): the offer's count and |
| // the old titles, as JSON. Revisions are random in both worlds. |
| _, inPlace := rig.postJSON(Bo, acme+"/rename", |
| url.Values{"title": {"Acme Group"}}) |
diff --git a/internal/mapatest/layout_browser_test.go b/internal/mapatest/layout_browser_test.go| index 79e489a..f95c17e 100644 |
| --- a/internal/mapatest/layout_browser_test.go |
| +++ b/internal/mapatest/layout_browser_test.go |
| @@ -137,7 +137,7 @@ func walkRename(t *testing.T, rig *harness.Rig, path string) { |
| func walkNewAndShare(t *testing.T, rig *harness.Rig) { |
| t.Helper() |
| drive(t, rig, chromedp.Navigate(rig.Origin+"/pages"), |
| - chromedp.Click(`[mapa-new-page] > summary`), |
| + chromedp.Click(opener), |
| chromedp.SendKeys(`#mapa-new-title`, "From the sidebar"), |
| chromedp.Submit(`#mapa-new-title`), |
| chromedp.WaitVisible("h1[mapa-title]")) |
diff --git a/internal/mapatest/newpage_browser_test.go b/internal/mapatest/newpage_browser_test.go| new file mode 100644 |
| index 0000000..206db57 |
| --- /dev/null |
| +++ b/internal/mapatest/newpage_browser_test.go |
| @@ -0,0 +1,258 @@ |
| +//go:build browser |
| + |
| +package mapatest |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "github.com/chromedp/cdproto/cdp" |
| + "github.com/chromedp/cdproto/input" |
| + "github.com/chromedp/cdproto/network" |
| + "github.com/chromedp/chromedp" |
| +) |
| + |
| +// New team page (level-up §4.7) and the rail's tooltips (§3.2), in |
| +// Chromium (build note 77). The sidebar scrolls (overflow: auto), and |
| +// everything that left it was clipped: the popover's right side in the |
| +// open sidebar, all of it beside the rail, and every tooltip. Each check |
| +// asks the page what a pointer would hit at the corners of what must be |
| +// seen, so a box that is laid out but cut off fails. |
| + |
| +// opener is the sidebar's New team page control, as either shape has |
| +// drawn it (a <details>' summary before build note 77, now a button). |
| +const opener = `[mapa-side-foot] ` + |
| + `:is(summary, [popovertarget])[mapa-side-item]` |
| + |
| +// sideCookie sets the mapa-sidebar cookie, or deletes it for "". |
| +func sideCookie(rig *harness.Rig, |
| + state string) chromedp.Action[chromedp.Void] { |
| + return chromedp.Func(func(ctx context.Context, |
| + target *chromedp.Target) error { |
| + where := rig.Origin + "/" |
| + if state == "" { |
| + _, err := cdp.Call(ctx, target, network.DeleteCookies, |
| + network.DeleteCookiesParams{Name: "mapa-sidebar", URL: where}) |
| + return err |
| + } |
| + _, err := cdp.Call(ctx, target, network.SetCookie, |
| + network.SetCookieParams{Name: "mapa-sidebar", Value: state, |
| + URL: where}) |
| + return err |
| + }) |
| +} |
| + |
| +// cornersHit is, for each part inside box, every corner (3px in, past |
| +// a rounded border) where the topmost element is not inside box: "" |
| +// when the whole of every part can be seen and clicked. |
| +const cornersHit = `(function (box, parts) { |
| + var holder = document.querySelector(box), misses = []; |
| + parts.forEach(function (part) { |
| + var el = holder && holder.querySelector(part); |
| + if (!el) { misses.push(part + " is not drawn"); return; } |
| + var r = el.getBoundingClientRect(); |
| + [[r.left + 3, r.top + 3], [r.right - 3, r.top + 3], |
| + [r.left + 3, r.bottom - 3], [r.right - 3, r.bottom - 3] |
| + ].forEach(function (p) { |
| + var hit = document.elementFromPoint(p[0], p[1]); |
| + if (hit && holder.contains(hit)) return; |
| + misses.push(part + " at " + Math.round(p[0]) + "," + Math.round(p[1]) + |
| + " is " + (hit ? hit.tagName.toLowerCase() : "off the screen")); |
| + }); |
| + }); |
| + return misses.join("; "); |
| +})(%q, ["input[name=title]", "button[type=submit]"])` |
| + |
| +// sideCase is one sidebar state at one width: the cookie ("" for none) |
| +// and what the sidebar shows then. |
| +type sideCase struct { |
| + width int64 |
| + cookie, show string |
| +} |
| + |
| +var sideCases = []sideCase{ |
| + {1400, "", "open"}, {1400, "rail", "rail"}, {1400, "open", "open"}, |
| + {900, "", "rail"}, {900, "open", "open"}, {900, "rail", "rail"}, |
| +} |
| + |
| +// From the sidebar, in every state, scripts off and on: the whole form |
| +// is on top, focus is in the title, and Enter creates the page and opens |
| +// it. At 390 there is no sidebar: Page → New team page is the screen. |
| +func TestNewTeamPageShowsTheWholeForm(t *testing.T) { |
| + rig, _ := browserRig(t, 1) |
| + for _, live := range []bool{false, true} { |
| + for number, each := range sideCases { |
| + name := fmt.Sprintf("%dpx, %s (cookie %q), scripts %v", |
| + each.width, each.show, each.cookie, live) |
| + drive(t, rig, scripts(live), sideCookie(rig, each.cookie), |
| + chromedp.EmulateViewport(each.width, 877), |
| + chromedp.Navigate(rig.Origin+"/pages"), |
| + chromedp.WaitVisible("main h1"), |
| + chromedp.Click(opener), chromedp.WaitVisible("#mapa-new-title")) |
| + title := fmt.Sprintf("Sidebar %d %v", number, live) |
| + createFrom(t, rig, name, "form[mapa-new-page-form]", |
| + "mapa-new-title", title) |
| + } |
| + name := fmt.Sprintf("390px, Page menu, scripts %v", live) |
| + drive(t, rig, scripts(live), sideCookie(rig, ""), |
| + chromedp.EmulateViewport(390, 844), |
| + chromedp.Navigate(rig.Origin+"/pages"), |
| + chromedp.Click(pageMenu), |
| + chromedp.Click(`#mapa-menu-page a[href="/new"]`), |
| + chromedp.WaitVisible(`main input[name="title"]`)) |
| + createFrom(t, rig, name, `main form[action="/pages"]`, "title", |
| + fmt.Sprintf("Phone %v", live)) |
| + } |
| +} |
| + |
| +// createFrom checks the open form, then types title into whatever has |
| +// focus and presses Enter, as a person would, and waits for the page. |
| +func createFrom(t *testing.T, rig *harness.Rig, name, form, field, |
| + title string) { |
| + t.Helper() |
| + if misses := read(t, rig, chromedp.Evaluate[string]( |
| + fmt.Sprintf(cornersHit, form))); misses != "" { |
| + t.Errorf("%s: the form is not all on top: %s", name, misses) |
| + } |
| + focus := read(t, rig, chromedp.Evaluate[string]( |
| + `document.activeElement.id || document.activeElement.name || ""`)) |
| + if focus != field { |
| + t.Errorf("%s: focus is on %q, not the title", name, focus) |
| + } |
| + drive(t, rig, chromedp.KeyEvent(title), chromedp.KeyEvent("\r")) |
| + if !landsOn(t, rig, title) { |
| + t.Errorf("%s: Enter did not open a page titled %q", name, title) |
| + } |
| +} |
| + |
| +// landsOn waits up to five seconds for a page titled title. |
| +func landsOn(t *testing.T, rig *harness.Rig, title string) bool { |
| + t.Helper() |
| + check := fmt.Sprintf(`location.pathname.indexOf("/p/") === 0 && |
| + (document.querySelector("h1[mapa-title]") || {}).textContent === %q`, |
| + title) |
| + for range 50 { |
| + if read(t, rig, chromedp.Evaluate[bool](check)) { |
| + return true |
| + } |
| + time.Sleep(100 * time.Millisecond) |
| + } |
| + return false |
| +} |
| + |
| +// A taken title is refused where it was typed, and what was typed |
| +// stays: in the popover with scripts, on the New page screen without. |
| +func TestNewTeamPageRefusesATakenTitleInPlace(t *testing.T) { |
| + rig, store := browserRig(t, 0) |
| + if _, err := store.CreateTeamPage(context.Background(), Bo, |
| + "Onboarding", ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + rig.Allow("POST", "/pages", 422) |
| + for _, live := range []bool{false, true} { |
| + drive(t, rig, scripts(live), chromedp.EmulateViewport(1400, 877), |
| + chromedp.Navigate(rig.Origin+"/pages"), |
| + chromedp.Click(opener), chromedp.WaitVisible("#mapa-new-title"), |
| + chromedp.KeyEvent("Onboarding"), chromedp.KeyEvent("\r"), |
| + chromedp.Sleep(1200*time.Millisecond)) |
| + where := `[mapa-new-page]:popover-open` |
| + if !live { |
| + where = "main" |
| + } |
| + said := read(t, rig, chromedp.Evaluate[string](fmt.Sprintf( |
| + `(document.querySelector(%q) || {}).textContent || ""`, |
| + where+" [rst-field-error]:not([hidden])"))) |
| + kept := read(t, rig, chromedp.Evaluate[string](fmt.Sprintf( |
| + `(document.querySelector(%q) || {}).value || ""`, |
| + where+` input[name="title"]`))) |
| + if !strings.Contains(said, "already exists") || kept != "Onboarding" { |
| + t.Errorf("scripts %v: refusal %q, field %q", live, said, kept) |
| + } |
| + } |
| +} |
| + |
| +// The New page screen's Create and Cancel sit under its one field, as |
| +// on every other form (they were under a borderless body field half the |
| +// window tall). |
| +func TestTheNewPageScreenKeepsItsButtonsUnderTheField(t *testing.T) { |
| + rig, _ := browserRig(t, 1) |
| + gap := `Math.round(document.querySelector('main [rst-form-foot]')` + |
| + `.getBoundingClientRect().top - document.querySelector(` + |
| + `'main input[name="title"]').getBoundingClientRect().bottom)` |
| + for _, live := range []bool{false, true} { |
| + for _, size := range [][2]int64{{1402, 877}, {390, 844}} { |
| + drive(t, rig, scripts(live), |
| + chromedp.EmulateViewport(size[0], size[1]), |
| + chromedp.Navigate(rig.Origin+"/new"), |
| + chromedp.WaitVisible(`main input[name="title"]`)) |
| + if got := read(t, rig, chromedp.Evaluate[int](gap)); got < 0 || |
| + got > 48 { |
| + t.Errorf("%dx%d, scripts %v: the buttons are %dpx under "+ |
| + "the field", size[0], size[1], live, got) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// labelSeen is "" when the hovered row's tooltip can be hit at all four |
| +// corners; it takes pointer events for the moment it is asked. |
| +const labelSeen = `(function (row) { |
| + var label = document.querySelector(row + " [mapa-side-label]"); |
| + label.style.pointerEvents = "auto"; |
| + var r = label.getBoundingClientRect(), misses = []; |
| + [[r.left + 3, r.top + 3], [r.right - 3, r.top + 3], |
| + [r.left + 3, r.bottom - 3], [r.right - 3, r.bottom - 3] |
| + ].forEach(function (p) { |
| + if (!label.contains(document.elementFromPoint(p[0], p[1]))) { |
| + misses.push(Math.round(p[0]) + "," + Math.round(p[1])); |
| + } |
| + }); |
| + label.style.pointerEvents = ""; |
| + return misses.length ? label.textContent + " cut off at " + |
| + misses.join(" ") : ""; |
| +})(%q)` |
| + |
| +// Every row of the rail shows its whole tooltip on hover: by width with |
| +// no cookie, and by cookie on a wide window. |
| +func TestTheRailsTooltipsAreWhole(t *testing.T) { |
| + rig, _ := browserRig(t, 1, harness.WithHover()) |
| + mark := `Array.prototype.filter.call(document.querySelectorAll(` + |
| + `"[mapa-side] [mapa-side-item]"), function (row) {` + |
| + ` return row.offsetParent !== null; }).map(function (row, i) {` + |
| + ` row.setAttribute("data-gate-row", i); return i; }).length` |
| + for _, each := range []sideCase{{900, "", "rail"}, {1400, "rail", "rail"}} { |
| + drive(t, rig, sideCookie(rig, each.cookie), |
| + chromedp.EmulateViewport(each.width, 877), |
| + chromedp.Navigate(rig.Origin+"/pages"), |
| + chromedp.WaitVisible("main h1")) |
| + rows := read(t, rig, chromedp.Evaluate[int](mark)) |
| + for row := range rows { |
| + selector := fmt.Sprintf(`[data-gate-row="%d"]`, row) |
| + drive(t, rig, rest(selector)) |
| + if miss := read(t, rig, chromedp.Evaluate[string]( |
| + fmt.Sprintf(labelSeen, selector))); miss != "" { |
| + t.Errorf("%dpx (cookie %q): %s", each.width, each.cookie, miss) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// rest moves a hovering mouse to the middle of selector's element. |
| +func rest(selector string) chromedp.Action[chromedp.Void] { |
| + return chromedp.Func(func(ctx context.Context, |
| + target *chromedp.Target) error { |
| + box, err := chromedp.Run(ctx, chromedp.Dimensions(selector)) |
| + if err != nil { |
| + return err |
| + } |
| + quad := box.Content |
| + across, down := (quad[0]+quad[4])/2, (quad[1]+quad[5])/2 |
| + return chromedp.Do(ctx, chromedp.MouseEvent( |
| + input.DispatchMouseEventTypeMouseMoved, across, down), |
| + chromedp.Sleep(80*time.Millisecond)) |
| + }) |
| +} |
diff --git a/internal/mapatest/share_json_test.go b/internal/mapatest/share_json_test.go| index 17f5b23..3c447ac 100644 |
| --- a/internal/mapatest/share_json_test.go |
| +++ b/internal/mapatest/share_json_test.go |
| @@ -39,3 +39,30 @@ func TestMakeTeamPageAnswersTheEditor(t *testing.T) { |
| t.Fatal("the new team page does not hold the blocks") |
| } |
| } |
| + |
| +// New team page's popover (level-up §4.7, build note 77): with Accept |
| +// JSON, POST /pages answers the new page's address, and a refused title |
| +// is the sentence, as JSON, with nothing written. |
| +func TestNewTeamPageAnswersThePopover(t *testing.T) { |
| + rig := newRig(t) |
| + taken := rig.createPage(t, Bo, "Taken", "") |
| + pages := rig.count(t, "pages") |
| + for _, title := range []string{"Taken", " "} { |
| + code, refused := rig.postJSON(Ana, "/pages", |
| + url.Values{"title": {title}}) |
| + if code != http.StatusUnprocessableEntity || refused["error"] == "" || |
| + rig.count(t, "pages") != pages { |
| + t.Fatalf("%q: %d %v", title, code, refused) |
| + } |
| + if title == "Taken" && refused["taken"] != taken { |
| + t.Fatalf("a taken title points to %v, not %s", refused["taken"], |
| + taken) |
| + } |
| + } |
| + code, reply := rig.postJSON(Ana, "/pages", url.Values{"title": {"Fresh"}}) |
| + href, _ := reply["href"].(string) |
| + if code != http.StatusOK || !strings.HasPrefix(href, "/p/") || |
| + !strings.Contains(rig.page(t, Bo, href), "Fresh") { |
| + t.Fatalf("POST /pages answered %d %v", code, reply) |
| + } |
| +} |
diff --git a/internal/mapatest/title_browser_test.go b/internal/mapatest/title_browser_test.go| index b4e24bb..d9d42a0 100644 |
| --- a/internal/mapatest/title_browser_test.go |
| +++ b/internal/mapatest/title_browser_test.go |
| @@ -15,7 +15,7 @@ import ( |
| "amadan.net/oficina/mapa/internal/mapa" |
| ) |
| -// The in-page title (level-up §4.1, build note 77), in a real Chromium |
| +// The in-page title (level-up §4.1, build note 78), in a real Chromium |
| // through the real server: click it, type, Enter renames, and the |
| // header, the sidebar, the tab's title and the links offer follow with |
| // no reload; Esc writes nothing; a refusal is said beside it and keeps |
diff --git a/internal/mapatest/title_quality_browser_test.go b/internal/mapatest/title_quality_browser_test.go| index c3779c8..53ccff4 100644 |
| --- a/internal/mapatest/title_quality_browser_test.go |
| +++ b/internal/mapatest/title_quality_browser_test.go |
| @@ -13,7 +13,7 @@ import ( |
| "amadan.net/oficina/mapa/internal/mapa" |
| ) |
| -// The in-page title's quality gates (build note 77): no shift, the |
| +// The in-page title's quality gates (build note 78): no shift, the |
| // body's typing and draft untouched by a rename, and axe. |
| // headBoxes is the page head's boxes (the kicker, the H1, the editable |
diff --git a/internal/mapatest/title_test.go b/internal/mapatest/title_test.go| index b7748f4..356b98c 100644 |
| --- a/internal/mapatest/title_test.go |
| +++ b/internal/mapatest/title_test.go |
| @@ -7,7 +7,7 @@ import ( |
| "testing" |
| ) |
| -// The in-page title (level-up §4.1, build note 77): the H1 and the |
| +// The in-page title (level-up §4.1, build note 78): the H1 and the |
| // header rename through POST /p/{id}/rename asking for JSON, which |
| // answers the title, the revisions, and the confirm page's honest |
| // count; a refusal is the form's sentence and writes nothing; Update |