Issues: per-project numbers, statuses (open, accepted, rejected, withdrawn, duplicate), feature links, edits, and a timeline of comments and events. From an issue, collaborators create or update a feature with the revision tied to the issue and an option to accept it. Comments: general and line-anchored threads on features, one discussion thread per issue, edit history, tombstone deletes, resolve, and promoting a feature thread to an issue. Line threads attach to top-level Markdown blocks and go outdated only when the text changes. HTMX swaps threads in place with focus management; every action also works as a plain form post. Markdown headings are re-levelled so user text never skips heading levels on the page. The example flow from concept.md (steps 1-7) is covered end to end in tests/test_example_flow.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
from intent.features.diff import line_diff
|
|
from intent.markdown import render
|
|
|
|
|
|
def test_blocks_carry_source_lines():
|
|
html = render("Para one\ncontinues.\n\n- a\n- b\n")
|
|
assert '<p data-source-lines="1-2">' in html
|
|
assert '<li data-source-lines="4-4">' in html
|
|
|
|
|
|
def test_headings_shift_down_one_level():
|
|
html = render("# Top\n\n###### Deepest\n")
|
|
assert "<h2" in html and "<h1" not in html
|
|
assert "<h6" in html
|
|
|
|
|
|
def test_raw_html_and_script_links_are_neutralised():
|
|
html = render("<script>alert(1)</script>\n\n[x](javascript:alert(1)) <img src=x onerror=y>")
|
|
assert "<script" not in html
|
|
assert "javascript:" not in html.replace("[x](javascript:alert(1))", "")
|
|
assert "onerror" not in html.replace("onerror=y>", "")
|
|
|
|
|
|
def test_remote_images_are_dropped():
|
|
assert "<img" not in render("")
|
|
|
|
|
|
def test_tables_and_strikethrough():
|
|
html = render("| a |\n|---|\n| 1 |\n\n~~old~~")
|
|
assert "<table" in html and "<s>old</s>" in html
|
|
|
|
|
|
def test_line_diff_hunks():
|
|
old = "\n".join(f"line {i}" for i in range(1, 21))
|
|
new = old.replace("line 10", "line ten")
|
|
[hunk] = line_diff(old, new)
|
|
kinds = [(line.kind, line.old_number, line.new_number) for line in hunk]
|
|
assert ("removed", 10, None) in kinds
|
|
assert ("added", None, 10) in kinds
|
|
assert kinds[0] == ("same", 7, 7) # three lines of context
|
|
assert line_diff(old, old) == []
|
|
|
|
|
|
def test_blocks_split_top_level_markdown_with_line_ranges():
|
|
from intent.markdown import render_blocks, source_lines
|
|
|
|
text = "# Title\n\nPara one\ncontinues.\n\n- a\n- b\n\n```\ncode\n```\n"
|
|
blocks = render_blocks(text)
|
|
assert [(b.start, b.end) for b in blocks] == [(1, 1), (3, 4), (6, 7), (9, 11)]
|
|
assert blocks[0].anchor == "L1-1" and "<h2" in blocks[0].html
|
|
assert "<li" in blocks[2].html and "<li" not in blocks[1].html
|
|
assert source_lines(text, 3, 4) == "Para one\ncontinues."
|
|
|
|
|
|
def test_heading_base_is_adjustable():
|
|
assert "<h3" in render("# Deep", heading_base=3)
|
|
# The shallowest heading lands on the base level, keeping relative structure.
|
|
html = render("## Two\n\n### Three\n")
|
|
assert "<h2" in html and "<h3" in html and "<h4" not in html
|