Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c606b5ba43 | ||
|
|
90b313952b | ||
|
|
7240fc263b | ||
|
|
580e3cf7f0 | ||
|
|
2298d3373a |
@@ -94,8 +94,22 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
|
||||
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
|
||||
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
|
||||
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
|
||||
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
|
||||
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
|
||||
- Read only. Moving a card by keypress is a follow-up, deliberately kept out until the watch and render loop were solid
|
||||
- **A card is four corners with the title between them:** mark and short id top left, due top right, owner bottom left, criteria count bottom right. The two numbers are in corners because that is where the eye goes for one, and both were invisible at the end of a line of prose
|
||||
- The title takes one row or two, wrapped on spaces, with an ellipsis when even two are not enough. One row when one is enough: a second, blank row on every short ticket spends the column's height on nothing
|
||||
- **A card's height therefore depends on the column's width**, so `card_lines` and `card_height` both take it. `column_areas` is shared between the draw and `follow_selection` for the same reason: `Ratio` hands the remainder column to whichever slot it likes, and reproducing that arithmetic by hand is how the measurement and the draw come to disagree about where a card starts
|
||||
- **A corner that will not fit is dropped whole**, never truncated or wrapped: half a date reads as a different date, and a card that reflows in a narrow column changes height, which the scroll would then have to chase. The left corner is the ticket's identity and always stays
|
||||
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
|
||||
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
|
||||
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
|
||||
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
|
||||
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` actually sits rather than assuming the last slot, and `the_done_column_is_last` pins the assumption. A status inserted after done would otherwise hide two columns in silence
|
||||
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing done again is a no-op for the selection, since a column is appended rather than inserted
|
||||
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
|
||||
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not
|
||||
|
||||
### Shipping the Agent Assets
|
||||
- The skill is embedded with `include_str!` from `assets/SKILL.md`, not copied by an install script. `cargo install` places binaries and nothing else, so an installed document that is not in the binary is a document that drifts from it
|
||||
@@ -109,6 +123,9 @@ and this file is for what someone changing worklane's own code needs.
|
||||
|
||||
### Color and Output
|
||||
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
|
||||
- **`color_text()` is for the CLI's own printing only. Anything reachable from `content_trim` takes the decision as an argument and calls `paint()`**, because the board renders with colour off and an escape sequence in a ratatui paragraph is drawn as literal bytes. `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision` scans this file and fails on a new caller; the allowlist is `ambiguous`, which builds a failed-search message for stderr
|
||||
- A function that takes an `enabled` flag must use it all the way down. `colorize_bold` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
|
||||
- **A test that asserts an absence has to be paired with one that asserts the presence.** The guard for this, an assert that the detail view holds no escape byte, could not fail: a test binary has no tty, so `should_use_colors()` was false and the leaking branch was never taken. The pair is now `content_trim(.., false)` has no escape and `content_trim(.., true)` still colours, which pins the flag as the only thing that decides
|
||||
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
|
||||
- Reset color with `\x1b[0m` after colored text
|
||||
- Bold uses `\x1b[1;35m` (magenta bold)
|
||||
@@ -125,7 +142,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
- Colorization functions (`colorize_line`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
|
||||
- Colorization functions (`colorize_ordered`, `colorize_bold`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for `colorize_bold` with one caller, and the only thing it added was asking the terminal
|
||||
- `show` renders the Metadata section as a two column table via `render_metadata_table`, not line by line. Column width is measured on the raw field names in characters and padding is applied before anything is styled: measuring a coloured string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
|
||||
- The title is printed once, by `cmd_show`. `content_trim_colored` skips the `# ` heading in the file content
|
||||
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
|
||||
|
||||
Generated
+1
-1
@@ -1494,7 +1494,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.8.1"
|
||||
version = "0.8.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.8.1"
|
||||
version = "0.8.5"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -5,7 +5,7 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
## Commands
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `worklane` or `worklane tui` | Opens the board: four status columns, redrawn when the tree changes. Read only. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit |
|
||||
| `worklane` or `worklane tui` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit |
|
||||
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ pub fn cmd_ls(
|
||||
|
||||
// Show all tickets except done grouped by status
|
||||
for status in &statuses {
|
||||
if *status == "done" {
|
||||
if *status == DONE {
|
||||
continue;
|
||||
}
|
||||
let status_path = worklane_dir.join(status);
|
||||
|
||||
@@ -161,6 +161,8 @@ fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
KeyCode::Down | KeyCode::Char('j') => board.select_card(1, screen),
|
||||
KeyCode::PageUp => board.scroll_detail(-1, screen),
|
||||
KeyCode::PageDown => board.scroll_detail(1, screen),
|
||||
// Free of the other bindings, and the footer names it in both states.
|
||||
KeyCode::Char('d') => board.toggle_done(screen),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+820
-76
File diff suppressed because it is too large
Load Diff
+205
-10
@@ -403,7 +403,7 @@ pub fn content_trim(content: &str, colored: bool) -> String {
|
||||
|
||||
// Implementation Plan - color numbers in cyan
|
||||
if current_section == "## Implementation Plan" {
|
||||
result.push_str(&colorize_ordered(line));
|
||||
result.push_str(&colorize_ordered(line, colored));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
@@ -454,7 +454,13 @@ pub fn content_trim(content: &str, colored: bool) -> String {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn colorize_ordered(line: &str) -> String {
|
||||
/// Colour the `1.` at the head of a numbered line, leaving the rest alone.
|
||||
///
|
||||
/// Takes the decision rather than asking for it. Asking is what put `\x1b[36m` and
|
||||
/// `\x1b[0m` around every Implementation Plan number in the board's detail view,
|
||||
/// which renders with colour off precisely because a paragraph is not a place an
|
||||
/// escape sequence can go.
|
||||
fn colorize_ordered(line: &str, colored: bool) -> String {
|
||||
if line.chars().next().is_none_or(|c| !c.is_ascii_digit()) {
|
||||
return line.to_string();
|
||||
}
|
||||
@@ -468,7 +474,7 @@ pub fn colorize_ordered(line: &str) -> String {
|
||||
// still scanning digits
|
||||
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
|
||||
let number = &line[..i + 1];
|
||||
result.push_str(&color_text(number, Color::Cyan));
|
||||
result.push_str(&paint(number, Color::Cyan, colored));
|
||||
result.push_str(&line[i + 1..]);
|
||||
return result;
|
||||
} else {
|
||||
@@ -558,7 +564,10 @@ fn render_metadata_table(lines: &[&str], colored: bool) -> String {
|
||||
result.push_str(METADATA_GUTTER);
|
||||
result.push_str(&metadata_value_cell(name, value, colored));
|
||||
}
|
||||
MetadataRow::Other(text) => result.push_str(&colorize_line(text)),
|
||||
// The decision this row is rendered under, not the one the terminal
|
||||
// would give: `colorize_line` asked `should_use_colors()` here, which is
|
||||
// how escapes reached the board's detail view.
|
||||
MetadataRow::Other(text) => result.push_str(&colorize_bold(text, colored)),
|
||||
}
|
||||
result.push('\n');
|
||||
}
|
||||
@@ -571,10 +580,6 @@ pub fn is_unknown_value(value: &str) -> bool {
|
||||
trimmed == "_None_" || trimmed == "_Not set_" || trimmed == "-None-" || trimmed == "-Not set-"
|
||||
}
|
||||
|
||||
pub fn colorize_line(line: &str) -> String {
|
||||
colorize_bold(line, should_use_colors())
|
||||
}
|
||||
|
||||
/// Replace `**bold**` with colour, or leave the line exactly as it is.
|
||||
///
|
||||
/// Taking `enabled` rather than asking makes both paths testable, and the
|
||||
@@ -600,7 +605,9 @@ fn colorize_bold(line: &str, enabled: bool) -> String {
|
||||
match (i + 2..chars.len()).find(|&at| is_delimiter(&chars, at)) {
|
||||
Some(close) => {
|
||||
let bold: String = chars[i + 2..close].iter().collect();
|
||||
result.push_str(&color_text(&bold, Color::Magenta));
|
||||
// `enabled`, not `should_use_colors()`. Asking again here made the
|
||||
// flag a lie: the early return above respected it and this did not.
|
||||
result.push_str(&paint(&bold, Color::Magenta, enabled));
|
||||
i = close + 2;
|
||||
}
|
||||
// Unterminated: the rest is literal. The old scan walked off the end
|
||||
@@ -1095,9 +1102,18 @@ pub fn trim_blank_ends(values: &[String]) -> &[String] {
|
||||
}
|
||||
|
||||
pub fn status_dirs() -> Vec<&'static str> {
|
||||
vec!["backlog", "committed", "reviewing", "done"]
|
||||
vec!["backlog", "committed", "reviewing", DONE]
|
||||
}
|
||||
|
||||
/// The end of the flow, and the one status both views treat differently: `ls` counts it
|
||||
/// in the summary and leaves it out of the listing, and the board hides its column until
|
||||
/// asked. Named because that rule now has two readers.
|
||||
///
|
||||
/// It is deliberately last in `status_dirs()`. The board leans on that: hiding done drops
|
||||
/// the final column, so the other three keep their indices and the selection only has to
|
||||
/// be handled when it is sitting on done itself.
|
||||
pub const DONE: &str = "done";
|
||||
|
||||
/// Lowest and highest level a ticket can carry. 1 is the most urgent, which is
|
||||
/// what the `p1` to `p3` tags this replaced already meant.
|
||||
pub const PRIORITY_RANGE: std::ops::RangeInclusive<u8> = 1..=5;
|
||||
@@ -1143,6 +1159,16 @@ pub fn parse_priority(content: &str) -> Priority {
|
||||
priority_from_value(&parse_ticket_field(content, "Priority"))
|
||||
}
|
||||
|
||||
/// How far along a ticket is: criteria ticked against criteria written.
|
||||
///
|
||||
/// `total` is never zero. A ticket with no criteria has no progress to show, and a card
|
||||
/// reading `[0/0]` says less than a card saying nothing, so the absence is `None`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Progress {
|
||||
pub met: usize,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
pub struct TicketItem {
|
||||
pub title: String,
|
||||
pub owner: String,
|
||||
@@ -1150,11 +1176,42 @@ pub struct TicketItem {
|
||||
pub id: String,
|
||||
pub created: String,
|
||||
pub priority: Priority,
|
||||
/// Ticked against total, or `None` for a ticket with no criteria.
|
||||
///
|
||||
/// Counted where the file is already being read, so the board pays nothing for it
|
||||
/// beyond the count itself: the alternative, counting per card, would re-read every
|
||||
/// ticket body on every draw rather than on the tick that changed something. The
|
||||
/// listing ignores it, as it ignores `path`.
|
||||
pub criteria: Option<Progress>,
|
||||
/// The file this came from. The listing ignores it; the TUI opens it for the
|
||||
/// detail view rather than resolving the ticket a second time.
|
||||
pub path: std::path::PathBuf,
|
||||
}
|
||||
|
||||
/// The date part of a due value, for a view with only a corner to spend on it.
|
||||
///
|
||||
/// The field is not validated, see daa0e79, so it holds whatever a caller typed: a bare
|
||||
/// date, a date and a time, or free text. Only a real `YYYY-MM-DD` prefix is cut back
|
||||
/// to. Taking the first word regardless would turn a free-text due into its first word,
|
||||
/// which is worse than showing what is stored and letting the column decide.
|
||||
pub fn due_date(due: &str) -> &str {
|
||||
let candidate = due.split([' ', 'T']).next().unwrap_or(due);
|
||||
match is_ymd(candidate) {
|
||||
true => candidate,
|
||||
false => due,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_ymd(value: &str) -> bool {
|
||||
let bytes = value.as_bytes();
|
||||
bytes.len() == 10
|
||||
&& bytes[4] == b'-'
|
||||
&& bytes[7] == b'-'
|
||||
&& [0, 1, 2, 3, 5, 6, 8, 9]
|
||||
.iter()
|
||||
.all(|at| bytes[*at].is_ascii_digit())
|
||||
}
|
||||
|
||||
/// Grey for a value that is not set, per the colour guideline.
|
||||
///
|
||||
/// `show` already did this in its metadata rendering, so the listing was the one
|
||||
@@ -1256,6 +1313,18 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
let filename = e.path().file_stem()?.to_string_lossy().to_string();
|
||||
let created_at = parse_ticket_field(&content, "Created At");
|
||||
|
||||
// Through `criteria()`, so the card and the numbers `show` prints cannot
|
||||
// disagree: a checkbox written into a description is not a criterion there
|
||||
// and is not counted here.
|
||||
let counted = criteria(&content);
|
||||
let progress = match counted.len() {
|
||||
0 => None,
|
||||
total => Some(Progress {
|
||||
met: counted.iter().filter(|criterion| criterion.checked).count(),
|
||||
total,
|
||||
}),
|
||||
};
|
||||
|
||||
Some(TicketItem {
|
||||
title,
|
||||
owner,
|
||||
@@ -1263,6 +1332,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
id: short_id(&filename).to_string(),
|
||||
created: format_created_at(&created_at),
|
||||
priority: parse_priority(&content),
|
||||
criteria: progress,
|
||||
path: e.path(),
|
||||
})
|
||||
})
|
||||
@@ -1543,6 +1613,131 @@ mod tests {
|
||||
assert_eq!(rendered, format!("Priority {glyph} _Not set_\n"));
|
||||
}
|
||||
|
||||
/// A ticket with the two things that used to leak: a numbered plan, and a
|
||||
/// hand-written line inside the Metadata section.
|
||||
const BOTH_LEAKS: &str = "# T\n\n## Implementation Plan\n1. First step\n2. Second step\n\
|
||||
\n## Metadata\n\n- **ID**: abc\nA **handwritten** note\n";
|
||||
|
||||
/// The bug: the board asks for `content_trim(content, false)` because a paragraph
|
||||
/// is no place for an escape sequence, and two paths asked the terminal instead.
|
||||
#[test]
|
||||
fn the_body_carries_no_escape_when_the_colour_is_off() {
|
||||
let rendered = content_trim(BOTH_LEAKS, false);
|
||||
|
||||
assert!(
|
||||
!rendered.contains('\x1b'),
|
||||
"an escape survived colour being off: {rendered:?}"
|
||||
);
|
||||
// And the content is all still there, in plain form.
|
||||
assert!(rendered.contains("1. First step"), "{rendered:?}");
|
||||
assert!(rendered.contains("**handwritten**"), "{rendered:?}");
|
||||
}
|
||||
|
||||
/// The other half of the pair, and the one that makes the first mean something:
|
||||
/// with the flag on, both paths still colour. Without this, the passing test above
|
||||
/// could be a colouring path that was simply deleted.
|
||||
#[test]
|
||||
fn the_body_colours_the_plan_number_and_a_metadata_note_when_the_colour_is_on() {
|
||||
let rendered = content_trim(BOTH_LEAKS, true);
|
||||
|
||||
assert!(
|
||||
rendered.contains(&format!("{}1.", Color::Cyan.ansi())),
|
||||
"the plan number lost its colour: {rendered:?}"
|
||||
);
|
||||
assert!(
|
||||
rendered.contains(&format!("{}handwritten", Color::Magenta.ansi())),
|
||||
"the bold run lost its colour: {rendered:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The flag has to be the only thing that decides, or the disabled path is just
|
||||
/// the terminal's answer in disguise — which is why the leak survived a test
|
||||
/// asserting the detail view holds no escapes. In a test binary there is no tty,
|
||||
/// so `should_use_colors()` is false and the leaking branch was never taken.
|
||||
#[test]
|
||||
fn nothing_the_body_renders_asks_the_terminal_for_the_colour_decision() {
|
||||
let callers = callers_of_color_text(include_str!("util.rs"));
|
||||
|
||||
// `ambiguous` is the one that may: it builds the candidate list for a failed
|
||||
// search, reaches the user on stderr, and is not reachable from `content_trim`.
|
||||
assert_eq!(
|
||||
callers,
|
||||
vec!["ambiguous".to_string()],
|
||||
"`color_text` asks `should_use_colors()`. Everything reachable from \
|
||||
`content_trim` has to take the decision as an argument and pass it to \
|
||||
`paint` instead, because the board renders with colour off and an escape \
|
||||
in a ratatui paragraph is drawn as literal bytes. If the new caller really \
|
||||
is CLI-only, add it here and say why."
|
||||
);
|
||||
}
|
||||
|
||||
/// Which functions in this file call `color_text`, by name, definitions and the
|
||||
/// test module excluded.
|
||||
fn callers_of_color_text(source: &str) -> Vec<String> {
|
||||
let body = match source.find("\n#[cfg(test)]") {
|
||||
Some(end) => &source[..end],
|
||||
None => source,
|
||||
};
|
||||
|
||||
let mut current = String::new();
|
||||
let mut callers = Vec::new();
|
||||
for line in body.lines() {
|
||||
if let Some(rest) = line.strip_prefix("fn ").or_else(|| line.strip_prefix("pub fn ")) {
|
||||
current = rest.split('(').next().unwrap_or_default().to_string();
|
||||
continue;
|
||||
}
|
||||
if line.contains("color_text(") && !callers.contains(¤t) {
|
||||
callers.push(current.clone());
|
||||
}
|
||||
}
|
||||
|
||||
callers
|
||||
}
|
||||
|
||||
/// The field is not validated, see daa0e79, so the card cannot trust it to be a
|
||||
/// bare date. Only a real date prefix is cut back to: free text is left alone,
|
||||
/// since turning "next friday" into "next" would be a worse answer than the width.
|
||||
#[test]
|
||||
fn a_due_value_is_cut_back_to_its_date_only_when_it_has_one() {
|
||||
assert_eq!(due_date("2026-12-31"), "2026-12-31");
|
||||
assert_eq!(due_date("2026-12-31 09:30:00"), "2026-12-31");
|
||||
assert_eq!(due_date("2026-12-31T09:30:00Z"), "2026-12-31");
|
||||
assert_eq!(due_date("_Not set_"), "_Not set_");
|
||||
assert_eq!(due_date("next friday"), "next friday");
|
||||
assert_eq!(due_date("2026-1-1 09:30"), "2026-1-1 09:30");
|
||||
}
|
||||
|
||||
/// The count on a card comes from `criteria()`, the same function that numbers them
|
||||
/// in `show`, so the two cannot disagree about what a criterion is.
|
||||
#[test]
|
||||
fn collect_ticket_items_counts_the_criteria_show_would_number() {
|
||||
let dir = std::env::temp_dir().join(format!("worklane-count-{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&dir).unwrap();
|
||||
|
||||
let write = |name: &str, body: &str| {
|
||||
fs::write(
|
||||
dir.join(format!("11111111-0000-4000-8000-00000000000{name}.md")),
|
||||
format!("# T{name}\n\n{body}\n\n## Metadata\n\n- **Owner**: alice\n"),
|
||||
)
|
||||
.unwrap();
|
||||
};
|
||||
|
||||
// A checkbox in the description is not a criterion, in either view.
|
||||
write(
|
||||
"1",
|
||||
"## Description\n- [x] not a criterion\n\n## Acceptance Criteria\n- [x] One\n- [ ] Two",
|
||||
);
|
||||
write("2", "## Acceptance Criteria\n_No acceptance criteria provided._");
|
||||
|
||||
let items = collect_ticket_items(&dir).unwrap();
|
||||
let counted: Vec<Option<Progress>> = items.iter().map(|item| item.criteria).collect();
|
||||
|
||||
assert!(counted.contains(&Some(Progress { met: 1, total: 2 })), "{counted:?}");
|
||||
assert!(counted.contains(&None), "a ticket with no criteria got a count: {counted:?}");
|
||||
|
||||
fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_section_rule_matches_the_width_of_its_name() {
|
||||
let rendered = content_trim_colored("# T\n\n## Description\nbody\n");
|
||||
|
||||
Reference in New Issue
Block a user