test(remote): hold the strip to offering a retry only where one can work

`remote_strip_action` exists because of a bug its own comment records: the
label and the action used to be decided separately, so a `ServerMismatch` —
the one state a retry cannot fix — wore a Retry Now button and looped on it
forever. Nothing tested it, so the regression could return in silence.

Three mutations left the suite green: making every state return `Retry`,
dropping the `hosts_our_server` check so a peer somebody else runs offers an
Update Server button that cannot work, and giving a state with no label a
button anyway.

Held now on all four answers — the install for a machine whose server is
ours, a retry for the states a retry fixes, and no button at all for
`Attached`, `RouteLost`, or a server that is not ours to install.
This commit is contained in:
l0ng-ai
2026-08-23 16:18:29 +08:00
parent e83ac36e9d
commit cde91bb928
+87
View File
@@ -3411,4 +3411,91 @@ mod tests {
);
});
}
/// The strip's one button, and the state it must not offer a retry for.
///
/// This function exists because of a bug its own comment records: the
/// label and the action used to be decided separately, so a
/// `ServerMismatch` — the one state a retry cannot fix — wore a Retry Now
/// button and looped on it forever. Nothing tested it. Making every state
/// return `Retry`, dropping the `hosts_our_server` check, or giving a
/// state with no label a button anyway all left the suite green.
#[gpui::test]
fn the_strip_offers_a_retry_only_where_retrying_can_work(cx: &mut gpui::TestAppContext) {
use crate::core::session::{WindowView, WindowViews, WorkspaceStore};
use crate::ui::app::test_window::harness_with_tabs;
let (app, mut vcx, _streams) = harness_with_tabs(cx, 1);
let ws = app.read_with(cx, |app, _| app.workspace);
let bind = |cx: &mut gpui::App, target: RemoteTarget| {
WorkspaceStore::install_for_test(
cx,
WindowViews {
views: vec![WindowView {
id: ws,
host: Some(RemoteRef::new(target, WorkspaceId::new())),
..Default::default()
}],
active: None,
},
);
};
// A machine whose server is ours to install: the mismatch offers the
// install, never a retry.
cx.update(|cx| {
bind(
cx,
RemoteTarget::Alias {
alias: "build-box".into(),
},
)
});
app.update_in(&mut vcx, |app, _window, cx| {
let mismatch = RemoteStatus::ServerMismatch("dialect".into());
let (_, action) = app
.remote_strip_action(&mismatch, cx)
.expect("a machine we can install on gets a button");
assert!(
matches!(action, StripAction::UpdateServer { .. }),
"a retry here can only fail the same way"
);
// Everything else that has a label retries.
let (_, action) = app
.remote_strip_action(&RemoteStatus::Disconnected, cx)
.expect("disconnected has a button");
assert!(matches!(action, StripAction::Retry));
// States with nothing worth pressing have no button at all.
assert!(
app.remote_strip_action(&RemoteStatus::Attached, cx)
.is_none()
);
assert!(
app.remote_strip_action(&RemoteStatus::RouteLost, cx)
.is_none()
);
});
// A peer somebody else runs is not ours to update: the explanation
// stays, the button goes.
cx.update(|cx| {
bind(
cx,
RemoteTarget::LocalStdio {
program: "some-server".into(),
args: Vec::new(),
},
)
});
app.update_in(&mut vcx, |app, _window, cx| {
let mismatch = RemoteStatus::ServerMismatch("dialect".into());
assert!(
app.remote_strip_action(&mismatch, cx).is_none(),
"a server that is not ours to install offers no button"
);
});
}
}