Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions features/steps/ticket_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,30 @@ def step_ticket_has_notes(context, ticket_id):
ticket_path.write_text(content)


@given(r'ticket "(?P<ticket_id>[^"]+)" has markdown content with horizontal rule')
def step_ticket_has_horizontal_rule(context, ticket_id):
"""Add markdown content with a horizontal rule (---) to ticket."""
ticket_path = Path(context.test_dir) / '.tickets' / f'{ticket_id}.md'
content = ticket_path.read_text()

# Add markdown content with horizontal rule separator and YAML-like content after it
# This simulates the issue where content after --- looks like YAML frontmatter
additional_content = '''
## Section 1

Some content here.

---

## Implementation Plan

Overview: This is a detailed plan
Design Decision: We chose this approach
'''
content += additional_content
ticket_path.write_text(content)


@given(r'I am in subdirectory "(?P<subdir>[^"]+)"')
def step_in_subdirectory(context, subdir):
"""Change to a subdirectory (creating it if needed)."""
Expand Down Expand Up @@ -591,6 +615,23 @@ def step_jsonl_deps_is_array(context):
raise AssertionError("No JSONL line with deps field found")


@then(r'the JSONL should have exactly (?P<count>\d+) fields')
def step_jsonl_exact_field_count(context, count):
"""Assert JSONL has exactly N fields."""
count = int(count)
lines = context.stdout.strip().split('\n')
assert lines, "No JSONL output"

for line in lines:
if line.strip():
data = json.loads(line)
actual_count = len(data.keys())
assert actual_count == count, \
f"Expected {count} fields but got {actual_count}\nFields: {list(data.keys())}\nFull line: {line}"
return
raise AssertionError("No JSONL output found")


@then(r'the dep tree output should have (?P<first_id>[^\s]+) before (?P<second_id>[^\s]+)')
def step_dep_tree_order(context, first_id, second_id):
"""Assert that first_id appears before second_id in dep tree output."""
Expand Down
10 changes: 10 additions & 0 deletions features/ticket_query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ Feature: Ticket Query
When I run "ticket query"
Then the command should succeed
And the JSONL deps field should be a JSON array

Scenario: Query handles markdown horizontal rules
Given a ticket exists with ID "query-001" and title "Ticket with horizontal rule"
And ticket "query-001" has markdown content with horizontal rule
When I run "ticket query"
Then the command should succeed
And the output should be valid JSONL
And the JSONL output should have field "id"
And the JSONL output should have field "status"
And the JSONL should have exactly 7 fields
10 changes: 8 additions & 2 deletions ticket
Original file line number Diff line number Diff line change
Expand Up @@ -1325,10 +1325,16 @@ cmd_query() {
BEGIN { FS=": "; in_front=0 }
FNR==1 {
if (prev_file) emit()
field_count=0; in_front=0
field_count=0; in_front=0; frontmatter_done=0
prev_file=FILENAME
}
/^---$/ { in_front = !in_front; next }
/^---$/ {
if (!frontmatter_done) {
in_front = !in_front
if (!in_front) frontmatter_done = 1
}
next
}
in_front && /^[a-zA-Z]/ {
key = $1
val = substr($0, length($1) + 3)
Expand Down