Merge branch 't3/p15-c1-desktop-packages': packages for Windows, macOS and Linux, and the Claude desktop extension (P15 C1)
The two Connect page baselines are re-blessed on the merged code: the page gained the extension row here and the stopped test clock on main. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
813042a7a6
53 files changed
+3875
-276
No files matched your search
@@ -214,7 +214,7 @@ const WARN_AGE: std::time::Duration = std::time::Duration::from_secs(60);
|
||||
const FIRST_CONNECT_KEY: &str = "first_connect_done";
|
||||
|
||||
/// What a window is called when no company is in front.
|
||||
const TITLE: &str = "wanderbooks";
|
||||
const TITLE: &str = "Wanderbooks";
|
||||
|
||||
impl App {
|
||||
/// The live app over one company's books directory.
|
||||
|
||||
@@ -424,6 +424,9 @@ pub struct State {
|
||||
new_address_asked: bool,
|
||||
/// The address was just copied (the time, for the word "Copied").
|
||||
copied_at: Option<f64>,
|
||||
/// The folder the Claude desktop extension was written in, once it
|
||||
/// was (set by the job that made it).
|
||||
extension_folder: Arc<std::sync::Mutex<Option<String>>>,
|
||||
}
|
||||
|
||||
/// The two lines an assistant set up by hand needs.
|
||||
@@ -807,6 +810,7 @@ impl State {
|
||||
want = Some(w);
|
||||
}
|
||||
}
|
||||
self.desktop_row(ui, status, book, &owner, busy, &mut want);
|
||||
another_row(ui, status, book, &owner, &commands, busy, &mut want);
|
||||
if let Some((what, keep, work)) = want {
|
||||
self.start(ui, jobs, what, &keep, work);
|
||||
@@ -842,6 +846,83 @@ impl State {
|
||||
});
|
||||
}
|
||||
|
||||
/// The "Claude desktop app" row (WB-pkg-5): one button that writes the
|
||||
/// one-click extension, and the steps that follow, in plain words.
|
||||
fn desktop_row(
|
||||
&mut self,
|
||||
ui: &mut Ui,
|
||||
status: &Status,
|
||||
book: &str,
|
||||
owner: &Option<Arc<dyn Owner>>,
|
||||
busy: bool,
|
||||
want: &mut Want,
|
||||
) {
|
||||
let p = pal(ui.ctx());
|
||||
let made = self
|
||||
.extension_folder
|
||||
.lock()
|
||||
.map(|f| f.clone())
|
||||
.unwrap_or_default();
|
||||
Frame::new()
|
||||
.fill(p.surface)
|
||||
.stroke(Stroke::new(1.0, p.border))
|
||||
.corner_radius(CornerRadius::same(8))
|
||||
.inner_margin(Margin::symmetric(12, 10))
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new("Claude desktop app").font(theme::semibold(14.5)));
|
||||
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||
if let Some(owner) = owner
|
||||
&& ui
|
||||
.add_enabled(!busy, egui::Button::new("Make the Claude extension"))
|
||||
.on_hover_text(
|
||||
"Writes one file you open in the Claude desktop app to add these books",
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
let (o, b, company) =
|
||||
(owner.clone(), book.to_string(), status.company.clone());
|
||||
let folder = self.extension_folder.clone();
|
||||
*want = Some((
|
||||
"Claude desktop extension".to_string(),
|
||||
"Making the Claude desktop extension".to_string(),
|
||||
Box::new(move || {
|
||||
o.claude_desktop_extension(&b, &company).map(|made| {
|
||||
if let Ok(mut f) = folder.lock() {
|
||||
*f = Some(made.folder.clone());
|
||||
}
|
||||
format!(
|
||||
"made {}. Next: open the Claude desktop app, go to Settings, then Extensions, then Advanced settings, choose Install Extension, and pick that file (or just open the file). Keep Wanderbooks open while you use Claude.",
|
||||
made.file
|
||||
)
|
||||
})
|
||||
}),
|
||||
));
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
ui.label(
|
||||
RichText::new(
|
||||
"Adds these books to the Claude app on this computer with one file, so you type nothing.",
|
||||
)
|
||||
.font(theme::regular(13.0))
|
||||
.color(p.muted),
|
||||
);
|
||||
if let Some(folder) = made {
|
||||
ui.add_space(4.0);
|
||||
if ui
|
||||
.button(format!("{} Show the file", icon::FOLDER_OPEN))
|
||||
.clicked()
|
||||
{
|
||||
crate::export::open(std::path::Path::new(&folder));
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
}
|
||||
|
||||
/// "Connections": every key to these books, who is connected on it,
|
||||
/// what it may do, when it last did anything, and Revoke.
|
||||
fn connections(
|
||||
|
||||
@@ -141,10 +141,17 @@ pub fn open(path: &Path) {
|
||||
#[cfg(target_os = "macos")]
|
||||
let cmd = std::process::Command::new("open").arg(path).spawn();
|
||||
#[cfg(target_os = "windows")]
|
||||
let cmd = std::process::Command::new("cmd")
|
||||
.args(["/C", "start", ""])
|
||||
.arg(path)
|
||||
.spawn();
|
||||
let cmd = {
|
||||
// The window has no console (WB-pkg-2): a console program it
|
||||
// starts would open one for a moment, so it is told not to
|
||||
// (CREATE_NO_WINDOW).
|
||||
use std::os::windows::process::CommandExt;
|
||||
std::process::Command::new("cmd")
|
||||
.args(["/C", "start", ""])
|
||||
.arg(path)
|
||||
.creation_flags(0x0800_0000)
|
||||
.spawn()
|
||||
};
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
let cmd = std::process::Command::new("xdg-open").arg(path).spawn();
|
||||
let _ = cmd;
|
||||
|
||||
@@ -138,14 +138,21 @@ pub fn run(
|
||||
},
|
||||
},
|
||||
};
|
||||
let mut viewport = egui::ViewportBuilder::default()
|
||||
.with_title("Wanderbooks")
|
||||
.with_app_id("wanderbooks")
|
||||
.with_inner_size([1440.0, 920.0])
|
||||
// Small on purpose: tiling window managers hand out small slots
|
||||
// regardless, and every screen lays itself out to fit.
|
||||
.with_min_inner_size([360.0, 400.0]);
|
||||
// The window's own icon (the taskbar on Windows, X11): the packages'
|
||||
// icon. macOS takes its icon from the app bundle, Wayland from the
|
||||
// desktop entry; a failure to decode leaves the system's default.
|
||||
if let Some(icon) = window_icon() {
|
||||
viewport = viewport.with_icon(std::sync::Arc::new(icon));
|
||||
}
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default()
|
||||
.with_title("wanderbooks")
|
||||
.with_app_id("wanderbooks")
|
||||
.with_inner_size([1440.0, 920.0])
|
||||
// Small on purpose: tiling window managers hand out small slots
|
||||
// regardless, and every screen lays itself out to fit.
|
||||
.with_min_inner_size([360.0, 400.0]),
|
||||
viewport,
|
||||
// The platform's place for app settings, never the books' folder
|
||||
// (prefs.rs).
|
||||
persistence_path: prefs::prepare(),
|
||||
@@ -201,3 +208,22 @@ mod exit_tests {
|
||||
assert_eq!(Exit(1).to_string(), "exit code 1");
|
||||
}
|
||||
}
|
||||
|
||||
/// The icon every package carries (`deploy/packaging/icons`), as the window's
|
||||
/// own (WB-pkg-6).
|
||||
fn window_icon() -> Option<egui::IconData> {
|
||||
eframe::icon_data::from_png_bytes(include_bytes!(
|
||||
"../../../deploy/packaging/icons/512x512.png"
|
||||
))
|
||||
.ok()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod window_icon_tests {
|
||||
#[test]
|
||||
fn the_windows_icon_is_the_packages_icon() {
|
||||
let icon = super::window_icon().expect("the icon decodes");
|
||||
assert_eq!((icon.width, icon.height), (512, 512));
|
||||
assert_eq!(icon.rgba.len(), 512 * 512 * 4);
|
||||
}
|
||||
}
|
||||
@@ -412,6 +412,16 @@ pub trait Owner: Send + Sync {
|
||||
fn command_line(&self, _words: &[&str]) -> Result<String, String> {
|
||||
Err("not here".into())
|
||||
}
|
||||
/// The Claude desktop extension for the company `book` (shown as
|
||||
/// `company`): the one-click package written where a person can open it,
|
||||
/// the key made first if there was none. Blocks.
|
||||
fn claude_desktop_extension(
|
||||
&self,
|
||||
_book: &str,
|
||||
_company: &str,
|
||||
) -> Result<ExtensionMade, String> {
|
||||
Err("not here".into())
|
||||
}
|
||||
/// The key an assistant needs to reach the company `book` exists (made
|
||||
/// now if it did not), able to read, draft and post but not to see the
|
||||
/// access record: `Ok(true)` when it was made now. It never replaces a
|
||||
@@ -464,6 +474,11 @@ pub trait Owner: Send + Sync {
|
||||
fn check_for_updates(&self) -> Result<Vec<String>, String> {
|
||||
Err("not here".into())
|
||||
}
|
||||
/// A newer version exists, and where to get it (WB-pkg-3): what the
|
||||
/// program's daily look found. Cheap: called every few seconds.
|
||||
fn newer_version(&self) -> Option<NewerVersion> {
|
||||
None
|
||||
}
|
||||
/// Accept the waiting update: the books' host installs it and restarts
|
||||
/// onto it when no call is running, the books staying open.
|
||||
fn apply_update(&self) -> Result<Vec<String>, String> {
|
||||
@@ -476,6 +491,25 @@ pub trait Owner: Send + Sync {
|
||||
}
|
||||
}
|
||||
|
||||
/// A newer version of the program that the person may get and install over
|
||||
/// this one (WB-pkg-3).
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct NewerVersion {
|
||||
/// Its version.
|
||||
pub version: String,
|
||||
/// The page to get it from: the program's own, never a feed's.
|
||||
pub page: String,
|
||||
}
|
||||
|
||||
/// The Claude desktop extension the Connect page made (WB-pkg-5).
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ExtensionMade {
|
||||
/// The package file, in full.
|
||||
pub file: String,
|
||||
/// The folder it is in.
|
||||
pub folder: String,
|
||||
}
|
||||
|
||||
/// The owner the program gave the viewer, for every company's view that
|
||||
/// isn't given one of its own. It is the program's (one per process, as
|
||||
/// the program is one), not a company's: each view takes a handle to it
|
||||
@@ -623,6 +657,8 @@ pub struct OwnerMenu {
|
||||
/// The update waiting, as last read, and when (re-read every few
|
||||
/// seconds and after any job).
|
||||
update: Option<(std::time::Instant, Option<UpdateWaiting>)>,
|
||||
/// A newer version the person may get, as last read, and when.
|
||||
newer: Option<(std::time::Instant, Option<NewerVersion>)>,
|
||||
/// The tab's threads: every job is one of them (INVARIANT 6).
|
||||
jobs: crate::jobs::Spawner,
|
||||
}
|
||||
@@ -668,6 +704,23 @@ impl OwnerMenu {
|
||||
self.update.as_ref().and_then(|(_, u)| u.clone())
|
||||
}
|
||||
|
||||
/// A newer version to get, if any (read now and then, not every frame).
|
||||
fn newer_version(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
owner: &Arc<dyn Owner>,
|
||||
) -> Option<NewerVersion> {
|
||||
if self
|
||||
.newer
|
||||
.as_ref()
|
||||
.is_none_or(|(at, _)| at.elapsed() > UPDATE_LOOK)
|
||||
{
|
||||
self.newer = Some((std::time::Instant::now(), owner.newer_version()));
|
||||
}
|
||||
ctx.request_repaint_after(UPDATE_LOOK);
|
||||
self.newer.as_ref().and_then(|(_, n)| n.clone())
|
||||
}
|
||||
|
||||
/// The standing notices above the page: an update waiting for the
|
||||
/// owner's accept, and a format upgrade the books wait for, whose
|
||||
/// go-ahead is asked for once each open (INVARIANT 5).
|
||||
@@ -689,7 +742,7 @@ impl OwnerMenu {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(
|
||||
RichText::new(format!(
|
||||
"{} Version {} of wanderbooks is ready.",
|
||||
"{} Version {} of Wanderbooks is ready.",
|
||||
icon::ARROW_FAT_UP,
|
||||
update.version
|
||||
))
|
||||
@@ -719,12 +772,48 @@ impl OwnerMenu {
|
||||
ui.ctx(),
|
||||
(
|
||||
"Update".into(),
|
||||
Effect::Changes("Updating wanderbooks"),
|
||||
Effect::Changes("Updating Wanderbooks"),
|
||||
work,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// No update of the program's own is waiting: is a newer version
|
||||
// out for the person to get and install over this one?
|
||||
else if let Some(newer) = self.newer_version(ui.ctx(), &owner) {
|
||||
let p = crate::theme::pal(ui.ctx());
|
||||
egui::Frame::new()
|
||||
.fill(p.warning_soft)
|
||||
.inner_margin(egui::Margin::symmetric(20, 10))
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(
|
||||
RichText::new(format!(
|
||||
"{} Version {} of Wanderbooks is available.",
|
||||
icon::ARROW_FAT_UP,
|
||||
newer.version
|
||||
))
|
||||
.font(crate::theme::semibold(13.0))
|
||||
.color(p.warning),
|
||||
);
|
||||
ui.label(
|
||||
RichText::new(
|
||||
"Download it and install it over this one. Your books, keys and connections stay as they are.",
|
||||
)
|
||||
.font(crate::theme::regular(13.0))
|
||||
.color(p.text),
|
||||
);
|
||||
if ui
|
||||
.button("Open the download page")
|
||||
.on_hover_text(newer.page.clone())
|
||||
.clicked()
|
||||
{
|
||||
ui.ctx().open_url(egui::OpenUrl::new_tab(newer.page.clone()));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
let Some(upgrade) = books.format_upgrade.clone() else {
|
||||
return;
|
||||
};
|
||||
@@ -752,7 +841,7 @@ impl OwnerMenu {
|
||||
);
|
||||
ui.label(
|
||||
RichText::new(
|
||||
"An older version of wanderbooks wrote them. They work on their old format until you agree; what needs the new one is refused.",
|
||||
"An older version of Wanderbooks wrote them. They work on their old format until you agree; what needs the new one is refused.",
|
||||
)
|
||||
.font(crate::theme::regular(13.0))
|
||||
.color(p.text),
|
||||
@@ -867,7 +956,7 @@ impl OwnerMenu {
|
||||
ui.separator();
|
||||
if ui
|
||||
.button(format!("{} Check for updates", icon::ARROWS_CLOCKWISE))
|
||||
.on_hover_text("Look for a newer version of wanderbooks now")
|
||||
.on_hover_text("Look for a newer version of Wanderbooks now")
|
||||
.clicked()
|
||||
{
|
||||
let o = owner.clone();
|
||||
@@ -886,7 +975,7 @@ impl OwnerMenu {
|
||||
let o = owner.clone();
|
||||
start = Some((
|
||||
"Update".into(),
|
||||
Effect::Changes("Updating wanderbooks"),
|
||||
Effect::Changes("Updating Wanderbooks"),
|
||||
Box::new(move || o.apply_update()),
|
||||
));
|
||||
}
|
||||
@@ -1148,7 +1237,7 @@ fn upgrade_dialog(
|
||||
ui.heading("Upgrade these books' format?");
|
||||
ui.add_space(4.0);
|
||||
ui.label(format!(
|
||||
"An older version of wanderbooks wrote these books, in journal format {}. The upgrade adds {}.",
|
||||
"An older version of Wanderbooks wrote these books, in journal format {}. The upgrade adds {}.",
|
||||
form.upgrade.from.format,
|
||||
form.upgrade.adds().join(", ")
|
||||
));
|
||||
|
||||
@@ -158,7 +158,7 @@ impl Welcome {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.set_max_width(640.0);
|
||||
ui.add_space(36.0);
|
||||
ui.label(RichText::new("Welcome to wanderbooks").font(crate::theme::bold(28.0)));
|
||||
ui.label(RichText::new("Welcome to Wanderbooks").font(crate::theme::bold(28.0)));
|
||||
ui.label(
|
||||
RichText::new(
|
||||
"Your company's books, kept by an assistant and checked by you. A few short steps; nothing here needs a terminal.",
|
||||
|
||||
@@ -247,6 +247,17 @@ impl Owner for Fake {
|
||||
self.note(format!("connect {} {book}", agent.key()));
|
||||
Ok(vec![format!("{} reaches the books.", agent.label())])
|
||||
}
|
||||
fn claude_desktop_extension(
|
||||
&self,
|
||||
book: &str,
|
||||
company: &str,
|
||||
) -> Result<ledger_gui::owner::ExtensionMade, String> {
|
||||
self.note(format!("extension {book} {company}"));
|
||||
Ok(ledger_gui::owner::ExtensionMade {
|
||||
file: "/docs/Wanderbooks/Extensions/wanderbooks-alpha.mcpb".into(),
|
||||
folder: "/docs/Wanderbooks/Extensions".into(),
|
||||
})
|
||||
}
|
||||
fn new_books(&self, _: &str, _: &str) -> Result<String, String> {
|
||||
Err("not here".into())
|
||||
}
|
||||
@@ -731,6 +742,50 @@ fn the_connect_buttons_do_what_connect_does() {
|
||||
drop(h);
|
||||
}
|
||||
|
||||
/// WB-pkg-5: the "Claude desktop app" row makes the extension for this
|
||||
/// company through the owner, then says in words what to do with the file.
|
||||
#[test]
|
||||
fn the_claude_desktop_row_makes_the_extension_and_says_what_to_do_next() {
|
||||
let w = World::new(&[("alpha", "Wanderland Labs")]);
|
||||
let owner = Fake::new();
|
||||
owner.answer(roster(vec![], vec![]));
|
||||
let mut h = start(&w, &["alpha"], &owner);
|
||||
refresh(&mut h);
|
||||
h.state_mut().goto(Route::Connect);
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label_contains("Claude desktop app").is_some());
|
||||
assert!(
|
||||
h.query_by_label_contains("Show the file").is_none(),
|
||||
"nothing is made yet"
|
||||
);
|
||||
h.get_by_role_and_label(Role::Button, "Make the Claude extension")
|
||||
.click();
|
||||
h.run_steps(2);
|
||||
wait_for("the extension was made", || {
|
||||
owner
|
||||
.said()
|
||||
.contains(&"extension alpha Wanderland Labs".to_string())
|
||||
});
|
||||
until(&mut h, "it said what came of it", |a| {
|
||||
a.views()[0].connect_state().said().is_some()
|
||||
});
|
||||
h.run_steps(2);
|
||||
for words in [
|
||||
"wanderbooks-alpha.mcpb",
|
||||
"Settings",
|
||||
"Extensions",
|
||||
"Install Extension",
|
||||
"Keep Wanderbooks open",
|
||||
] {
|
||||
assert!(
|
||||
h.query_by_label_contains(words).is_some(),
|
||||
"{words} is said on the page"
|
||||
);
|
||||
}
|
||||
assert!(h.query_by_label_contains("Show the file").is_some());
|
||||
drop(h);
|
||||
}
|
||||
|
||||
// ---- 5: the warning before a close ---------------------------------------------
|
||||
|
||||
fn connected_alpha(owner: &Fake) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
b2f05e2383abc93a
|
||||
c44ce509bf9179de
|
||||
@@ -1 +1 @@
|
||||
982cea77ed6d057f
|
||||
ceb2e1edc0d868ff
|
||||
@@ -336,7 +336,7 @@ fn each_tab_shows_its_own_company_and_figures() {
|
||||
loaded(&mut h);
|
||||
assert_eq!(titles(&h), ["Alpha Co", "Beta Co"]);
|
||||
assert_eq!(h.state().active(), Some(0));
|
||||
assert_eq!(h.state().window_title(), "Alpha Co · wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Alpha Co · Wanderbooks");
|
||||
|
||||
// Alpha: cash 10,000.00 less 1,234.56 rent is 8,765.44.
|
||||
assert!(shows(&h, "8,765.44"), "alpha's cash: {:?}", texts(&h));
|
||||
@@ -354,7 +354,7 @@ fn each_tab_shows_its_own_company_and_figures() {
|
||||
// Beta: cash 25,000.00 less 777.77 is 24,222.23.
|
||||
show_tab(&mut h, "Beta Co");
|
||||
assert_eq!(h.state().active(), Some(1));
|
||||
assert_eq!(h.state().window_title(), "Beta Co · wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Beta Co · Wanderbooks");
|
||||
assert!(
|
||||
matches!(h.state().route(), Route::Overview),
|
||||
"a tab opens on its overview, not on the page the other was on"
|
||||
@@ -768,7 +768,7 @@ fn start_up_restores_the_open_tabs_their_order_and_the_one_in_front() {
|
||||
assert_eq!(titles(&h), ["Gamma Co", "Alpha Co", "Beta Co"]);
|
||||
assert_eq!(h.state().active(), Some(1), "the same one in front");
|
||||
assert!(h.state().views().iter().all(|v| v.error().is_none()));
|
||||
assert_eq!(h.state().window_title(), "Alpha Co · wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Alpha Co · Wanderbooks");
|
||||
|
||||
// No record: the data root's first, alone.
|
||||
let h2 = start_with_prefs(&w, &[]);
|
||||
@@ -894,15 +894,15 @@ fn closing_the_front_tab_shows_a_neighbour_and_the_last_leaves_an_empty_window()
|
||||
show_tab(&mut h, "Beta Co");
|
||||
close_tab(&mut h, "Beta Co");
|
||||
assert_eq!(titles(&h), ["Alpha Co", "Gamma Co"]);
|
||||
assert_eq!(h.state().window_title(), "Gamma Co · wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Gamma Co · Wanderbooks");
|
||||
// A tab behind the front one closing leaves the front one in front.
|
||||
close_tab(&mut h, "Alpha Co");
|
||||
assert_eq!(titles(&h), ["Gamma Co"]);
|
||||
assert_eq!(h.state().window_title(), "Gamma Co · wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Gamma Co · Wanderbooks");
|
||||
// The last one.
|
||||
close_tab(&mut h, "Gamma Co");
|
||||
assert!(h.state().views().is_empty());
|
||||
assert_eq!(h.state().window_title(), "wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Wanderbooks");
|
||||
assert!(shows(&h, "No company is open"), "{:?}", texts(&h));
|
||||
assert!(
|
||||
shows(&h, "Open a company with the + at the top of the window."),
|
||||
@@ -1737,7 +1737,7 @@ fn the_status_card_shows_the_company_in_front_and_follows_the_tab() {
|
||||
"alpha's hue left the card"
|
||||
);
|
||||
// The window's title still names the company.
|
||||
assert_eq!(h.state().window_title(), "Beta Co · wanderbooks");
|
||||
assert_eq!(h.state().window_title(), "Beta Co · Wanderbooks");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use std::sync::{Arc, Mutex, OnceLock};
|
||||
struct Fake {
|
||||
asked: Mutex<Vec<String>>,
|
||||
staged: Mutex<bool>,
|
||||
newer: Mutex<bool>,
|
||||
}
|
||||
|
||||
impl Fake {
|
||||
@@ -57,6 +58,12 @@ impl Owner for Fake {
|
||||
staged_at: "2026-10-30T08:00:00Z".into(),
|
||||
})
|
||||
}
|
||||
fn newer_version(&self) -> Option<ledger_gui::owner::NewerVersion> {
|
||||
(*self.newer.lock().unwrap()).then(|| ledger_gui::owner::NewerVersion {
|
||||
version: "9.2.0".into(),
|
||||
page: "https://example.test/releases/latest".into(),
|
||||
})
|
||||
}
|
||||
fn check_for_updates(&self) -> Result<Vec<String>, String> {
|
||||
self.said("check");
|
||||
*self.staged.lock().unwrap() = true;
|
||||
@@ -159,7 +166,7 @@ fn the_menu_checks_for_updates_and_a_waiting_update_shows_a_notice_that_accepts(
|
||||
// owner, and the notice goes once it is installed.
|
||||
for _ in 0..60 {
|
||||
h.run_steps(2);
|
||||
if h.query_by_label_contains("Version 9.1.0 of wanderbooks is ready")
|
||||
if h.query_by_label_contains("Version 9.1.0 of Wanderbooks is ready")
|
||||
.is_some()
|
||||
{
|
||||
break;
|
||||
@@ -167,7 +174,7 @@ fn the_menu_checks_for_updates_and_a_waiting_update_shows_a_notice_that_accepts(
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
}
|
||||
assert!(
|
||||
h.query_by_label_contains("Version 9.1.0 of wanderbooks is ready")
|
||||
h.query_by_label_contains("Version 9.1.0 of Wanderbooks is ready")
|
||||
.is_some(),
|
||||
"no notice"
|
||||
);
|
||||
@@ -194,3 +201,51 @@ fn books_outside_a_data_root_have_no_update_notice() {
|
||||
assert!(h.query_by_label_contains("is ready.").is_none());
|
||||
*f.staged.lock().unwrap() = false;
|
||||
}
|
||||
|
||||
/// WB-pkg-3: with no update of the program's own waiting, a newer version
|
||||
/// the daily look found is told in a standing notice that says where to
|
||||
/// get it and that books, keys and connections stay; an update that is
|
||||
/// waiting is the only notice shown (one at a time).
|
||||
#[test]
|
||||
fn a_newer_version_is_told_with_where_to_get_it() {
|
||||
let _alone = alone();
|
||||
let f = fake();
|
||||
*f.newer.lock().unwrap() = true;
|
||||
let (_dir, _book, b) = books(true);
|
||||
let mut h = harness(b);
|
||||
for _ in 0..60 {
|
||||
h.run_steps(2);
|
||||
if h.query_by_label_contains("Version 9.2.0 of Wanderbooks is available")
|
||||
.is_some()
|
||||
{
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
}
|
||||
assert!(
|
||||
h.query_by_label_contains("Version 9.2.0 of Wanderbooks is available")
|
||||
.is_some(),
|
||||
"no notice"
|
||||
);
|
||||
assert!(
|
||||
h.query_by_label_contains("Your books, keys and connections stay as they are")
|
||||
.is_some()
|
||||
);
|
||||
assert!(h.query_by_label("Open the download page").is_some());
|
||||
// One notice at a time: a staged update wins.
|
||||
*f.staged.lock().unwrap() = true;
|
||||
for _ in 0..60 {
|
||||
h.run_steps(2);
|
||||
if h.query_by_label_contains("is ready.").is_some() {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
}
|
||||
assert!(h.query_by_label_contains("is ready.").is_some());
|
||||
assert!(
|
||||
h.query_by_label_contains("Version 9.2.0 of Wanderbooks is available")
|
||||
.is_none()
|
||||
);
|
||||
*f.staged.lock().unwrap() = false;
|
||||
*f.newer.lock().unwrap() = false;
|
||||
}
|
||||
Reference in new issue
Block a user