Skip to content
Merged
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
33 changes: 32 additions & 1 deletion apps/zbugs-rune/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# zbugs-rune against zbugs' backend, end to end: the app runs headless on
# the wall clock (`--realtime`), opens at the list's first issue with no
# selection saved, steps away from an open issue and back with
# the arrow keys, then opens it, comments on it, reacts
# the arrow keys, creates an issue and finds its row highlighted at the
# list's top, then opens the issue it stepped to, comments on it, reacts
# to it, labels it, closes it, edits the comment, creates a label for it,
# makes it internal, and unsubscribes from it, pressing its controls as a
# person would. Opening it marks it viewed. Then Postgres must have each
Expand Down Expand Up @@ -55,6 +56,34 @@ ZBUGS_RUNE_DIR="$out/arrows" cargo run --locked --quiet -- --realtime \
arrows=$(node -e 'console.log(JSON.parse(require("fs").readFileSync(process.argv[1])).selection)' \
"$out/arrows/settings.json")

# A new issue, from the New Issue sheet with the list at its top: it opens,
# and its row must show highlighted at the top of the list, not above it
# out of view (where Rune keeps a new row that comes above the top one).
# It draws (--snap), as a window does: Rune holds the row it drew on top.
new_title="e2e-new-$(date +%s)"
mkdir -p "$out/created"
cat > "$out/created.json" <<EOF
{"events": [
{"t": 12.0, "type": "tap", "key": "new-issue"},
{"t": 12.5, "type": "type", "text": "$new_title"},
{"t": 14.0, "type": "key", "name": "Enter"}
]}
EOF
ZBUGS_RUNE_DIR="$out/created" cargo run --locked --quiet -- --realtime \
--script "$out/created.json" --at 16 --size 1180x760 \
--tree "$out/created-tree.json" --snap "$out/created.png" >/dev/null
created=$(sql "select id from issue where title = '$new_title'")
created_row=$(node -e '
const els = JSON.parse(require("fs").readFileSync(process.argv[1])).elements;
const list = els.find(e => e.key === "list-scroll")?.rect;
const row = els.find(e => e.key === process.argv[2]);
const shown = list && row && row.rect[1] >= list[1] && row.rect[1] + row.rect[3] <= list[1] + list[3];
console.log(shown ? (row.fill === "#00000000" ? "shown" : "shown, highlighted") : "out of view");
' "$out/created-tree.json" "$created")
created_selection=$(node -e 'console.log(JSON.parse(require("fs").readFileSync(process.argv[1])).selection)' \
"$out/created/settings.json")
sql "delete from issue where id = '$created'"

# The label picker lists the issue's project's labels by name, bytewise.
first_label=$(sql "select l.name from label l join issue i on i.\"projectID\" = l.\"projectID\"
where i.id = '$issue' order by l.name collate \"C\" limit 1")
Expand Down Expand Up @@ -107,6 +136,8 @@ check() {
}
check "the first issue, with none saved" "$first" "$first_issue"
check "the arrow keys" "$arrows" "$issue"
check "the new issue, open" "$created_selection" "$created"
check "the new issue's row" "$created_row" "shown, highlighted"
check "the comment, edited" \
"$(sql "select count(*) from comment where \"issueID\" = '$issue' and body = '$body edited'")" 1
check "the reaction" \
Expand Down
9 changes: 9 additions & 0 deletions apps/zbugs-rune/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ pub struct App {
pub checked: Vec<String>,
/// Scroll the list to the selected issue once it's there (a relaunch).
reveal_selected: bool,
/// How far down the list is scrolled, which the list's viewport sets.
pub list_offset: rune::Live<f32>,
/// Select the list's first issue once it has rows: a launch with no
/// selection to restore.
select_first: bool,
Expand Down Expand Up @@ -279,6 +281,7 @@ impl App {
select_mode: false,
checked: Vec::new(),
reveal_selected: false,
list_offset: rune::Live::new(0.0),
select_first: true,
detail: None,
detail_result: ResultType::Unknown,
Expand Down Expand Up @@ -1158,6 +1161,12 @@ fn apply_issues(s: &mut App, rows: Vec<Issue>, result_type: ResultType, tx: &mut
{
s.reveal_selected = false;
tx.scroll_into_view(id.clone());
} else if s.list_offset.get() < 0.5 {
// At the top, the list stays at the top, as zbugs-swift's and
// zbugs-gpui's do: Rune holds the top row in place when a new row
// comes above it, which left an issue just created, here or in
// another app, above the view while it showed selected.
tx.scroll_to_y("list-scroll", 0.0);
}
}

Expand Down
4 changes: 4 additions & 0 deletions apps/zbugs-rune/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ fn issue_list(s: &App, k: &Kit, layer: &mut Vec<El>) -> El {
.child(text(message).font(k.ty.ui).color(k.c.text_faint))
} else {
let kit = k.clone();
let offset = s.list_offset.clone();
col()
.key("list-scroll")
.w_full()
Expand All @@ -565,6 +566,9 @@ fn issue_list(s: &App, k: &Kit, layer: &mut Vec<El>) -> El {
.scroll(ScrollSpec {
stick_bottom: false,
})
.on_scroll_offset(move |at| {
offset.set(at.offset[1]);
})
.child(
col()
.key("issues")
Expand Down
Loading