Merge look-fix-comments-pane app work (every card replies, resolves, reopens, deletes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-28 18:10:46 +00:00
co-authored by Claude Opus 5.5
+52 -7
View File
@@ -18,14 +18,12 @@ pub(super) fn comments(app: &mut SlideApp, ui: &mut Ui) {
}
Divider::horizontal().show(ui);
let threads = app.session.active().map(|st| threads(&st.doc)).unwrap_or_default();
let now =
web_time::SystemTime::now().duration_since(web_time::UNIX_EPOCH).ok().and_then(|elapsed| i64::try_from(elapsed.as_secs()).ok()).unwrap_or(0);
// The replies form writes each comment's date and time, so it needs no clock.
let out = CommentsPanel::new(Word::plain("Comments"), &threads, &mut app.comments_pane)
.header(CommentsHeader::Hosted)
.form(CommentsForm::Replies)
.page_label(|slide| slide.saturating_add(1).to_string())
.reply_submit(SubmitKey::Enter)
.now(now)
.show(ui);
// Each pass applies only the edits its panel reports; a rerun has no replay queue.
for edit in out.edits {
@@ -198,10 +196,8 @@ mod tests {
fixture.click(&card).settle();
}
Action::Reply => {
let button = fixture.by_label(words.reply_button.as_str()).unwrap();
fixture.click(&button).type_text(reply).settle();
let post = fixture.by_label(words.post.as_str()).unwrap();
fixture.click(&post).settle();
let field = fixture.by_label(words.reply.as_str()).unwrap();
fixture.click(&field).type_text(reply).key(egui::Key::Enter, egui::Modifiers::NONE).settle();
}
Action::Resolve | Action::Reopen | Action::Delete => {
let label = if matches!(action, Action::Resolve) {
@@ -230,6 +226,55 @@ mod tests {
.collect()
}
/// Production's pane offered Reply, Resolve or Reopen, and delete on every card: each control of a card that is
/// on another slide and not selected runs its engine command on that card's comment alone.
#[test]
fn every_card_in_the_pane_replies_resolves_reopens_and_deletes() {
use egui::accesskit::Role as Access;
use egui_kittest::kittest::Queryable;
let words = CommentsWords::default();
for action in [Action::Reply, Action::Resolve, Action::Reopen, Action::Delete] {
let mut session = Session::with_new();
session.execute("slide.new", &json!({"layout": "blank"})).unwrap();
for (slide, text) in [(0, "On the first slide"), (1, "On the second slide")] {
session.execute("slide.go", &json!({"index": slide})).unwrap();
session.execute("comment.add", &json!({"text": text})).unwrap();
}
if matches!(action, Action::Reopen) {
session.execute("comment.resolve", &json!({"index": 0, "resolved": true})).unwrap();
}
session.execute("slide.go", &json!({"index": 0})).unwrap();
let builder = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0));
let mut h = crate::test_harness::harness_with(session, crate::Services::default(), builder, |_| {});
h.state_mut().run("view.pane", json!({"pane": "comments"})).unwrap();
h.run_steps(3);
let before = h.state().session.active().unwrap().doc.clone();
// The second card's controls are the last of their kind in the pane.
let (role, label) = match action {
Action::Reply => (Access::TextInput, &words.reply),
Action::Resolve => (Access::Button, &words.resolve),
Action::Reopen => (Access::Button, &words.reopen),
Action::Delete | Action::Select => (Access::Button, &words.delete),
};
h.query_all_by_role_and_label(role, label.as_str()).last().expect("the second card's control").click();
h.run_steps(3);
if matches!(action, Action::Reply) {
h.query_all_by_role_and_label(role, label.as_str()).last().expect("the second card's reply box").type_text("Done");
h.run_steps(2);
h.key_press(egui::Key::Enter);
h.run_steps(3);
}
let doc = &h.state().session.active().unwrap().doc;
assert_eq!(doc.slides[0].comments, before.slides[0].comments, "{action:?} leaves the first slide's comment alone");
let (was, now) = (&before.slides[1].comments, &doc.slides[1].comments);
match action {
Action::Reply => assert!(now[0].replies.iter().any(|reply| reply.text == "Done"), "the reply is on the second card's comment"),
Action::Resolve | Action::Reopen => assert_ne!(now[0].resolved, was[0].resolved, "{action:?} flips the second comment"),
Action::Delete | Action::Select => assert!(now.len() < was.len(), "the second comment is deleted"),
}
}
}
#[test]
fn comment_edits_send_their_commands_and_keep_the_focus() {
let cases = [