fix(app-iced): 点选共享档立刻显示后果原文,登记在飞时不吃关闭(M223 自检)
两处自己复审抓到的问题: 1. 契约 §5.2 要求 Shared/VersionDir 被**点选**就展示 target_notes() 原文,而上一版要等 用户再点一次「预检」才出现。现在点选这两档会顺手发一次**零写盘**的预检,结果落在 Pick 段当提示读(不把用户甩到确认页:确认仍由显式的「预检」按钮触发,Form::checked)。 改档之后旧 plan 因目标档不一致而不再显示(Form::fresh_plan),避免画上一档的后果原文。 2. 「关闭」在登记在飞时被忽略:core 那条线程已经开跑,关面板会让 Done 事件被代次丢掉, 用户看到的就是「实例写进去了,界面什么都没说」。 用例:a_foreign_target_shows_its_notes_without_jumping_to_confirm / choosing_a_foreign_target_previews_but_waits_for_the_user / closing_is_ignored_while_the_registration_is_in_flight。
This commit is contained in:
1 parent
9ca5ee8ae7
commit
a36e17a5d3
4 files changed
+163
-19
No files matched your search
@@ -35,6 +35,11 @@ impl App {
|
||||
self.dispatch_adopt(AdoptCommand::Scan);
|
||||
}
|
||||
AdoptMessage::Close => {
|
||||
// 登记在飞时不吃「关闭」:core 那条线程已经开跑了,写了盘却不回报 Done
|
||||
// 就会出现「实例已存在但界面什么都没说」——等它交卷(几十毫秒级)。
|
||||
if self.adopt_form.busy == Busy::Importing {
|
||||
return Task::none();
|
||||
}
|
||||
self.adopt_form.close();
|
||||
self.dispatch_adopt(AdoptCommand::Dismiss);
|
||||
}
|
||||
@@ -42,9 +47,22 @@ impl App {
|
||||
self.adopt_form.selected = Some(version_id);
|
||||
}
|
||||
AdoptMessage::Name(name) => self.adopt_form.name = name,
|
||||
AdoptMessage::Target(target) => self.adopt_form.target = target,
|
||||
AdoptMessage::Target(target) => {
|
||||
self.adopt_form.target = target;
|
||||
// 换了目标档 ⇒ 上一档的预检作废(确认按钮不该继续亮着)
|
||||
self.adopt_form.checked = false;
|
||||
// 共享档 / 版本目录档会写进**别人的目录**:一被点选就把后果原文拿出来
|
||||
// (零写盘的预检,见 `Form::stage` 的收窄:这一次结果落在 Pick 段当提示读)。
|
||||
if target.touches_foreign_dir() {
|
||||
if let Some(request) = self.adopt_request() {
|
||||
self.adopt_form.busy = Busy::Checking;
|
||||
self.dispatch_adopt(AdoptCommand::Preview(Box::new(request)));
|
||||
}
|
||||
}
|
||||
}
|
||||
AdoptMessage::Check => {
|
||||
if let Some(request) = self.adopt_request() {
|
||||
self.adopt_form.checked = true;
|
||||
self.adopt_form.busy = Busy::Checking;
|
||||
self.dispatch_adopt(AdoptCommand::Preview(Box::new(request)));
|
||||
}
|
||||
@@ -58,6 +76,7 @@ impl App {
|
||||
AdoptMessage::Back => {
|
||||
// 退回候选列表 = 重新扫一次:`scan` 会把上一轮的预检/失败一起作废,
|
||||
// 于是界面回到 Pick 段,不需要再给 core 加一个「清失败」的命令。
|
||||
self.adopt_form.checked = false;
|
||||
self.adopt_form.busy = Busy::Scanning;
|
||||
self.dispatch_adopt(AdoptCommand::Scan);
|
||||
}
|
||||
@@ -173,4 +192,36 @@ mod tests {
|
||||
));
|
||||
assert!(app.state.adopt.scan.is_none());
|
||||
}
|
||||
|
||||
/// 共享档一被点选就发一条**预检**(零写盘),但**不**置 `checked`——确认页要用户点「预检」。
|
||||
///
|
||||
/// 抓得住:`Target` 分支忘了发预检(后果原文永远不出现,契约 §5.2 失守)、
|
||||
/// 或者顺手把 `checked` 也置上(点一下档位就跳到确认页)。
|
||||
#[test]
|
||||
fn choosing_a_foreign_target_previews_but_waits_for_the_user() {
|
||||
let mut app = headless();
|
||||
let _ = app.on_adopt(AdoptMessage::Open);
|
||||
let _ = app.on_adopt(AdoptMessage::Select("1.20.1".to_string()));
|
||||
let _ = app.on_adopt(AdoptMessage::Target(AdoptTargetView::Shared));
|
||||
assert_eq!(app.adopt_form.busy, Busy::Checking);
|
||||
assert!(!app.adopt_form.checked, "确认页要等用户点「预检」");
|
||||
|
||||
// 缺省档不触发自动预检(它不会写进别人的目录)
|
||||
let _ = app.on_adopt(AdoptMessage::Target(AdoptTargetView::InstanceDir));
|
||||
assert!(!app.adopt_form.checked);
|
||||
}
|
||||
|
||||
/// 登记在飞时「关闭」被忽略:core 已经在写了,关掉面板只会让 Done 无处可去。
|
||||
///
|
||||
/// 抓得住:Close 无条件清表单并 `Dismiss`(实例写成功了,界面却什么都没说)。
|
||||
#[test]
|
||||
fn closing_is_ignored_while_the_registration_is_in_flight() {
|
||||
let mut app = headless();
|
||||
let _ = app.on_adopt(AdoptMessage::Open);
|
||||
let _ = app.on_adopt(AdoptMessage::Select("1.20.1".to_string()));
|
||||
let _ = app.on_adopt(AdoptMessage::Check);
|
||||
app.adopt_form.busy = Busy::Importing;
|
||||
let _ = app.on_adopt(AdoptMessage::Close);
|
||||
assert!(app.adopt_form.open, "登记在飞时不许把面板关掉");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user