// Case: start -> edit -> abandon
// Add an untracked file
let file_to_record = "soul.rs";
fs::write(repo_path.join(file_to_record), "music")
.await
.unwrap();
// Wait for the FS watch to pick it up
let msg = await_next_msg(&mut fs_watch_task).await;
assert_matches!(
&msg,
Msg::View(app::Msg::ToRepo(
repo::MsgIn::RefreshChangedAndUntrackedFiles
))
);
// Update the state with it to send it to repo
let _task = update(&mut state, msg);
// Wait for response from repo
let msg = await_next_msg(&mut tasks).await;
assert_matches!(&msg, Msg::FromRepo(repo::MsgOut::Refreshed(_)));
let _task = update(&mut state, msg);
// Select it
state.cursor.selection = Some(cursor::Selection::UntrackedFile {
ix: 0,
path: file_to_record.to_string(),
});
// Add it to tracked files
let _task = update(&mut state, Msg::AddUntrackedFile);
// Wait for it to be added
let msg = task::await_next_msg(&mut tasks).await;
assert_matches!(
&msg,
Msg::FromRepo(repo::MsgOut::AddedUntrackedFile { path }) if path == file_to_record
);
// Start a record
let _task = start_record(&mut state);
assert!(state.record_msg.is_some());
// Edit the record msg
let record_msg = "Added soul music";
edit_record_msg(
&mut state,
text_editor::Action::Edit(text_editor::Edit::Paste(Arc::new(
record_msg.to_string(),
))),
);
assert!(state.record_msg.is_some());
assert_matches!(
state.record_msg.as_ref().unwrap(),
app::RecordMsg::Typing(_)
);
if let app::RecordMsg::Typing(content) = state.record_msg.as_ref().unwrap()
{
assert_eq!(&content.text(), record_msg);
}