Help: one click opens the manual, two quick clicks the note; the manual styled
One click on Help shows the explanations of every command in one window, the names in a sans-serif and the explanations in a serif, with a 2em margin; Copy copies them as plain text. Two quick clicks show the note about the documentation site. The closed window is not displayed (a layout rule had shown it empty on the start screen). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
24a6a2595b
commit
5d63a0f758
5 files changed
+156
-38
No files matched your search
+59
-12
@@ -2107,12 +2107,19 @@ class EndToEndTest(unittest.TestCase):
|
||||
def test_page_menu_and_help(self):
|
||||
"""Andy, 2026-10-14: the page and view commands are in a Page menu,
|
||||
a popup of Kokkoja's own under the button, closed by a press on an
|
||||
item, elsewhere, or Escape; Help shows a note for now; one popup
|
||||
at a time."""
|
||||
item, elsewhere, or Escape; one popup at a time. Help (Andy,
|
||||
2026-10-15): one click shows the manual, two quick clicks the note
|
||||
about the documentation site."""
|
||||
firefox = self.firefox
|
||||
firefox.go(self.address("Late"))
|
||||
# The closed manual window is not displayed, on the start screen
|
||||
# or in the session (a layout rule on the dialog itself had
|
||||
# overridden the browser's display: none, 2026-10-15).
|
||||
displayed = lambda: firefox.run("return getComputedStyle(document.getElementById('manual_dialog')).display;")
|
||||
self.assertEqual(displayed(), "none")
|
||||
self.enter_name("Menuist", "start_session")
|
||||
self.wait_until(lambda s: s["page"]["number"] == 1, "the page")
|
||||
self.assertEqual(displayed(), "none")
|
||||
hidden = lambda id: firefox.run(f"return document.getElementById('{id}').hidden;")
|
||||
click = lambda id: firefox.run(f"document.getElementById('{id}').click();")
|
||||
box = lambda id: firefox.run(f"const b = document.getElementById('{id}').getBoundingClientRect(); return [b.left, b.top, b.right, b.bottom];")
|
||||
@@ -2157,32 +2164,54 @@ class EndToEndTest(unittest.TestCase):
|
||||
firefox.run("document.getElementById('page').dispatchEvent(new PointerEvent('pointerdown', {bubbles: true}));")
|
||||
self.assertTrue(hidden("page_menu"))
|
||||
|
||||
# Help: a note for now; opening it closes the menu, and the reverse.
|
||||
# Help, two quick clicks: the note about the documentation site;
|
||||
# opening it closes the menu, and the reverse.
|
||||
click("page_menu_button")
|
||||
click("help")
|
||||
double_click = lambda id: firefox.run(f"const b = document.getElementById('{id}'); b.click(); b.click();")
|
||||
double_click("help")
|
||||
self.assertFalse(hidden("help_popup"))
|
||||
self.assertTrue(hidden("page_menu"))
|
||||
# At the far right, the note's right edge aligns with the button's, inside the window.
|
||||
help_button, note = box("help"), box("help_popup")
|
||||
self.assertAlmostEqual(note[2], help_button[2], delta=1)
|
||||
self.assertLess(note[2], firefox.run("return window.innerWidth;"))
|
||||
self.assertEqual(firefox.run("return document.getElementById('help_popup').textContent.trim();"), "Help is coming!")
|
||||
self.assertEqual(firefox.run("return document.getElementById('help_popup').textContent.trim();"), "Documentation website coming soon!")
|
||||
time.sleep(0.6)
|
||||
self.assertFalse(firefox.run("return document.getElementById('manual_dialog').open;"), "two clicks do not open the manual")
|
||||
click("page_menu_button")
|
||||
self.assertTrue(hidden("help_popup"))
|
||||
self.assertFalse(hidden("page_menu"))
|
||||
firefox.chord("\ue00c")
|
||||
|
||||
# Ctrl-click on Help: the tooltips of every command as one text, in
|
||||
# a window: the title, then each control in alphabetical order,
|
||||
# its name on a line, its explanation wrapped at 80 columns, and
|
||||
# a blank line after.
|
||||
firefox.run("document.getElementById('help').dispatchEvent(new MouseEvent('click', {ctrlKey: true, bubbles: true}));")
|
||||
self.assertTrue(firefox.run("return document.getElementById('manual_dialog').open;"))
|
||||
# One click on Help: the manual, the tooltips of every command in a
|
||||
# window, once the interval for a second click has passed. The
|
||||
# title, then each control in alphabetical order, its name in the
|
||||
# interface's sans-serif and its explanation in a serif below; the
|
||||
# window's contents 2em from its edges.
|
||||
click("help")
|
||||
self.assertFalse(firefox.run("return document.getElementById('manual_dialog').open;"), "not before the interval")
|
||||
self.wait_until_true(lambda: firefox.run("return document.getElementById('manual_dialog').open;"), bool, "the manual", seconds=3)
|
||||
self.assertEqual(displayed(), "flex")
|
||||
self.assertTrue(hidden("help_popup"), "the note did not open as well")
|
||||
manual = firefox.run("return document.getElementById('manual_text').textContent;")
|
||||
self.assertEqual(firefox.run("return document.getElementById('manual_text').querySelector('h3').textContent;"), "User interface actions")
|
||||
shown = firefox.run("""
|
||||
const list = document.querySelector('#manual_text dl');
|
||||
return [...list.children].map((e) => [e.tagName, e.textContent, getComputedStyle(e).fontFamily]);
|
||||
""")
|
||||
self.assertEqual([tag for tag, _, _ in shown[::2]], ["DT"] * (len(shown) // 2))
|
||||
self.assertEqual([tag for tag, _, _ in shown[1::2]], ["DD"] * (len(shown) // 2))
|
||||
self.assertTrue(all("sans-serif" in font for _, _, font in shown[::2]), "the names in a sans-serif")
|
||||
self.assertTrue(all(font == "serif" for _, _, font in shown[1::2]), "the explanations in a serif")
|
||||
self.assertEqual(firefox.run("const s = getComputedStyle(document.getElementById('manual_dialog')); return [s.paddingTop, s.paddingRight, s.paddingBottom, s.paddingLeft];"), ["30px"] * 4, "2em at 15px")
|
||||
self.assertEqual(firefox.run("return document.activeElement.id;"), "manual_text")
|
||||
# The text the Copy button copies: the title, then each control in
|
||||
# alphabetical order, its name on a line, its explanation wrapped
|
||||
# at 80 columns, and a blank line after; the same entries as shown.
|
||||
manual = firefox.run("return window.kokkoja.manualText();")
|
||||
self.assertTrue(manual.startswith("User interface actions\n\n"))
|
||||
blocks = manual.split("\n\n")[1:]
|
||||
names = [block.split("\n")[0] for block in blocks if block]
|
||||
self.assertEqual(names, [text for _, text, _ in shown[::2]], "the text and the window agree")
|
||||
self.assertEqual(names, sorted(names, key=str.casefold), "alphabetical")
|
||||
self.assertIn("Pen", names)
|
||||
self.assertIn("Color", names) # the swatches as one entry
|
||||
@@ -2204,8 +2233,26 @@ class EndToEndTest(unittest.TestCase):
|
||||
unwrapped = re.sub(r"\d+(?:\.\d+)?", "#", manual.replace("\n", " "))
|
||||
for help in set(helps):
|
||||
self.assertIn(re.sub(r"\d+(?:\.\d+)?", "#", help), unwrapped, help[:40])
|
||||
self.assertIn("Two quick clicks show where the documentation is.", unwrapped)
|
||||
firefox.run("document.getElementById('manual_close').click();")
|
||||
self.assertFalse(firefox.run("return document.getElementById('manual_dialog').open;"))
|
||||
self.assertEqual(displayed(), "none")
|
||||
# The same with a real mouse: two clicks within the interval show
|
||||
# the note, and the manual does not open; after a click the list
|
||||
# has the focus without a focus ring (the ring is for keyboard
|
||||
# focus).
|
||||
x, y = firefox.run("const b = document.getElementById('help').getBoundingClientRect(); return [Math.round(b.left + b.width / 2), Math.round(b.top + b.height / 2)];")
|
||||
press = [{"type": "pointerDown", "button": 0}, {"type": "pointerUp", "button": 0}]
|
||||
firefox.pointer_actions([{"type": "pointerMove", "duration": 0, "origin": "viewport", "x": x, "y": y},
|
||||
*press, {"type": "pause", "duration": 120}, *press])
|
||||
self.assertFalse(hidden("help_popup"))
|
||||
time.sleep(0.6)
|
||||
self.assertFalse(firefox.run("return document.getElementById('manual_dialog').open;"))
|
||||
firefox.run("document.getElementById('page').dispatchEvent(new PointerEvent('pointerdown', {bubbles: true}));")
|
||||
firefox.pointer_actions([{"type": "pointerMove", "duration": 0, "origin": "viewport", "x": x, "y": y}, *press])
|
||||
self.wait_until_true(lambda: firefox.run("return document.getElementById('manual_dialog').open;"), bool, "the manual", seconds=3)
|
||||
self.assertEqual(firefox.run("const e = document.getElementById('manual_text'); return [document.activeElement.id, getComputedStyle(e).outlineStyle];"), ["manual_text", "none"])
|
||||
firefox.run("document.getElementById('manual_close').click();")
|
||||
|
||||
def test_shrink_ignores_the_invisible(self):
|
||||
"""Andy, 2026-10-14: what cannot be seen does not count for Shrink:
|
||||
|
||||
Reference in new issue
Block a user