| index 66a414f..26de00a 100644 |
| --- a/internal/slidestest/browser_quieter_test.go |
| +++ b/internal/slidestest/browser_quieter_test.go |
| @@ -474,6 +474,48 @@ func boxMenuInWindow(t *testing.T, te *tidyEditor) string { |
| return strings.Trim(strings.Join([]string{button, menu}, "; "), "; ") |
| } |
| |
| +// segRoomJS reports, for the card's segments of radio group name, each |
| +// segment whose words have under 6px of room either side inside it, or |
| +// that runs out of the card, with each of its segments selected in turn |
| +// (the selected one is bold). The radios are set without an event, so |
| +// the document is not changed; the one that was set is put back. |
| +const segRoomJS = `(name => { |
| + const inputs = [...document.querySelectorAll('[slides-inspector] input[name="' + name + '"]')] |
| + const was = inputs.find(i => i.checked), out = [] |
| + if (!inputs.length || !inputs[0].checkVisibility()) return name + ' is not drawn' |
| + const card = inputs[0].closest('[estilo-inspector-group]').getBoundingClientRect() |
| + for (const pick of inputs) { |
| + pick.checked = true |
| + for (const i of inputs) { |
| + const seg = i.closest('[estilo-seg-item]'), r = seg.getBoundingClientRect() |
| + const words = [...seg.childNodes].find(n => n.nodeType === 3 && n.textContent.trim()), q = document.createRange() |
| + q.selectNodeContents(words) |
| + const w = q.getBoundingClientRect(), room = Math.min(w.left - r.left, r.right - w.right) |
| + if (room < 6) out.push(words.textContent.trim() + ' has ' + room.toFixed(1) + 'px of room with ' + pick.value + ' selected') |
| + if (r.left < card.left - 0.5 || r.right > card.right + 0.5) out.push(words.textContent.trim() + ' runs out of the card') |
| + } |
| + } |
| + if (was) was.checked = true |
| + return out.join('; ') |
| +})` |
| + |
| +// TestQuieterSegmentsHaveRoom (review V2): the card's worded segments |
| +// (a heading's Level, a text's Size) size to their words, each with room |
| +// inside its segment, selected or not, and the group fits the card. |
| +func TestQuieterSegmentsHaveRoom(t *testing.T) { |
| + te := openTidyEditorOn(t, 1280, 720, func(a *testApp, cookies []*http.Cookie) string { return quieterDeck(t, a, cookies, boxMenuDeck) }) |
| + for _, c := range []struct{ id, name string }{{"boxhead00001", "rst-block-level"}, {"boxtext00001", "rst-block-size"}} { |
| + te.selectBoxByID(t, c.id) |
| + var got string |
| + te.rig.Run(chromedp.Evaluate(segRoomJS+`(`+jsString(c.name)+`)`, &got)) |
| + if got != "" { |
| + t.Errorf("%s: %s", c.name, got) |
| + } |
| + } |
| + te.selectBoxByID(t, "boxhead00001") |
| + te.rig.Screen(`[slides-inspector]`, "a heading's level, three worded segments") |
| +} |
| + |
| // TestQuieterEmptyDeck: a deck with no slides. |
| func TestQuieterEmptyDeck(t *testing.T) { |
| te := newTidyEditor(t, 1280, 720, func(a *testApp, cookies []*http.Cookie) string { return emptyDeck(t, a, cookies) }) |