Files
odysseus/tests/smoke/test_documents_smoke.py
T
Léo 12f74ec9ea test(smoke): add a release smoke suite over every advertised feature area
The decomposition lanes have two safety nets and neither covers the
product. The checkpoint benchmark measures the agent runtime; the
computed-style snapshot pins the CSS. Nothing checked that Notes,
Calendar, Documents, Email, Memory, Cookbook or Settings still worked
after a route package moved or a 17,000-line module was split - and the
unit suite does not, since a byte-identical file move can break tests
that pass on the base branch with CI green throughout. The 28 Playwright
specs we do have are all under tests/e2e/photo-editor/ and no workflow
runs them.

scripts/odysseus-smoke boots this worktree through `odysseus dev` and
runs tests/smoke/: one scenario per area, each asserting a user-visible
outcome rather than a status code. Models come from a deterministic
OpenAI-compatible stub on an ephemeral loopback port; email reuses the
existing ODYSSEUS_EMAIL_FIXTURE path rather than inventing a second
mechanism. No scenario touches a live endpoint or the network.

The report is a per-area table that prints the areas the suite does not
cover next to the ones it does, and builds its rows from the registry
rather than from what happened to run, so an area cannot go missing by
having its module deleted or renamed. Under a plain pytest with nothing
booted every scenario skips with the reason, so the full suite stays
green.
2026-09-30 12:12:58 +02:00

47 lines
2.1 KiB
Python

"""Documents: the editor's create, edit and version history survive a round trip."""
from __future__ import annotations
DOCUMENT_PATH = "/api/document"
LIBRARY_PATH = "/api/documents/library"
TITLE = "Odysseus smoke document"
FIRST = "First revision, written by the release smoke suite."
SECOND = "Second revision, written by the release smoke suite."
def test_a_document_round_trips_with_its_versions(client):
created = client.post(DOCUMENT_PATH, json={"title": TITLE, "content": FIRST})
assert created.status_code == 200, created.text
body = created.json()
doc_id = body["id"]
try:
assert body.get("current_content") == FIRST, body
assert body.get("version_count") == 1, body
library = client.get(LIBRARY_PATH)
assert library.status_code == 200, library.text
assert doc_id in [d.get("id") for d in library.json().get("documents") or []]
# `force_version` because a save inside the route's coalesce
# window updates the current version in place instead of adding
# one - which is right for autosave and would make a smoke check
# that edits immediately depend on the clock.
edited = client.put(f"{DOCUMENT_PATH}/{doc_id}",
json={"content": SECOND, "force_version": True})
assert edited.status_code == 200, edited.text
assert edited.json().get("current_content") == SECOND, edited.text
assert edited.json().get("version_count") == 2, edited.text
versions = client.get(f"{DOCUMENT_PATH}/{doc_id}/versions")
assert versions.status_code == 200, versions.text
contents = {v.get("version_number"): v.get("content") for v in versions.json()}
assert contents.get(1) == FIRST, contents
assert contents.get(2) == SECOND, contents
restored = client.post(f"{DOCUMENT_PATH}/{doc_id}/restore/1")
assert restored.status_code == 200, restored.text
assert client.get(f"{DOCUMENT_PATH}/{doc_id}").json()["current_content"] == FIRST
finally:
removed = client.delete(f"{DOCUMENT_PATH}/{doc_id}")
assert removed.status_code == 200, removed.text