mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-01 22:37:10 -06:00
Tests from main: mailing results open beside the source document
This commit is contained in:
@@ -8560,9 +8560,10 @@ fn a_rejected_comparison_keeps_the_current_versions() {
|
||||
assert_eq!(s.file_name.as_deref(), Some("original.docx"));
|
||||
}
|
||||
|
||||
/// A rejected mailing result must keep the source document's save target and versions.
|
||||
/// A mailing result opens beside a protected source document, which keeps its save target,
|
||||
/// versions, password and text.
|
||||
#[test]
|
||||
fn a_rejected_mailing_result_keeps_the_current_file_identity() {
|
||||
fn a_mailing_result_beside_a_protected_document_keeps_its_file_identity() {
|
||||
use wordcraft_doc::{CharProps, InlineObject};
|
||||
|
||||
let mut s = Session::new(wordcraft_doc::Document::from_text("Protected source."));
|
||||
@@ -8580,7 +8581,9 @@ fn a_rejected_mailing_result_keeps_the_current_file_identity() {
|
||||
s.password = Some(crate::io::Password::new("synthetic file password"));
|
||||
s.bib_style = "Chicago".into();
|
||||
|
||||
assert!(s.run("mailings.envelopes", &json!({"delivery": "Recipient"})).is_err());
|
||||
s.run("mailings.envelopes", &json!({"delivery": "Recipient"})).unwrap();
|
||||
assert_ne!(s.document_id(), before_id, "the envelope is a new document");
|
||||
s.activate(before_id).unwrap();
|
||||
assert_eq!(s.doc, before);
|
||||
assert_eq!(s.versions.len(), 1);
|
||||
assert_eq!(s.path.as_deref(), Some(std::path::Path::new("source.docx")));
|
||||
|
||||
@@ -4449,15 +4449,16 @@ mod tests {
|
||||
|
||||
/// #1346: a check box the selected paragraphs differ in shows as neither on nor off; a click
|
||||
/// and OK turn it on in all of them, and the other fields they differ in stay as they were.
|
||||
/// #3028: the records dialog refuses a range with no records itself, before Save Changes asks
|
||||
/// about the unsaved document; a good range goes on to that question.
|
||||
/// #3028: the records dialog refuses a range with no records itself; a good range merges into
|
||||
/// a new document beside the unsaved one, asking nothing.
|
||||
#[test]
|
||||
fn merge_records_dialog_checks_the_range_before_asking_to_save() {
|
||||
fn merge_records_dialog_checks_the_range_before_merging() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut app = app_with("Dear ");
|
||||
let _ = app.run("mailings.recipients", json!({"csv": "Name\nAda\nAlan\nGrace"}));
|
||||
let _ = app.run("text.insert", json!({"text": "unsaved"}));
|
||||
assert!(app.session.dirty);
|
||||
let source = app.session.document_id();
|
||||
app.dialog = Dialog::open("mergeRecords", &mut app);
|
||||
if let Some(Dialog::MergeRecords { choice, from, to, .. }) = &mut app.dialog {
|
||||
*choice = 2;
|
||||
@@ -4491,8 +4492,10 @@ mod tests {
|
||||
for _ in 0..2 {
|
||||
h.step();
|
||||
}
|
||||
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
|
||||
assert!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).contains("unsaved"), "nothing merged yet");
|
||||
assert!(h.state().dialog.is_none(), "nothing to ask about: the merge opens beside");
|
||||
assert_ne!(h.state().session.document_id(), source, "the merge is a new document");
|
||||
h.state_mut().run("view.switchWindows", json!({"id": source})).unwrap();
|
||||
assert!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).contains("unsaved"), "the unsaved document is still open");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user