Cloudflare Pages / Build and verify the site (push) Successful in 3m29s
Use the verified dependency lock across native hosts and bundled apps. Preserve saved styles, local app reactivation, and offline packages while integrating the latest practice, Habits, Lumi, and figure preview updates.
592 lines
32 KiB
Python
592 lines
32 KiB
Python
"""Lists on a private display, driven through Kryon's test driver.
|
|
|
|
Run by lists_ui_test.sh on its own Xvfb display: list chips choose where a
|
|
task goes, a new list is created with Enter, Share and Invitations open in a
|
|
dialog, and a friend invitation and an accepted invitation are stored as
|
|
durable deliveries without alarming the person when the node is unreachable.
|
|
"""
|
|
|
|
import contextlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import shutil
|
|
import sqlite3
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import time
|
|
|
|
from ui_driver import UiDriver
|
|
|
|
assert os.environ.get("INBE_UI_TEST_XVFB") == "1", "Run tests/lists_ui_test.sh"
|
|
assert not os.environ.get("WAYLAND_DISPLAY") and not os.environ.get("DBUS_SESSION_BUS_ADDRESS")
|
|
BINARY = sys.argv[1]
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
TEST_DIR = ROOT / "build/lists-ui-test"
|
|
TEST_DIR.mkdir(parents=True, exist_ok=True)
|
|
ALARMING = re.compile(r"could|fail|error|unconfirmed", re.IGNORECASE)
|
|
# Shared list ids are UUIDs; the app ignores invitations to anything else.
|
|
SHARED_LIST = "5ad0e7f2-3b1c-4d6e-9f80-a1b2c3d4e5f6"
|
|
OWNED_LIST = "6be1f803-4c2d-4e7f-8091-b2c3d4e5f6a7"
|
|
GIVEN_LIST = "7cf2a914-5d3e-4f80-9102-c3d4e5f6a7b8"
|
|
driver = UiDriver(TEST_DIR / "driver")
|
|
|
|
|
|
def wait_for(predicate, message, timeout=10):
|
|
deadline = time.monotonic() + timeout
|
|
while True:
|
|
result = predicate()
|
|
if result:
|
|
return result
|
|
assert time.monotonic() < deadline, f"FAIL {message() if callable(message) else message} ({TEST_DIR})"
|
|
time.sleep(.05)
|
|
|
|
|
|
with contextlib.ExitStack() as stack:
|
|
temporary = Path(stack.enter_context(tempfile.TemporaryDirectory(prefix="inbe-lists-ui-")))
|
|
log = stack.enter_context((TEST_DIR / "app.log").open("w"))
|
|
# Screenshot mode seeds its own temporary database; the window stays
|
|
# open for the test. Its own start capture goes to a temporary folder.
|
|
app = subprocess.Popen(
|
|
[BINARY, "--screenshot", str(temporary / "start.png"),
|
|
"--bundle", str(ROOT / "build/inbe-full.zx"), "--feature", "lists",
|
|
"--screenshot-scene", "lists", "--screenshot-width", "900", "--screenshot-height", "720",
|
|
"--screenshot-ui-scale", "2", "--screenshot-theme", "0", "--screenshot-dark", "1"],
|
|
env=os.environ | {"APP_SHOT_WINDOW": "1"} | driver.environment(),
|
|
stdout=log, stderr=subprocess.STDOUT)
|
|
database = Path(f"/tmp/inbe-screenshot-{app.pid}/inbe.db")
|
|
|
|
def cleanup():
|
|
if app.poll() is None:
|
|
app.terminate()
|
|
try:
|
|
app.wait(timeout=5)
|
|
except subprocess.TimeoutExpired:
|
|
app.kill()
|
|
app.wait(timeout=5)
|
|
shutil.rmtree(database.parent, ignore_errors=True)
|
|
stack.callback(cleanup)
|
|
driver.attach(app, TEST_DIR / "app.log")
|
|
|
|
def find_window():
|
|
found = subprocess.run(["xdotool", "search", "--onlyvisible", "--pid", str(app.pid)],
|
|
capture_output=True, text=True, timeout=5)
|
|
return found.stdout.split()[0] if found.returncode == 0 and database.exists() else ""
|
|
wait_for(find_window, "isolated app startup", timeout=20)
|
|
driver.wait(label="Shopping", role="button")
|
|
driver.wait(label="Add", role="button")
|
|
driver.wait_idle(frames=3)
|
|
|
|
def sql(query, parameters=()):
|
|
# Read-only, so closing it never checkpoints the running app's WAL.
|
|
uri = database.as_uri() + "?mode=ro"
|
|
with contextlib.closing(sqlite3.connect(uri, uri=True, timeout=2)) as db:
|
|
row = db.execute(query, parameters).fetchone()
|
|
if row is None:
|
|
return ""
|
|
if len(row) > 1:
|
|
return row
|
|
return "" if row[0] is None else row[0]
|
|
|
|
def writable():
|
|
"""A connection for fixtures written while the app runs. It never
|
|
checkpoints on close, so it cannot remove the WAL the app writes to."""
|
|
db = sqlite3.connect(database, timeout=2)
|
|
db.setconfig(sqlite3.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, True)
|
|
return contextlib.closing(db)
|
|
|
|
def item_list(title):
|
|
return sql("SELECT l.title FROM elist_items i JOIN elist_lists l ON i.list_id=l.id "
|
|
f"WHERE i.title='{title}'")
|
|
|
|
def add(text):
|
|
"""Type into the page's one text field and press Enter."""
|
|
driver.press(role="text_field")
|
|
driver.type(text)
|
|
driver.wait(role="text_field", value=text)
|
|
driver.key("enter")
|
|
|
|
def dialog():
|
|
"""The open dialog's words; it fails when no dialog shows."""
|
|
tree = driver.tree()
|
|
modals = [node["index"] for node in tree if node["kind"] == "modal" and node["visible"]]
|
|
assert modals, "No dialog opened over the list"
|
|
inside = set(modals)
|
|
for node in tree:
|
|
if node["parent"] in inside:
|
|
inside.add(node["index"])
|
|
return "\n".join(node["label"] for node in tree if node["index"] in inside and node["label"])
|
|
|
|
def open_settings(name):
|
|
"""Tap a list's chip: the first tap selects it, a tap on the
|
|
selected chip (with its gear) opens List settings."""
|
|
driver.press(contains=name, role="button")
|
|
try:
|
|
driver.wait(label="List settings", timeout=2)
|
|
except Exception:
|
|
driver.press(contains=name, role="button")
|
|
driver.wait(label="List settings")
|
|
driver.wait_idle(frames=3)
|
|
|
|
def page():
|
|
"""Every label List settings shows."""
|
|
return "\n".join(driver.labels())
|
|
|
|
def back():
|
|
driver.press(label="Back", role="button")
|
|
driver.wait_gone(label="List settings")
|
|
driver.wait(label="Add", role="button")
|
|
|
|
def calm(message):
|
|
shown = [label for label in driver.labels() if ALARMING.search(label)]
|
|
assert not shown, f"FAIL {message}: {shown} ({TEST_DIR})"
|
|
|
|
# A short swipe right finishes an item, a long swipe edits it, and a swipe
|
|
# left deletes it. Distances are logical pixels scaled with the UI, never
|
|
# fractions of the row width.
|
|
def swipe(title, pixels, direction=1):
|
|
"""Drag a row by a fixed logical-pixel distance."""
|
|
row = driver.wait(label=title, role="button")
|
|
x, y = UiDriver.center(row)
|
|
scale = row["visible_width"] / row["width"]
|
|
driver.drag((x, y), (x + direction * pixels * scale, y), steps=10)
|
|
driver.wait_idle(frames=3, timeout=2)
|
|
|
|
def resize_window(width, height):
|
|
subprocess.run(["xdotool", "windowsize", find_window(), str(width), str(height)], check=True)
|
|
|
|
def screen_size():
|
|
screen = driver.wait(role="screen", visible=None)
|
|
return screen["width"], screen["height"]
|
|
|
|
wait_for(lambda: screen_size() == (width, height),
|
|
lambda: f"the UI has size {screen_size()} after resizing to {(width, height)}")
|
|
|
|
def edit_task(title):
|
|
"""Press the Edit button on this title's row."""
|
|
row = driver.wait(label=title, role="button")
|
|
row_y = row["visible_y"] + row["visible_height"] / 2
|
|
edit = min((button for button in driver.find(label="Edit", role="button", visible=True)),
|
|
key=lambda button: abs(button["visible_y"] + button["visible_height"] / 2 - row_y))
|
|
driver.press(key=edit["key"])
|
|
|
|
def right_click(node):
|
|
x, y = UiDriver.center(node)
|
|
subprocess.run(["xdotool", "mousemove", "--window", find_window(),
|
|
str(round(x)), str(round(y)), "click", "3"], check=True)
|
|
|
|
def clear_field(value):
|
|
for _ in range(len(value)):
|
|
driver.key("backspace")
|
|
|
|
original = sql("SELECT id,comment,sort_order FROM elist_items WHERE title='Fresh fruit' AND deleted_at=0")
|
|
assert not driver.find(role="checkbox", visible=True), "items still have checkboxes"
|
|
assert driver.wait(label="Edit", role="button"), "items have no accessible edit button"
|
|
right_click(driver.wait(label="Fresh fruit", role="button"))
|
|
driver.wait_idle(frames=3)
|
|
driver.wait(label="Check", role="selectable")
|
|
driver.press(label="Edit", role="selectable")
|
|
driver.wait(label="Task", role="text")
|
|
driver.press(label="Cancel", role="button")
|
|
driver.wait(label="Fresh fruit", role="button")
|
|
driver.press(label="Fresh fruit", role="button")
|
|
driver.wait_idle(frames=4)
|
|
wait_for(lambda: sql("SELECT done FROM elist_items WHERE id=?", (original[0],)) == 1,
|
|
"a short swipe did not finish the item")
|
|
# As in 1List, finished items leave the list; a pull down on the items
|
|
# shows them above the open ones.
|
|
driver.wait_gone(label="Fresh fruit", role="button")
|
|
assert not driver.find(contains="Finished", visible=True), "the list still names its finished items"
|
|
add_button = driver.wait(label="Add", role="button")
|
|
pull_x = add_button["visible_x"] - 200
|
|
pull_y = add_button["visible_y"] + add_button["visible_height"] + 60
|
|
driver.drag((pull_x, pull_y), (pull_x, pull_y + 260), steps=12)
|
|
driver.wait(label="Fresh fruit", role="button")
|
|
assert not driver.find(contains="Finished", visible=True), "a heading names the finished items"
|
|
# A fixed short distance reopens the item; a fixed long distance opens the
|
|
# custom-task modal, and Cancel leaves both fields unchanged.
|
|
swipe("Fresh fruit", 100)
|
|
wait_for(lambda: sql("SELECT done FROM elist_items WHERE id=?", (original[0],)) == 0,
|
|
"a fixed short swipe did not reopen the item")
|
|
swipe("Fresh fruit", 200)
|
|
driver.wait(label="Task", role="text")
|
|
driver.wait(role="text_area")
|
|
driver.press(label="Cancel", role="button")
|
|
driver.wait(label="Fresh fruit", role="button")
|
|
assert sql("SELECT title,comment FROM elist_items WHERE id=?",
|
|
(original[0],)) == ("Fresh fruit", original[1]), "Cancel changed the task"
|
|
# Dragging past the combined action span still opens the same edit stage.
|
|
swipe("Fresh fruit", 600)
|
|
driver.press(role="text_area")
|
|
clear_field(sql("SELECT comment FROM elist_items WHERE id=?", (original[0],)))
|
|
edited_comment = "Pick organic fruit 茶é"
|
|
driver.type(edited_comment)
|
|
driver.wait(role="text_area", value=edited_comment)
|
|
driver.press(label="Save", role="button")
|
|
def saved_comment():
|
|
return sql("SELECT comment FROM elist_items WHERE id=?", (original[0],))
|
|
wait_for(lambda: saved_comment() == edited_comment,
|
|
lambda: f"the custom-task description was saved as {saved_comment()!r}")
|
|
swipe("Fresh fruit", -300)
|
|
wait_for(lambda: sql("SELECT deleted_at FROM elist_items WHERE id=?", (original[0],)) > 0,
|
|
"a swipe left did not delete the item")
|
|
# Deleting leaves the quick-add field empty again.
|
|
driver.wait(label="Add", role="button")
|
|
assert driver.find(role="text_field", value="", visible=True), \
|
|
f"the deleted item's name stayed in the field: {driver.find(role='text_field')}"
|
|
assert not driver.find(label="Fresh fruit", role="button", visible=True), "the deleted item is still listed"
|
|
driver.press(label="Undo delete", role="button")
|
|
wait_for(lambda: sql("SELECT deleted_at FROM elist_items WHERE id=?", (original[0],)) == 0,
|
|
"Undo did not restore the item")
|
|
restored = sql("SELECT id,comment,sort_order,done FROM elist_items WHERE title='Fresh fruit' AND deleted_at=0")
|
|
assert restored == (original[0], edited_comment, original[2], 0), ("Undo changed the item", restored)
|
|
assert sql("SELECT COUNT(*) FROM elist_items WHERE title='Fresh fruit'") == 1, "Undo made a duplicate"
|
|
swipe("Fresh fruit", 100)
|
|
wait_for(lambda: sql("SELECT done FROM elist_items WHERE id=?", (original[0],)) == 1,
|
|
"a short swipe did not finish the item after undo")
|
|
|
|
# The same fixed distance acts after a native resize; the row's new width
|
|
# never changes the threshold or the long edit stage.
|
|
resize_window(700, 560)
|
|
swipe("Fresh fruit", 100)
|
|
wait_for(lambda: sql("SELECT done FROM elist_items WHERE id=?", (original[0],)) == 0,
|
|
"the short action changed after resizing")
|
|
swipe("Fresh fruit", 200)
|
|
driver.wait(label="Task", role="text")
|
|
driver.press(label="Cancel", role="button")
|
|
resize_window(900, 720)
|
|
|
|
driver.press(label="Weekend", role="button")
|
|
long_task = "Prepare documentation and review the remaining details. " * 9 + "茶é"
|
|
add(long_task)
|
|
wait_for(lambda: sql("SELECT COUNT(*) FROM elist_items WHERE title=?", (long_task,)) == 1,
|
|
"long UTF-8 todo was truncated or rejected")
|
|
edit_task(long_task)
|
|
driver.wait(role="text_field", value=long_task)
|
|
driver.type("!")
|
|
driver.press(label="Save", role="button")
|
|
wait_for(lambda: sql("SELECT COUNT(*) FROM elist_items WHERE title=?", (long_task + "!",)) == 1,
|
|
"long UTF-8 todo did not retain its complete edit")
|
|
|
|
# The modal also creates a prioritized task. At this short viewport its
|
|
# outer modal scroll must reveal Save without clipping either action.
|
|
resize_window(430, 360)
|
|
driver.press(label="Custom", role="button")
|
|
driver.wait(label="Task", role="text")
|
|
driver.press(role="text_field")
|
|
driver.type("Viewport plan 茶é")
|
|
driver.press(role="text_area")
|
|
driver.type("Save after scrolling")
|
|
driver.press(key=6551, role="dropdown")
|
|
driver.press(label="A", role="option")
|
|
driver.wait(key=6551, label="A", role="dropdown")
|
|
viewport = driver.wait(key=6555)
|
|
wheel_x = viewport["visible_x"] + 8
|
|
wheel_y = viewport["visible_y"] + viewport["visible_height"] - 16
|
|
for _ in range(8):
|
|
driver.pointer(wheel_x, wheel_y, wheel=-4)
|
|
driver.wait_idle(frames=2)
|
|
driver.press(key=6553, role="button")
|
|
wait_for(lambda: sql("SELECT comment FROM elist_items WHERE title='(A) Viewport plan 茶é'") ==
|
|
"Save after scrolling", "a short viewport hid the modal's Save action")
|
|
resize_window(900, 720)
|
|
add("Weekend task")
|
|
wait_for(lambda: item_list("Weekend task"), "the task was not added")
|
|
assert item_list("Weekend task") == "Weekend", f"FAIL tab selects destination list: got {item_list('Weekend task')!r}"
|
|
driver.press(label="New list", role="button")
|
|
driver.wait(label="Create list", role="button")
|
|
add("Travel")
|
|
wait_for(lambda: sql("SELECT COUNT(*) FROM elist_lists WHERE title='Travel'") == 1, "create list with Enter")
|
|
driver.wait(label="Travel", role="button")
|
|
add("Pack bag")
|
|
wait_for(lambda: item_list("Pack bag"), "the task was not added to the new list")
|
|
assert item_list("Pack bag") == "Travel", f"FAIL new list is selected: got {item_list('Pack bag')!r}"
|
|
# Lists are chips that wrap onto more rows, as in 1List: however many
|
|
# there are, each shows its whole name and none is cut off.
|
|
extra = [f"Long list name number {number} to wrap" for number in range(1, 5)]
|
|
for name in extra:
|
|
driver.press(label="New list", role="button")
|
|
driver.wait(label="Create list", role="button")
|
|
add(name)
|
|
driver.wait(label=name, role="button")
|
|
driver.wait_idle(frames=5, timeout=3)
|
|
chips = [driver.wait(label=name, role="button") for name in ["Shopping", "Weekend", "Travel", *extra]]
|
|
cut = [chip["label"] for chip in chips if chip["visible_width"] < chip["width"] - 1]
|
|
assert not cut, f"list chips are cut off: {cut}"
|
|
assert len({chip["y"] for chip in chips}) >= 2, "the list chips did not wrap onto another row"
|
|
for chip in chips:
|
|
for other in chips:
|
|
if chip is not other:
|
|
apart = (chip["x"] + chip["width"] <= other["x"] or other["x"] + other["width"] <= chip["x"] or
|
|
chip["y"] + chip["height"] <= other["y"] or other["y"] + other["height"] <= chip["y"])
|
|
assert apart, f"list chips overlap: {chip['label']} and {other['label']}"
|
|
# With many lists, each list still shows its own items.
|
|
driver.press(label="Shopping", role="button")
|
|
driver.wait(label="Fresh fruit", role="button")
|
|
driver.press(label="Travel", role="button")
|
|
driver.wait(label="Pack bag", role="button")
|
|
# Correction in an item remains at the chosen byte after pointer release
|
|
# and redraw, including accented input. Put its row below the viewport so
|
|
# the test first follows the same scrolled-list path as an ordinary edit.
|
|
for number in range(12):
|
|
add(f"Travel item {number:02}")
|
|
correction = "Please pack a red bag tomorrow"
|
|
add(correction)
|
|
assert not driver.find(label=correction, role="button", visible=True), \
|
|
"correction fixture did not require scrolling"
|
|
for _ in range(20):
|
|
if driver.find(label=correction, role="button", visible=True):
|
|
break
|
|
driver.pointer(450, 600, wheel=-4)
|
|
driver.wait_idle(frames=3)
|
|
driver.wait(label=correction, role="button")
|
|
edit_task(correction)
|
|
field = driver.wait(role="text_field", value=correction)
|
|
x = field["visible_x"] + 100
|
|
y = field["visible_y"] + field["visible_height"] / 2
|
|
driver.pointer(x, y)
|
|
driver.pointer(x, y, down=True)
|
|
driver.pointer(x, y, down=False)
|
|
driver.release_pointer()
|
|
driver.wait_idle(frames=6)
|
|
cursor = driver.wait(role="text_field", value=correction)["cursor"]
|
|
assert 0 < cursor < len(correction), f"middle press moved the caret to {cursor}"
|
|
driver.type("é")
|
|
expected = correction[:cursor] + "é" + correction[cursor:]
|
|
field = driver.wait(role="text_field", value=expected)
|
|
assert field["cursor"] == cursor + len("é".encode()), field
|
|
driver.wait_idle(frames=6)
|
|
field = driver.wait(role="text_field", value=expected)
|
|
assert field["cursor"] == cursor + len("é".encode()), field
|
|
driver.type("x")
|
|
expected = correction[:cursor] + "éx" + correction[cursor:]
|
|
driver.wait(role="text_field", value=expected)
|
|
driver.press(label="Save", role="button")
|
|
wait_for(lambda: sql("SELECT COUNT(*) FROM elist_items WHERE title=? AND deleted_at=0",
|
|
(expected,)) == 1, "middle correction was not saved exactly")
|
|
# Return to the list chips for the remaining settings tests.
|
|
driver.pointer(450, 350, wheel=80)
|
|
driver.wait_idle(frames=6)
|
|
# A successful list save persists the name and leaves settings.
|
|
renamed_list_id = sql("SELECT id FROM elist_lists WHERE title='Travel' AND deleted_at=0")
|
|
open_settings("Travel")
|
|
driver.press(role="text_field")
|
|
driver.type(" renamed")
|
|
driver.wait(role="text_field", value="Travel renamed")
|
|
# The startup achievement toast can cover Save while the name is edited.
|
|
driver.wait_gone(contains="Achievement unlocked", timeout=20)
|
|
driver.press(label="Save", role="button")
|
|
wait_for(lambda: sql("SELECT title FROM elist_lists WHERE id=?", (renamed_list_id,)) == "Travel renamed",
|
|
lambda: f"the list save did not persist: {sql('SELECT title FROM elist_lists WHERE id=?', (renamed_list_id,))!r}")
|
|
driver.wait_gone(label="List settings", timeout=3)
|
|
driver.wait(label="Travel renamed", role="button")
|
|
driver.wait(label="Add", role="button")
|
|
# List settings holds the name, the people and Delete, which asks first.
|
|
for name in extra:
|
|
open_settings(name)
|
|
driver.press(label="Delete list", role="button")
|
|
driver.wait(label="Delete this list?")
|
|
driver.press(label="Delete list", role="button")
|
|
driver.wait_gone(label=name, role="button", visible=False)
|
|
driver.wait(label="Add", role="button")
|
|
driver.press(label="Travel renamed", role="button")
|
|
# Sharing lives in List settings, opened from the selected chip's gear.
|
|
# Offline, it asks to connect an account first. A private list shows no
|
|
# line about access, and Invitations appears only while one waits.
|
|
assert not driver.find(label="Share", role="button"), "a Share button is still on the list screen"
|
|
assert not driver.find(label="Rename", role="button"), "a Rename button is still on the list screen"
|
|
assert not driver.find(contains="Invitations", role="button"), "Invitations shown with none waiting"
|
|
open_settings("Travel renamed")
|
|
assert re.search(r"connect|account|sharing", page(), re.IGNORECASE), page()
|
|
assert not driver.find(label="Delete this list?", visible=True), "Delete did not wait to be asked"
|
|
back()
|
|
# Synthetic credentials make the connected panel available without a real
|
|
# account or HTTP delivery. The request must still pass through the actual
|
|
# bundle, typed host codec, document builder and durable-attempt storage.
|
|
with writable() as db, db:
|
|
user = db.execute("SELECT id FROM users LIMIT 1").fetchone()[0]
|
|
for key, value in {"sync_public_id": "b" * 64, "sync_public_key": "fixture",
|
|
"sync_private_key": "fixture", "sync_server_url": "http://127.0.0.1:9",
|
|
"sync_enabled": "1"}.items():
|
|
db.execute("INSERT INTO settings(user_id,key,value,updated_at) VALUES(?,?,?,1) "
|
|
"ON CONFLICT(user_id,key) DO UPDATE SET value=excluded.value", (user, key, value))
|
|
db.execute("INSERT OR REPLACE INTO social_snapshots VALUES(?,?,?,1)",
|
|
(user, "friends.list", json.dumps({"friends": [{"user_id_hash": "a" * 64, "alias": "Alice"}]})))
|
|
# The fixture node is unreachable: a failed refresh keeps the lists and
|
|
# shows no notice. The refresh runs in the background, so give it real
|
|
# time to fail.
|
|
time.sleep(.7)
|
|
driver.wait_idle(frames=3)
|
|
calm("a failed refresh shows a notice")
|
|
open_settings("Shopping")
|
|
driver.wait(label="People with access")
|
|
assert "Refresh" not in page() and "Alice" not in page(), page()
|
|
driver.press(key=6540)
|
|
driver.type("ali")
|
|
driver.wait(label="Alice")
|
|
assert not sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%'"), "typing sent an invitation"
|
|
driver.press(label="Alice")
|
|
driver.wait(key=6540, value="Alice")
|
|
subprocess.run(["import", "-window", find_window(), str(TEST_DIR / "share-dialog.png")], check=True)
|
|
driver.press(label="Invite", role="button")
|
|
# The first failed delivery is retried quietly; nothing alarming is shown.
|
|
wait_for(lambda: sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%'"),
|
|
"the invitation was not stored for delivery")
|
|
driver.wait_idle(frames=3)
|
|
calm("a first failed delivery shows an error")
|
|
command = json.loads(sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%'"))
|
|
assert command["action"] == "invite" and command["target"] == "a" * 64, command
|
|
assert command["access"] == "editor", command
|
|
assert command["list"]["title"] == "Shopping", command
|
|
assert {row["title"] for row in command["list"]["items"]} == {"Fresh fruit", "Buy tea"}, command
|
|
back()
|
|
# A different fixture server selects a separate cache and pending-attempt
|
|
# scope, as a real account/server change does.
|
|
with writable() as db, db:
|
|
db.execute("UPDATE settings SET value='http://127.0.0.1:10' WHERE key='sync_server_url'")
|
|
# A list this account shared with Alice, who joined, and Cedar, still
|
|
# invited; and one Alice shared with this account.
|
|
owned = {"id": OWNED_LIST, "owner": "b" * 64, "alias": "me", "title": "Garden",
|
|
"revision": 1, "deleted": 0, "access": "owner", "items": []}
|
|
given = {"id": GIVEN_LIST, "owner": "a" * 64, "alias": "Alice", "title": "Groceries",
|
|
"revision": 1, "deleted": 0, "access": "viewer", "items": []}
|
|
incoming = {"lists": [owned, given], "invitations": [
|
|
{"id": "invitation-fixture", "list_id": SHARED_LIST, "title": "Weekend trip", "owner": "a" * 64,
|
|
"target": "b" * 64, "alias": "Alice", "status": "pending"},
|
|
{"id": "invitation-alice", "list_id": OWNED_LIST, "title": "Garden", "owner": "b" * 64,
|
|
"alias": "me", "target": "a" * 64, "target_alias": "Alice", "status": "accepted", "access": "owner"},
|
|
{"id": "invitation-cedar", "list_id": OWNED_LIST, "title": "Garden", "owner": "b" * 64,
|
|
"alias": "me", "target": "c" * 64, "target_alias": "Cedar", "status": "pending", "access": "viewer"}]}
|
|
db.execute("INSERT OR REPLACE INTO social_snapshots VALUES(?,?,?,1)",
|
|
(user, "lists.shared/" + "b" * 64 + "/http://127.0.0.1:10", json.dumps(incoming)))
|
|
driver.wait(label="Invitations (1)", role="button")
|
|
# A shared list names its people under the chips, as a document does.
|
|
driver.press(contains="Garden", role="button")
|
|
driver.wait(label="Alice · Cedar (Invited)", role="button")
|
|
# The owner's List settings on a list that already has people: a friend
|
|
# who joined, one still invited and several more to invite.
|
|
with writable() as db, db:
|
|
user = db.execute("SELECT id FROM users LIMIT 1").fetchone()[0]
|
|
db.execute("INSERT OR REPLACE INTO social_snapshots VALUES(?,?,?,1)",
|
|
(user, "friends.list", json.dumps({"friends": [
|
|
{"user_id_hash": "a" * 64, "alias": "Alice", "profile_icon": 55},
|
|
{"user_id_hash": "c" * 64, "alias": "Cedar", "profile_icon": 0},
|
|
{"user_id_hash": "d" * 64, "alias": "Dana"}, {"user_id_hash": "e" * 64, "alias": "Emerald"}]})))
|
|
time.sleep(.5)
|
|
# People show their own profile picture; someone without one keeps the
|
|
# first letter of their name.
|
|
driver.wait(label="Alice", role="image")
|
|
assert not driver.find(label="Cedar (Invited)", role="image"), "a person without a picture got one"
|
|
driver.press(label="Alice · Cedar (Invited)", role="button")
|
|
driver.wait(label="List settings")
|
|
time.sleep(1.0)
|
|
subprocess.run(["import", "-window", find_window(), str(TEST_DIR / "share-owned.png")], check=True)
|
|
wait_for(lambda: "Cedar" in page(), lambda: f"friends are not listed: {page()}")
|
|
names = page()
|
|
assert all(name in names for name in ("Alice", "Cedar (Invited)", "You")), names
|
|
assert "Dana" not in names and "Emerald" not in names, names
|
|
assert "Owner" in names and "Read only" in names, names
|
|
assert "Refresh" not in names, names
|
|
driver.wait(label="Alice", role="image")
|
|
driver.wait(label="You", role="image")
|
|
# Escape leaves List settings and stays on this list.
|
|
driver.press(key=6540)
|
|
subprocess.run(["xdotool", "windowfocus", find_window()], check=True)
|
|
subprocess.run(["xdotool", "keydown", "Escape"], check=True)
|
|
time.sleep(.12)
|
|
subprocess.run(["xdotool", "keyup", "Escape"], check=True)
|
|
wait_for(lambda: not driver.find(label="List settings", visible=True),
|
|
"Escape did not leave List settings")
|
|
driver.wait(label="Alice · Cedar (Invited)", role="button")
|
|
open_settings("Garden")
|
|
driver.wait(contains="Cedar")
|
|
# The same page stays readable on a phone-sized viewport.
|
|
subprocess.run(["xdotool", "windowsize", find_window(), "390", "844"], check=True)
|
|
wait_for(lambda: driver.wait(label="List settings")["x"] < 390, "List settings did not fit the phone viewport")
|
|
driver.wait_idle(frames=3)
|
|
phone_roles = driver.find(role="dropdown", visible=True)
|
|
assert len(phone_roles) == 3, f"access menus do not fit the phone page: {[node['label'] for node in phone_roles]}"
|
|
cedar = driver.wait(contains="Cedar")
|
|
cedar_role = driver.wait(label="Read only", role="dropdown")
|
|
assert cedar_role["x"] >= cedar["x"] + cedar["width"] - 1, "phone name overlaps access controls"
|
|
assert cedar_role["x"] + cedar_role["width"] <= 390, "an access menu runs off the phone page"
|
|
subprocess.run(["import", "-window", find_window(), str(TEST_DIR / "share-owned-phone.png")], check=True)
|
|
subprocess.run(["xdotool", "windowsize", find_window(), "900", "720"], check=True)
|
|
driver.wait_idle(frames=3)
|
|
# A collaborator outside the friend cache is still shown by name.
|
|
with writable() as db, db:
|
|
db.execute("INSERT OR REPLACE INTO social_snapshots VALUES(?,?,?,1)",
|
|
(user, "friends.list", json.dumps({"friends": [
|
|
{"user_id_hash": "d" * 64, "alias": "Dana"}, {"user_id_hash": "e" * 64, "alias": "Emerald"}]})))
|
|
driver.wait_idle(frames=3)
|
|
assert "Alice" in page() and "Cedar" in page(), page()
|
|
driver.press(key=6540)
|
|
driver.type("da")
|
|
driver.wait(label="Dana")
|
|
assert not driver.find(label="Emerald", visible=True), "suggestions did not filter by typed name"
|
|
driver.press(label="Dana")
|
|
driver.wait(key=6540, value="Dana")
|
|
# Viewers can read all access but cannot rename, invite, manage roles or
|
|
# delete.
|
|
back()
|
|
open_settings("Groceries")
|
|
driver.wait(label="People with access")
|
|
assert "Alice" in page() and "Owner" in page(), page()
|
|
assert not driver.find(key=6540, visible=True), "viewer can invite"
|
|
assert not driver.find(role="dropdown", visible=True), "viewer can manage permissions"
|
|
assert not driver.wait(key=6551)["enabled"], "viewer can rename a list"
|
|
assert not driver.find(label="Delete list", visible=True), "viewer can delete the list"
|
|
back()
|
|
assert not driver.wait(key=6507)["enabled"], "viewer can add tasks"
|
|
# Owners change a collaborator's role without sending its document again.
|
|
open_settings("Garden")
|
|
driver.wait(contains="Cedar")
|
|
driver.press(label="Read only")
|
|
driver.wait(label="Can edit", role="option")
|
|
driver.wait(label="Owner", role="option")
|
|
driver.wait(label="Remove access", role="option")
|
|
# The first Escape closes the access popup, leaving List settings open.
|
|
driver.key("escape")
|
|
wait_for(lambda: not driver.find(role="option", visible=True),
|
|
"Escape did not close the access popup")
|
|
driver.wait(label="People with access")
|
|
driver.press(label="Read only")
|
|
driver.press(label="Can edit", role="option")
|
|
wait_for(lambda: sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%/http://127.0.0.1:10'"),
|
|
"the permission change was not stored")
|
|
permission = json.loads(sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%/http://127.0.0.1:10'"))
|
|
assert permission["action"] == "access" and permission["access"] == "editor" and permission["target"] == "c" * 64, permission
|
|
assert permission["list"] == {"id": OWNED_LIST}, permission
|
|
back()
|
|
# Move the receipt out of this fixture's scope before testing the inbox.
|
|
with writable() as db, db:
|
|
db.execute("DELETE FROM social_snapshots WHERE kind LIKE 'lists.attempt/%/http://127.0.0.1:10'")
|
|
db.execute("UPDATE settings SET value='http://127.0.0.1:11' WHERE key='sync_server_url'")
|
|
db.execute("INSERT OR REPLACE INTO social_snapshots VALUES(?,?,?,1)",
|
|
(user, "lists.shared/" + "b" * 64 + "/http://127.0.0.1:11", json.dumps(incoming)))
|
|
driver.wait(label="Groceries", role="button")
|
|
driver.press(contains="Groceries", role="button")
|
|
driver.wait(label="Alice", role="button")
|
|
window = find_window()
|
|
subprocess.run(["import", "-window", window, str(TEST_DIR / "shared-names.png")], check=True)
|
|
driver.press(label="Invitations (1)", role="button")
|
|
wait_for(lambda: "Weekend trip" in dialog(), lambda: f"the invitation is not listed: {dialog()}")
|
|
assert "From: Alice" in dialog(), dialog()
|
|
accept = driver.wait(label="Accept", role="button")
|
|
decline = driver.wait(label="Decline", role="button")
|
|
assert accept["visible_height"] >= 44 and decline["visible_height"] >= 44
|
|
assert accept["x"] + accept["width"] <= decline["x"], "Invitation actions overlap"
|
|
window = find_window()
|
|
assert int(subprocess.check_output(["xdotool", "getwindowpid", window], text=True)) == app.pid
|
|
subprocess.run(["import", "-window", window, str(TEST_DIR / "invitations.png")], check=True)
|
|
calm("a failed refresh shows a notice")
|
|
driver.press(label="Accept", role="button")
|
|
wait_for(lambda: sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%/http://127.0.0.1:11'"),
|
|
"the acceptance was not stored for delivery")
|
|
command = json.loads(sql("SELECT json FROM social_snapshots WHERE kind LIKE 'lists.attempt/%/http://127.0.0.1:11'"))
|
|
assert command["action"] == "accept" and command["invitation_id"] == "invitation-fixture", command
|
|
assert sql(f"SELECT COUNT(*) FROM elist_lists WHERE id='{SHARED_LIST}'") == 0
|
|
print(f"PASS fixed-width task swipes, scrollable custom tasks, middle correction with accents, identity-preserving undo, list tabs, friend invitation and durable delivery ({TEST_DIR})")
|