From 20ea19ab326e6c99026b957c215209be685928e3 Mon Sep 17 00:00:00 2001 From: Valentin Millet Date: Fri, 4 Dec 2026 04:05:20 +0100 Subject: [PATCH 1/2] E2E: journey of the tools, their catalogue walked as one table --- e2e/src/driver.rs | 6 + e2e/src/sdk/clipboard.rs | 6 +- e2e/src/sdk/editor.rs | 16 +- e2e/src/sdk/files.rs | 12 + e2e/src/sdk/mod.rs | 2 +- e2e/src/sdk/shortcut.rs | 3 + e2e/src/sdk/tools.rs | 258 +++++++++++++++++- e2e/src/server.rs | 2 +- e2e/tests/08_tools.rs | 207 +++++++++++++++ e2e/tests/29_tools.rs | 179 ------------- e2e/tests/39_recette_tools.rs | 480 ---------------------------------- 11 files changed, 505 insertions(+), 666 deletions(-) create mode 100644 e2e/tests/08_tools.rs delete mode 100644 e2e/tests/29_tools.rs delete mode 100644 e2e/tests/39_recette_tools.rs diff --git a/e2e/src/driver.rs b/e2e/src/driver.rs index ddcee23e..613f0d8d 100644 --- a/e2e/src/driver.rs +++ b/e2e/src/driver.rs @@ -73,6 +73,12 @@ impl Tree { ids.filter(|id| id.starts_with(start)).collect() } + /// The node whose id begins so and that says `name`. + pub(crate) fn named(&self, start: &str, name: &str) -> Option<&Node> { + let mut nodes = self.nodes.iter().map(|(_, node)| node); + nodes.find(|node| node.author_id().is_some_and(|id| id.starts_with(start)) && said(node) == name) + } + /// What each node wearing `id` says, in reading order. pub(crate) fn texts(&self, id: &str) -> Vec { self.all(id).into_iter().map(said).collect() diff --git a/e2e/src/sdk/clipboard.rs b/e2e/src/sdk/clipboard.rs index 89a6fac9..97cdb4c7 100644 --- a/e2e/src/sdk/clipboard.rs +++ b/e2e/src/sdk/clipboard.rs @@ -23,7 +23,7 @@ impl Clipboard<'_> { pub(super) fn expect_that(&mut self, says: &str, holds: impl Fn(&str) -> bool) { let until = Instant::now() + PATIENCE; loop { - let held = platform::clipboard::System.text().unwrap_or_default(); + let held = held(); if holds(&held) { return; } @@ -37,3 +37,7 @@ impl Clipboard<'_> { } } } + +pub(super) fn held() -> String { + platform::clipboard::System.text().unwrap_or_default() +} diff --git a/e2e/src/sdk/editor.rs b/e2e/src/sdk/editor.rs index 41475c46..154196ed 100644 --- a/e2e/src/sdk/editor.rs +++ b/e2e/src/sdk/editor.rs @@ -50,9 +50,7 @@ impl Editor<'_> { pub fn add_tag(&mut self, tag: &str) { self.0.fill("editor-tag-add", "the field of a new tag", tag); self.0.press(Shortcut::Enter); - self.0.expect("the tag is added", |tree| { - tree.texts("editor-tag").iter().any(|worn| worn.contains(tag)) - }); + self.expect_tag(tag, "the tag is added"); } /// Chooses the language from the keyboard, in its menu's filter. @@ -259,6 +257,18 @@ impl Editor<'_> { self.0.expect(says, |tree| held(tree).contains(code)); } + /// The code holds nothing of this. + pub fn expect_code_without(&mut self, code: &str, says: &str) { + self.0 + .expect(says, |tree| tree.has("editor-body") && !held(tree).contains(code)); + } + + /// The note wears this tag. + pub fn expect_tag(&mut self, tag: &str, says: &str) { + self.0 + .expect(says, |tree| tree.texts("editor-tag").iter().any(|worn| worn.contains(tag))); + } + /// The note's kind is said, and cannot be changed. pub fn expect_no_kind_to_choose(&mut self, says: &str) { self.0.click("editor-kind", "the note's kind"); diff --git a/e2e/src/sdk/files.rs b/e2e/src/sdk/files.rs index ceae082c..a841795c 100644 --- a/e2e/src/sdk/files.rs +++ b/e2e/src/sdk/files.rs @@ -1,6 +1,7 @@ use std::path::{Path, PathBuf}; use super::App; +use crate::server; /// The person's own files, and what they answer to the system's file dialogs: no driver reaches the /// dialog itself. @@ -12,6 +13,11 @@ impl Files<'_> { std::fs::write(self.path(name), bytes).expect("the person's file is written"); } + /// Puts a picture of one pixel, a PNG, among the person's own files. + pub fn put_picture(&mut self, name: &str) { + self.put(name, server::PIXEL); + } + /// Answers this file to the dialogs from now on: the one to read, or the one to write. pub fn answer(&mut self, name: &str) { let path = self.path(name).display().to_string(); @@ -24,6 +30,12 @@ impl Files<'_> { self.0.expect(says, |_| std::fs::read(&path).is_ok_and(|bytes| holds(&bytes))); } + /// A file was written, the same as another. + pub fn expect_same(&mut self, name: &str, as_name: &str, says: &str) { + let wanted = std::fs::read(self.path(as_name)).expect("the other file is read"); + self.expect(name, says, |bytes| bytes == wanted); + } + /// What a file holds, once it is written. pub(super) fn read(&mut self, name: &str, says: &str) -> Vec { let path = self.path(name); diff --git a/e2e/src/sdk/mod.rs b/e2e/src/sdk/mod.rs index 5364aedd..f20314c9 100644 --- a/e2e/src/sdk/mod.rs +++ b/e2e/src/sdk/mod.rs @@ -54,7 +54,7 @@ pub use selection::Selection; pub use shortcut::Shortcut; pub use tags::Tags; pub use todo::Todo; -pub use tools::Tools; +pub use tools::{Copied, Given, Tools}; pub use trash::Trash; pub use tray::{Tray, TrayEntry}; pub use window::{Area, Window}; diff --git a/e2e/src/sdk/shortcut.rs b/e2e/src/sdk/shortcut.rs index 7cd373ae..ab122212 100644 --- a/e2e/src/sdk/shortcut.rs +++ b/e2e/src/sdk/shortcut.rs @@ -46,6 +46,8 @@ pub enum Shortcut { Palette, /// Ctrl+K: the search. Search, + /// Ctrl+Shift+T: the search of the tools. + SearchTools, /// Ctrl+F. Find, /// Ctrl+Alt+G. @@ -88,6 +90,7 @@ impl Shortcut { Self::SelectAll => (Key::A, Modifiers::COMMAND), Self::Palette => (Key::P, Modifiers::COMMAND | Modifiers::ALT), Self::Search => (Key::K, Modifiers::COMMAND), + Self::SearchTools => (Key::T, Modifiers::COMMAND | Modifiers::SHIFT), Self::Find => (Key::F, Modifiers::COMMAND), Self::GoToLine => (Key::G, Modifiers::COMMAND | Modifiers::ALT), Self::Format => (Key::F, Modifiers::SHIFT | Modifiers::ALT), diff --git a/e2e/src/sdk/tools.rs b/e2e/src/sdk/tools.rs index 26b4b49f..4fac11fd 100644 --- a/e2e/src/sdk/tools.rs +++ b/e2e/src/sdk/tools.rs @@ -1,17 +1,273 @@ -use super::App; +use egui::accesskit::Node; + +use super::{App, Shortcut, clipboard}; +use crate::driver::said; /// The tools area: its home and the tool that is open. pub struct Tools<'a>(pub(super) &'a mut App); +/// What a tool is given to answer. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Given { + /// Its *Example*. + Example, + /// Words searched in its table. + Search(&'static str), +} + +/// What copying one of a tool's answers gives, each answer by its name. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Copied { + /// What is shown. + Shown(&'static str), + /// What is shown, and by *Raw* what is written here. + Raw(&'static str, &'static str), + /// A text holding what is written here, shown otherwise. + Holding(&'static str, &'static str), + /// Nothing is to be copied. + Nothing, +} + impl Tools<'_> { + /// Goes to the tools and their search, Ctrl+Shift+T. + pub fn go_to_search(&mut self) { + self.0.press(Shortcut::SearchTools); + self.expect_search_ready("the tools' search has the keyboard"); + } + + /// Searches the tools and their references, over what was searched. + pub fn search(&mut self, words: &str) { + self.0.press(Shortcut::SelectAll); + self.0.type_text(words); + self.0.expect("the search answers", |tree| tree.has("tools-first-result")); + } + + /// Opens the first answer of the search, by Enter. + pub fn open_first(&mut self) { + self.0.press(Shortcut::Enter); + self.expect_tool_open("the first answer opens"); + } + + /// Empties the search, by Esc. + pub fn clear_search(&mut self) { + self.0.press(Shortcut::Escape); + self.0 + .expect("the whole catalogue is back", |tree| !tree.has("tools-first-result")); + } + + /// Leaves one category on the home, from the rail. + pub fn choose_category(&mut self, name: &str) { + self.click_named("tools-rail-category-", name, "the category in the rail"); + } + + /// Goes back to every tool, from the rail. + pub fn show_all(&mut self) { + self.0.click("tools-rail-all", "« All tools »"); + } + /// Opens a tool from the home, by the name it goes by in the catalogue. pub fn open(&mut self, tool: &str) { self.0.click(&format!("tools-entry-{tool}"), "the tool on the home"); self.expect_tool_open("the tool opens"); } + /// Opens a tool from the keyboard: its name searched, walked down to and opened. + pub fn open_from_the_keyboard(&mut self, name: &str) { + self.go_to_search(); + self.search(name); + self.expect_listed(name, "the search finds the tool"); + for _ in 0..40 { + if self.0.tree().focused_says() == name { + break; + } + self.0.press(Shortcut::Down); + } + self.0.press(Shortcut::Enter); + self.expect_open(name, "the tool opens"); + } + + /// Stars the tool open, or takes its star off. + pub fn flip_star(&mut self) { + self.0.click("tool-favourite", "the tool's star"); + } + + /// Gives the tool what it answers. + pub fn give(&mut self, given: Given) { + match given { + Given::Example => self.0.click("tool-sample", "« Example »"), + Given::Search(words) => { + self.0.expect("the table is shown", |tree| tree.has("reference-row")); + let rows = self.0.tree().count("reference-row"); + self.0.replace("reference-search", "the table's search", words); + self.0.expect("the search narrows the table", |tree| { + (1..rows).contains(&tree.count("reference-row")) + }); + } + } + } + + /// The tool answers this, among other things. + pub fn expect_answer(&mut self, words: &str, says: &str) { + self.0.expect(says, |tree| tree.mentions(words)); + } + + /// An answer is copied as it should. + pub fn expect_copied(&mut self, copied: Copied, says: &str) { + match copied { + Copied::Shown(name) => self.expect_copied_as_shown(name, says), + Copied::Raw(name, raw) => { + self.expect_copied_as_shown(name, says); + let named = format!(" {name},"); + self.0.click_where("copy-raw", "the answer's « Raw »", |button| { + said(button).contains(&named) + }); + self.0.clipboard().expect(raw, says); + } + Copied::Holding(name, words) => { + self.copy(name); + self.0.clipboard().expect_saying(words, says); + } + Copied::Nothing => {} + } + } + + /// *Save as note*: the answer filed with a title, in a folder of a space, with a tag. + pub fn save_as_note(&mut self, title: &str, (space, folder): (&str, &str), tag: &str) { + self.0.click("tool-save-as-note", "« Save as note »"); + self.0.replace("save-as-note-title", "the note's title", title); + self.choose("save-as-note-space", "the note's space", space); + self.choose("save-as-note-folder", "the note's folder", folder); + self.0.fill("save-as-note-tags", "the note's tags", tag); + self.0.click("save-as-note-submit", "« Save »"); + self.0.expect("the note is saved", |tree| !tree.has("save-as-note-title")); + } + + /// Fills the tool's text from a note, found in the picker by its title. + pub fn fill_from_note(&mut self, title: &str) { + self.0.click("note-import-text", "« Import from a note »"); + self.0.fill("note-picker-search", "the picker's search", title); + self.0 + .click_where("note-picker-option", "the note in the picker", |note| said(note) == title); + } + + /// Hashes the file answered to the dialog. + pub fn hash_file(&mut self) { + self.0.click("hash-source-1", "« File »"); + self.0.click("hash-pick-file", "the button that picks a file"); + } + + /// Reads the file answered to the dialog into Base64. + pub fn encode_file(&mut self) { + self.0.click("base64-source-1", "« File »"); + self.0.click("base64-pick-file", "the button that picks a file"); + self.0.expect("the file is read", |tree| tree.has("base64-file")); + } + + /// Decodes what the clipboard holds. + pub fn decode_what_was_copied(&mut self) { + let copied = clipboard::held(); + self.0.click("base64-direction-1", "« Decode »"); + self.0.take_keyboard("base64-input", "the text to decode"); + self.0.paste(&copied); + } + + /// Saves the bytes decoded as the file answered to the dialog. + pub fn save_decoded(&mut self) { + self.0.click("base64-save-file", "the button that saves the bytes"); + } + + /// Saves the code drawn as a PNG, in the file answered to the dialog. + pub fn save_code_as_png(&mut self) { + self.0.click("qr-png", "« PNG »"); + } + + /// Saves the code drawn as an SVG, in the file answered to the dialog. + pub fn save_code_as_svg(&mut self) { + self.0.click("qr-svg", "« Download SVG »"); + } + + /// Saves the people drawn, in the file answered to the dialog. + pub fn export_people(&mut self) { + self.0.click("identity-export", "« Export… »"); + } + + /// The tools are on the screen, the keyboard in their search. + pub fn expect_search_ready(&mut self, says: &str) { + self.0 + .expect(says, |tree| tree.has("area-tools") && tree.has_focus("tools-search")); + } + + /// A tool is listed on the home. + pub fn expect_listed(&mut self, name: &str, says: &str) { + self.0.expect(says, |tree| tree.named("tools-entry-", name).is_some()); + } + + /// A tool is not listed on the home. + pub fn expect_not_listed(&mut self, name: &str, says: &str) { + self.0 + .expect(says, |tree| tree.has("tools-search") && tree.named("tools-entry-", name).is_none()); + } + + /// The whole catalogue is listed, and it holds as many tools. + pub fn expect_catalogue_of(&mut self, count: usize, says: &str) { + self.0.expect(says, |tree| { + let entries = tree.all_starting("tools-entry-").into_iter(); + entries.filter(|id| !id.starts_with("tools-entry-star-")).count() == count + }); + } + /// A tool is open. pub fn expect_tool_open(&mut self, says: &str) { self.0.expect(says, |tree| tree.has("area-tools") && tree.has("tool-title")); } + + /// The tool of this name is open. + pub fn expect_open(&mut self, name: &str, says: &str) { + self.0.expect(says, |tree| tree.text("tool-title").as_deref() == Some(name)); + } + + /// A tool is among the favourites on the home. + pub fn expect_favourite(&mut self, name: &str, says: &str) { + self.0.expect(says, |tree| tree.named("tools-favourite-", name).is_some()); + } + + /// The last tools opened, on the home. + pub fn expect_recent(&mut self, names: &[&str], says: &str) { + self.0 + .expect(says, |tree| names.iter().all(|name| tree.named("tools-recent-", name).is_some())); + } + + /// The picture decoded is shown, with what it is. + pub fn expect_picture(&mut self, what: &str, says: &str) { + self.0 + .expect(says, |tree| tree.text("base64-image-facts").is_some_and(|facts| facts.contains(what))); + } + + /// Copies an answer: every line of what is copied is on the screen. + fn expect_copied_as_shown(&mut self, name: &str, says: &str) { + self.copy(name); + let tree = self.0.tree(); + self.0 + .clipboard() + .expect_that(says, |held| !held.is_empty() && held.lines().all(|line| tree.mentions(line))); + } + + fn copy(&mut self, name: &str) { + let named = format!(" {name}"); + self.0 + .click_where("copy-value", "the answer's copy", |button| said(button).ends_with(&named)); + } + + /// Chooses a place in a menu of *Save as note*. + fn choose(&mut self, menu: &str, name: &str, place: &str) { + self.0.click(menu, name); + self.click_named(&format!("{menu}-"), place, "the place in the menu"); + } + + fn click_named(&mut self, start: &str, label: &str, name: &str) { + let id = self.0.seen(&format!("{name} is on the screen"), |tree| { + tree.named(start, label).and_then(Node::author_id).map(str::to_owned) + }); + self.0.click(&id, name); + } } diff --git a/e2e/src/server.rs b/e2e/src/server.rs index 1060f185..e7dc3b9f 100644 --- a/e2e/src/server.rs +++ b/e2e/src/server.rs @@ -154,7 +154,7 @@ fn reply(path: &str, head: &str, sent: &[u8]) -> Reply { } /// One white pixel. -const PIXEL: &[u8] = &[ +pub(crate) const PIXEL: &[u8] = &[ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0xf8, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x09, diff --git a/e2e/tests/08_tools.rs b/e2e/tests/08_tools.rs new file mode 100644 index 00000000..c2e11635 --- /dev/null +++ b/e2e/tests/08_tools.rs @@ -0,0 +1,207 @@ +//! Journey 8, « The tools »: the home and its search, the whole catalogue walked as one table, what +//! is remembered of it, an answer kept as a note, and the tools that read or write files. + +use e2e::{App, Area, Copied, Given, Language, step}; + +/// A row per tool and reference: its name, what it is given, what it answers, and how that copies. +/// A tool added to the application is a row added here. +const CATALOGUE: &[(&str, Given, &str, Copied)] = &[ + ("Case converter", Given::Example, "parse_url_and_http_server", Copied::Shown("snake_case")), + ("Line breaks", Given::Example, "2 lines trimmed", Copied::Shown("Result")), + ("Text statistics", Given::Example, "34 distinct characters", Copied::Nothing), + ("Diff", Given::Example, "+ 4 lines", Copied::Nothing), + ("Hash / HMAC", Given::Example, MD5, Copied::Shown("MD5")), + ("Passwords", Given::Example, "bits of entropy", Copied::Shown("#1")), + ("Identifiers", Given::Example, "ULID · 26 characters, base32", Copied::Shown("every identifier")), + ("JWT", Given::Example, "Valid signature.", Copied::Shown("Payload")), + ("URL", Given::Example, "caf%C3%A9%20cr%C3%A8me", Copied::Shown("Encoded")), + ("Base64 and other bases", Given::Example, "Q2Fmw6k=", Copied::Shown("Base64")), + ("JSON ↔ YAML ↔ TOML ↔ XML", Given::Example, "codePostal = \"75001\"", Copied::Shown("Result")), + ("Colours", Given::Example, "oklch(65.2% 0.19 253.2)", Copied::Shown("OKLCH")), + ("JSON", Given::Example, "\"createdAt\"", Copied::Shown("Documents")), + ( + "Fictitious identity", + Given::Example, + "the same person comes back", + Copied::Shown("Document number (made up)"), + ), + ("Lorem ipsum", Given::Example, "Lorem ipsum dolor sit amet", Copied::Shown("Lorem ipsum")), + ("QR code", Given::Example, "25 × 25 modules", Copied::Nothing), + ("Dates and durations", Given::Example, "2023-11-14T22:13:20Z", Copied::Shown("ISO 8601 · UTC")), + ("Time zones", Given::Example, "UTC+09:00", Copied::Holding("Asia/Tokyo", "+09:00")), + ("Cron", Given::Example, "Every 15 minutes, from 9:00 to 18:00", Copied::Nothing), + ("Sizes and transfer", Given::Example, "4,700,000,000", Copied::Raw("B", "4700000000")), + ("Unix permissions", Given::Example, "chmod 754 file", Copied::Shown("chmod")), + ( + "Luhn and IBAN", + Given::Example, + "FR76 3000 6000 0112 3456 7890 189", + Copied::Raw("IBAN", "FR7630006000011234567890189"), + ), + ("CIDR subnets", Given::Example, "255.255.248.0", Copied::Shown("Mask")), + ("HTTP status codes", Given::Search("teapot"), "418", Copied::Shown("418")), + ("HTTP headers", Given::Search("etag"), "ETag", Copied::Shown("ETag")), + ("MIME types", Given::Search("svg"), "image/svg+xml", Copied::Shown("image/svg+xml")), + ("Common ports", Given::Search("postgres"), "5432", Copied::Shown("5432")), + ("Unix signals", Given::Search("sigterm"), "SIGTERM", Copied::Shown("SIGTERM")), + ("ASCII table", Given::Search("0x26"), "38", Copied::Shown("&")), + ("Regex cheat sheet", Given::Search("lookahead"), "(?=…)", Copied::Shown("(?=…)")), + ("Markdown cheat sheet", Given::Search("footnote"), "[^1]", Copied::Shown("[^1]")), + ("Mustache cheat sheet", Given::Search("partial"), "{{> partial}}", Copied::Shown("{{> partial}}")), +]; + +/// Of « hello world », in the Example and in a file. +const MD5: &str = "5eb63bbbe01eeed093cb22bb8f5acdc3"; +/// A favourite is not said again among the last ones opened. +const RECENT: [&str; 2] = ["Colours", "Mustache cheat sheet"]; +const SPACE: &str = "Workshop"; +const FOLDER: &str = "Digests"; + +#[test] +fn tools() { + let mut app = App::open("08_tools"); + app.prefs().change(|prefs| prefs.choose_language(Language::English)); + app.window().widen(); + app.rail().new_space(SPACE); + app.rail().new_folder(FOLDER); + + the_home(&mut app); + the_catalogue(&mut app); + what_is_remembered(&mut app); + with_the_notes(&mut app); + with_files(&mut app); + app.quit(); +} + +fn the_home(app: &mut App) { + step("from the notes, the shortcut goes to the tools and their search", || { + app.tools().go_to_search(); + app.tools().expect_catalogue_of(CATALOGUE.len(), "the home lists every tool"); + app.capture("home"); + }); + + step("a keyword finds the tool it is for, and Enter opens it", || { + app.tools().search("crlf"); + app.tools().expect_listed("Line breaks", "the tool answers"); + app.tools().expect_not_listed("Hash / HMAC", "the others are gone"); + app.tools().open_first(); + app.tools().expect_open("Line breaks", "its tool opens"); + }); + + step("what no tool answers is found in the references", || { + app.tools().go_to_search(); + app.tools().search("418"); + app.tools().expect_answer("teapot", "the reference's row is shown"); + app.tools().open_first(); + app.tools().expect_open("HTTP status codes", "its reference opens"); + }); + + step("the home is sorted by category", || { + app.tools().go_to_search(); + app.tools().clear_search(); + app.tools().choose_category("Time"); + app.tools().expect_listed("Cron", "the category's tools are listed"); + app.tools().expect_not_listed("Hash / HMAC", "the others are not"); + app.tools().show_all(); + app.tools().expect_listed("Hash / HMAC", "every tool is back"); + }); +} + +fn the_catalogue(app: &mut App) { + for &(tool, given, answer, copied) in CATALOGUE { + step(&format!("{tool}: opened from the keyboard, it answers, and its answer is copied"), || { + app.tools().open_from_the_keyboard(tool); + app.tools().give(given); + app.tools().expect_answer(answer, "it answers"); + app.tools().expect_copied(copied, "the answer is copied"); + }); + } +} + +fn what_is_remembered(app: &mut App) { + step("a star makes a favourite, and the last ones opened are listed, over a relaunch", || { + app.tools().open_from_the_keyboard("Cron"); + app.tools().flip_star(); + app.tools().open_from_the_keyboard("Colours"); + app.tools().go_to_search(); + app.tools().clear_search(); + app.tools().expect_favourite("Cron", "the starred one is a favourite"); + app.tools().expect_recent(&RECENT, "the last ones opened are listed"); + app.relaunch_and_unlock(); + app.tools().expect_favourite("Cron", "it still is"); + app.tools().expect_recent(&RECENT, "they still are"); + app.capture("remembered"); + }); +} + +fn with_the_notes(app: &mut App) { + step("*Save as note* files the answer where it is told, never what was typed", || { + app.tools().open_from_the_keyboard("Hash / HMAC"); + app.tools().give(Given::Example); + app.tools().expect_answer(MD5, "it answers"); + app.tools().save_as_note("Digests of a greeting", (SPACE, FOLDER), "checksum"); + app.window().go_to(Area::Notes); + app.rail().open_folder(FOLDER); + app.notes().open("Digests of a greeting"); + app.editor().expect_code_holding(MD5, "the note holds the answer"); + app.editor().expect_code_without("hello world", "and not what was typed"); + app.editor().expect_tag("checksum", "with its tag"); + app.editor().close(); + }); + + step("a tool's text is filled from a note", || { + app.notes().write_snippet("Search address", "a b&c"); + app.tools().open_from_the_keyboard("URL"); + app.tools().fill_from_note("Search address"); + app.tools().expect_answer("a%20b%26c", "it answers the note"); + }); +} + +fn with_files(app: &mut App) { + step("a file is hashed", || { + app.files().put("greeting.txt", b"hello world"); + app.files().answer("greeting.txt"); + app.tools().open_from_the_keyboard("Hash / HMAC"); + app.tools().hash_file(); + app.tools().expect_answer(MD5, "the file's digest is the text's"); + app.tools().expect_copied(Copied::Shown("MD5"), "it is copied"); + }); + + step("a picture is read into Base64, decoded into what it shows, and saved back", || { + app.files().put_picture("dot.png"); + app.files().answer("dot.png"); + app.tools().open_from_the_keyboard("Base64 and other bases"); + app.tools().encode_file(); + app.tools().expect_copied(Copied::Shown("Base64"), "its Base64 is copied"); + app.tools().decode_what_was_copied(); + app.tools().expect_picture("1 × 1", "the picture is shown, with its size"); + app.capture("base64"); + app.files().answer("back.png"); + app.tools().save_decoded(); + app.files() + .expect_same("back.png", "dot.png", "the bytes saved are the picture's"); + }); + + step("a QR code is saved as PNG and as SVG", || { + app.tools().open_from_the_keyboard("QR code"); + app.tools().give(Given::Example); + app.tools().expect_answer("25 × 25 modules", "the code is drawn"); + app.files().answer("code.png"); + app.tools().save_code_as_png(); + app.files() + .expect("code.png", "the PNG is written", |bytes| bytes.starts_with(b"\x89PNG")); + app.files().answer("code.svg"); + app.tools().save_code_as_svg(); + app.files() + .expect("code.svg", "the SVG is written", |bytes| bytes.starts_with(b"<")); + }); + + step("fictitious people are saved", || { + app.tools().open_from_the_keyboard("Fictitious identity"); + app.tools().give(Given::Example); + app.files().answer("people.json"); + app.tools().export_people(); + app.files() + .expect("people.json", "the people are written", |bytes| bytes.starts_with(b"[")); + }); +} diff --git a/e2e/tests/29_tools.rs b/e2e/tests/29_tools.rs deleted file mode 100644 index afac7b5d..00000000 --- a/e2e/tests/29_tools.rs +++ /dev/null @@ -1,179 +0,0 @@ -//! The tools' home: reached from the notes on its shortcut, its search finding a tool by a keyword, -//! the tool opened from the keyboard, its star and its place among the recent ones over a relaunch. - -use e2e::old::{App, Tree, step}; -use egui::accesskit::Node; -use egui::{Key, Modifiers}; - -fn search_is_focused(tree: &Tree) -> bool { - tree.focused().contains("tools-search") -} - -fn home(app: &mut App) { - step("the home opens on its search from the notes", || { - app.press(Key::T, Modifiers::COMMAND | Modifiers::SHIFT); - app.wait_for("area-tools"); - app.eventually("the search takes the focus", search_is_focused); - }); - step("a keyword narrows the catalogue", || { - app.fill("tools-search", "crlf"); - app.wait_for("tools-entry-line-breaks"); - app.eventually("the others are gone", |tree| tree.find("tools-entry-hash").is_none()); - app.press(Key::Escape, Modifiers::NONE); - app.wait_for("tools-entry-hash"); - }); -} - -fn a_tool(app: &mut App) { - step("Enter opens the first result, in its frame", || { - app.fill("tools-search", "cron"); - app.wait_for("tools-first-result"); - app.press(Key::Enter, Modifiers::NONE); - app.wait_for("tool-title"); - app.wait_for("tools-rail-tool-zones"); - }); - step("its star files it under the favourites", || { - app.click("tool-favourite"); - app.wait_for("tools-rail-favourites"); - }); - step("Ctrl+K goes back to the search", || { - app.press(Key::K, Modifiers::COMMAND); - app.eventually("the search takes the focus", search_is_focused); - app.press(Key::Escape, Modifiers::NONE); - app.wait_for("tools-favourite-cron"); - }); -} - -fn text_tools(app: &mut App) { - step("the case converter answers what is typed", || { - app.click("tools-entry-case"); - app.wait_for("tool-title"); - app.fill("case-input", "parse URL"); - app.eventually("the cases are shown", |tree| { - tree.texts("output-value").iter().any(|it| it == "parse_url") - }); - }); - step("the diff compares two texts", || { - app.click("tools-rail-tool-diff"); - app.fill("text-diff-a", "one"); - app.fill("text-diff-b", "two"); - app.wait_for("text-diff-rows"); - app.click("tool-clear"); - app.click("tool-back"); - }); -} - -/// By the search: the catalogue is longer than the window. -fn open_tool(app: &mut App, tool: &str) { - app.fill("tools-search", tool); - app.eventually("the catalogue is narrowed", |tree| !tree.has("tools-entry-hash")); - app.click(&format!("tools-entry-{tool}")); - app.wait_for("tool-title"); -} - -/// With the search let go: what it holds stays on the home. -fn back_to_the_home(app: &mut App) { - app.click("tool-back"); - app.click("tools-search"); - app.press(Key::Escape, Modifiers::NONE); - app.wait_for("tools-entry-hash"); -} - -fn data_tools(app: &mut App) { - step("a document is converted, and the swap brings it back", || { - open_tool(app, "convert"); - app.fill("convert-input", r#"{"service":"billing"}"#); - app.eventually("the YAML is shown", |tree| { - tree.text("convert-output").is_some_and(|it| it.contains("service: billing")) - }); - app.click("convert-swap"); - app.eventually("the JSON is back", |tree| { - tree.text("convert-output").is_some_and(|it| it.contains('{')) - }); - back_to_the_home(app); - }); - step("a seed brings the same person back", || { - open_tool(app, "identity"); - app.wait_for("identity-card"); - let drawn = app.tree().text("identity-surname"); - app.fill("identity-seed", "devnotes"); - app.wait_for("identity-seed-pinned"); - app.eventually("the seed's person is on the card", |tree| tree.text("identity-surname") != drawn); - let surname = app.tree().text("identity-surname"); - retype(app, "identity-seed", "another"); - app.eventually("another person is drawn", |tree| tree.text("identity-surname") != surname); - retype(app, "identity-seed", "devnotes"); - app.eventually("the first person is back", |tree| tree.text("identity-surname") == surname); - back_to_the_home(app); - }); - step("a code is drawn from a URL", || { - open_tool(app, "qr"); - app.fill("qr-url", "https://exemple.fr/doc"); - app.wait_for("qr-code"); - back_to_the_home(app); - }); -} - -fn references(app: &mut App) { - step("a code no tool answers is found in the references", || { - app.fill("tools-search", "418"); - app.wait_for("tools-references"); - app.wait_for("tools-first-result"); - assert!(!app.has("tools-no-match")); - app.press(Key::Enter, Modifiers::NONE); - app.wait_for("reference-search"); - app.eventually("the table is whole, its own search empty", |tree| { - tree.count("reference-row") > 3 - && tree.find("reference-search").and_then(Node::value) != Some("418") - }); - back_to_the_home(app); - }); - step("the rest of a reference opens it searched", || { - app.fill("tools-search", "cors"); - app.click("tools-reference-more"); - app.eventually("the reference is searched for it", |tree| { - tree.find("reference-search").and_then(Node::value) == Some("cors") - }); - back_to_the_home(app); - }); -} - -fn remembered(mut app: App) -> App { - step("the star and the recent tools come back", || { - app.click("tools-entry-case"); - app.wait_for("tool-title"); - }); - let mut app = app.relaunch(); - step("over a relaunch", || { - app.fill("vault-passphrase", e2e::old::PASSPHRASE); - app.click("vault-submit"); - app.wait_for("tools-favourite-cron"); - app.wait_for("tools-recent-case"); - let tree = app.tree(); - assert!(tree.text("tools-count").is_some_and(|words| words.contains("32"))); - }); - app -} - -/// Over what the field holds: `fill` types at the caret, and a second click only selects the -/// word when it comes within the double click's delay, which is the machine's speed. -fn retype(app: &mut App, author_id: &str, text: &str) { - app.click(author_id); - app.press(Key::A, Modifiers::COMMAND); - app.type_text(text); -} - -#[test] -fn tools_home() { - let profile = tempfile::tempdir().unwrap(); - let mut app = App::launch("29_tools", profile.path()); - app.create_library(); - app.wait_for("note-card"); - - home(&mut app); - a_tool(&mut app); - text_tools(&mut app); - data_tools(&mut app); - references(&mut app); - remembered(app).quit(); -} diff --git a/e2e/tests/39_recette_tools.rs b/e2e/tests/39_recette_tools.rs deleted file mode 100644 index c2e0b971..00000000 --- a/e2e/tests/39_recette_tools.rs +++ /dev/null @@ -1,480 +0,0 @@ -//! The acceptance sheet's main paths through the tools: each case typed as the sheet writes it and -//! its answer read from the window, in French, the sheet's language. A step opens on the case it -//! runs, so that a run can be read back into the sheet. - -use e2e::old::{App, PASSPHRASE, step}; -use egui::{Key, Modifiers}; - -const FRENCH: &str = "setting-locale-1"; -const JWT: &str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJyZWNldHRlIiwibmFtZSI6IlJlY2V0dGUgRGV2Tm90ZXMiLCJpYXQiOjE3NjcyMjU2MDAsImV4cCI6MTkyNDk5MjAwMH0.89V7D9SwqkMbyIoAbtwhgH3y8UgxyoI4vKAN_pgawSY"; -const PIXEL: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; -const SCHEMA: &str = r#"{"type":"object","required":["id","email","age","role"],"properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"age":{"type":"integer","minimum":18,"maximum":99},"role":{"enum":["admin","lecteur","redacteur"]}}}"#; - -/// One line of the sheet: the tool, its field, what is typed, and what must be read. -type Case = (&'static str, &'static str, &'static str, &'static str, &'static [&'static str]); - -const CASES: &[Case] = &[ - ( - "TXT-01", - "case", - "case-input", - "parse HTTP response", - &[ - "parseHttpResponse", - "ParseHttpResponse", - "parse_http_response", - "PARSE_HTTP_RESPONSE", - "parse-http-response", - "Parse-Http-Response", - "parse.http.response", - "parse/http/response", - "parsehttpresponse", - "Parse Http Response", - "Parse http response", - "PARSE HTTP RESPONSE", - ], - ), - ( - "CRY-01", - "hash", - "hash-input", - "DevNotes", - &[ - "7fd0b69809fbca9dc53d03ab5450e18d", - "f8148cf8eb16a1419d5ffa6819b8338ed76a13b2", - "7a215fd1357dc4712283d610bd18335a1e28066bc839535bca7c10c5069ea3bb", - "a1c24cfd5aac355e70003a964af2264228f8214317d3f9f004a89133b340a2ed", - "345e99d395", - "8 octets", - ], - ), - ( - "ENC-01", - "url-codec", - "url-codec-decoded", - "café crème & croissants", - &["caf%C3%A9%20cr%C3%A8me%20%26%20croissants"], - ), - ( - "ENC-06", - "base64", - "base64-input", - "Café ☕", - &[ - "6 caractères", - "9 octets", - "Q2Fmw6kg4piV", - "INQWNQ5JEDRJRFI=", - "43 61 66 c3 a9 20 e2 98 95", - "67 97 102 195 169 32 226 152 149", - ], - ), - ( - "ENC-13", - "convert", - "convert-input", - r#"{"service":"billing","replicas":2,"tags":["api","web"],"debug":null}"#, - &["service: billing", "replicas: 2", "debug: null"], - ), - ("ENC-19", "colour", "colour-input", "#1e90ff", &["#1e90ff", "30 144 255", "209.6", "oklch("]), - ("GEN-18", "qr", "qr-url", "https://devnotes.fr", &["Récupérable"]), - ("TPS-01", "dates", "dates-input", "1790000000", &["2026-09-21T14:13:20Z", "secondes", "lundi"]), - ("TPS-18", "cron", "cron-input", "*/15 9-18 * * MON-FRI", &["15 minutes", "lundi", "vendredi"]), - ("CMP-01", "sizes", "sizes-input", "1,5 Go", &["1 500 000 000", "1,397", "1 430,51", "12"]), - ("CMP-07", "permissions", "permissions-octal", "755", &["rwxr-xr-x", "chmod"]), - ("CMP-13", "checks", "checks-input", "4111 1111 1111 1111", &["Valide", "Visa"]), - ( - "CMP-13", - "checks", - "checks-input", - "4111 1111 1111 1112", - &["Invalide", "Le dernier chiffre devrait être 1."], - ), - ("CMP-13", "checks", "checks-input", "378282246310005", &["Valide", "American Express"]), - ("CMP-13", "checks", "checks-input", "5555 5555 5555 4444", &["Valide", "Mastercard"]), - ( - "CMP-14", - "checks", - "checks-input", - "FR14 2004 1010 0505 0001 3M02 606", - &["20041", "01005", "0500013M026", "06", "Valide"], - ), - ( - "CMP-19", - "cidr", - "cidr-network", - "10.24.8.0/21", - &[ - "10.24.8.0", - "255.255.248.0", - "0.0.7.255", - "10.24.8.1", - "10.24.15.254", - "10.24.15.255", - "2 046", - "2 048", - ], - ), -]; - -/// From the home, its search emptied: the window is wide enough for every tool to be in view. -fn open_tool(app: &mut App, tool: &str) { - if app.has("tool-back") { - app.click("tool-back"); - } - app.wait_for("tools-search"); - app.click("tools-search"); - app.press(Key::A, Modifiers::COMMAND); - app.press(Key::Backspace, Modifiers::NONE); - app.click(&format!("tools-entry-{tool}")); - app.wait_for("tool-title"); -} - -fn reads(app: &mut App, words: &[&str]) { - for word in words { - app.eventually(&format!("« {word} » is read"), |tree| tree.mentions(word)); - } -} - -fn retype(app: &mut App, field: &str, input: &str) { - app.click(field); - app.press(Key::A, Modifiers::COMMAND); - app.press(Key::Backspace, Modifiers::NONE); - app.paste(input); -} - -fn in_french(app: &mut App) { - app.click("file-menu"); - app.click("file-preferences"); - app.click("setting-locale"); - app.click(FRENCH); - app.click("settings-close"); - app.eventually("the panel closed", |tree| !tree.has("settings-dialog")); -} - -fn the_tools(scenario: &'static str, profile: &std::path::Path) -> App { - let mut app = App::launch(scenario, profile); - app.create_library(); - in_french(&mut app); - app.resize(1800, 1000); - app.press(Key::Num2, Modifiers::COMMAND); - app.wait_for("area-tools"); - app -} - -#[test] -fn recette_the_table_of_the_sheet() { - let profile = tempfile::tempdir().unwrap(); - let mut app = the_tools("39_recette_tools", profile.path()); - for (case, tool, field, input, words) in CASES { - step(&format!("{case} {tool}: {input}"), || { - open_tool(&mut app, tool); - retype(&mut app, field, input); - reads(&mut app, words); - app.capture(&format!("{case}-{tool}")); - }); - } - app.quit(); -} - -#[test] -fn recette_tools_of_several_gestures() { - let profile = tempfile::tempdir().unwrap(); - let mut app = the_tools("39_recette_gestures", profile.path()); - - step("TXT-07 mixed endings are read and put right", || { - open_tool(&mut app, "line-breaks"); - retype(&mut app, "line-breaks-input", "un\r\ndeux \ntrois\rquatre "); - app.wait_for("line-breaks-found"); - app.capture("TXT-06"); - app.click("line-breaks-trim"); - app.capture("TXT-07"); - }); - - step("TXT-08 what is counted of a flag", || { - open_tool(&mut app, "text-stats"); - retype(&mut app, "text-stats-input", "Hé 🇫🇷\nok"); - reads(&mut app, &["7", "8", "10", "15"]); - app.capture("TXT-08"); - }); - - step("TXT-11 two texts compared", || { - open_tool(&mut app, "diff"); - retype(&mut app, "text-diff-a", "un\ndeux\ntrois\n"); - retype(&mut app, "text-diff-b", "un\n2\n3\n"); - app.wait_for("text-diff-rows"); - app.capture("TXT-11"); - app.click("tool-clear"); - }); - - step("TXT-14 two documents compared as data", || { - app.click("diff-mode-1"); - retype(&mut app, "structured-diff-a", r#"{"total":126,"client":{"ville":"Lyon"},"remise":null}"#); - retype( - &mut app, - "structured-diff-b", - r#"{"total":138,"client":{"ville":"Villeurbanne"},"payeeLe":"2026-10-02"}"#, - ); - reads(&mut app, &["total", "client.ville", "remise", "payeeLe"]); - app.capture("TXT-14"); - app.click("tool-clear"); - }); - - app.quit(); -} - -#[test] -fn recette_crypto() { - let profile = tempfile::tempdir().unwrap(); - let mut app = the_tools("39_recette_crypto", profile.path()); - - step("CRY-03 HMAC in hex, then in base64", || { - open_tool(&mut app, "hash"); - retype(&mut app, "hash-input", "DevNotes"); - app.click("hash-hmac"); - retype(&mut app, "hash-key", "secret"); - reads(&mut app, &["4b86bba0e71ff3bea4180fc0ee8abc4d7f5939927d5f1a1acee89b837e47ec7a"]); - app.click("hash-encoding-1"); - reads(&mut app, &["S4a7oOcf876kGA/A7oq8TX9ZOZJ9Xxoazuibg35H7Ho="]); - app.capture("CRY-03"); - }); - - step("CRY-08 passwords drawn, and drawn again", || { - open_tool(&mut app, "password"); - app.wait_for("password-strength"); - app.capture("CRY-08"); - let first = app.tree().texts("output-value"); - app.click("password-generate"); - app.eventually("others are drawn", |tree| tree.texts("output-value") != first); - }); - - step("CRY-11 identifiers of each kind", || { - open_tool(&mut app, "identifiers"); - app.wait_for("identifiers-row"); - app.capture("CRY-11"); - }); - - step("CRY-12 identifiers read back", || { - for (id, words) in [ - ("01ARZ3NDEKTSV4RRFFQ69G5FAV", &["ULID", "2016"][..]), - ("550e8400-e29b-41d4-a716-446655440000", &["UUID", "RFC 9562"]), - ("507f1f77bcf86cd799439011", &["ObjectId", "2012"]), - ("00000000-0000-0000-0000-000000000000", &["UUID nul"]), - ("bonjour", &["Aucun identifiant connu"]), - ] { - retype(&mut app, "identifiers-checked", id); - reads(&mut app, words); - } - app.capture("CRY-12"); - }); - - step("CRY-13 a token read and checked", || { - open_tool(&mut app, "jwt"); - retype(&mut app, "jwt-token", JWT); - reads(&mut app, &["HS256", "recette", "Recette DevNotes"]); - app.click("jwt-secret"); - app.type_text("secret"); - reads(&mut app, &["Signature valide."]); - app.capture("CRY-13"); - }); - - app.quit(); -} - -#[test] -fn recette_encoders() { - let profile = tempfile::tempdir().unwrap(); - let mut app = the_tools("39_recette_encoders", profile.path()); - - step("ENC-04 a URL taken apart", || { - open_tool(&mut app, "url-codec"); - app.click("url-tab-1"); - retype( - &mut app, - "url-parser-input", - "https://ada:pwd@api.exemple.fr:8443/v1/factures?statut=payée&page=2#total", - ); - reads(&mut app, &["https", "ada", "pwd", "api.exemple.fr", "8443", "/v1/factures", "payée", "total"]); - app.capture("ENC-04"); - }); - - step("ENC-08 a format recognised, ENC-11 a picture shown", || { - open_tool(&mut app, "base64"); - app.click("base64-direction-1"); - for (written, read) in [ - ("Q2Fmw6k=", "Café"), - ("43 61 66 c3 a9", "Café"), - ("01000011 01100001", "Ca"), - ("67 97 102", "Caf"), - ] { - retype(&mut app, "base64-input", written); - reads(&mut app, &[read]); - } - app.capture("ENC-08"); - retype(&mut app, "base64-input", PIXEL); - app.wait_for("base64-image-facts"); - app.capture("ENC-11"); - }); - - step("ENC-19 what is no colour, ENC-20 a contrast put right", || { - open_tool(&mut app, "colour"); - retype(&mut app, "colour-input", "pas-une-couleur"); - app.wait_for("colour-invalid"); - retype(&mut app, "colour-input", "#777777"); - retype(&mut app, "colour-against", "#ffffff"); - reads(&mut app, &["4,48"]); - app.click("colour-fix"); - reads(&mut app, &["4,5"]); - app.capture("ENC-20"); - }); - - app.quit(); -} - -#[test] -fn recette_the_rest() { - let profile = tempfile::tempdir().unwrap(); - let mut app = the_tools("39_recette_rest", profile.path()); - - step("GEN-01 documents drawn from a schema", || { - open_tool(&mut app, "json-generator"); - retype(&mut app, "json-generator-input", SCHEMA); - retype(&mut app, "json-generator-count", "3"); - app.wait_for("json-generator-seed-used"); - app.capture("GEN-01"); - }); - - step("GEN-16 lorem ipsum, opening on its words", || { - open_tool(&mut app, "lorem"); - reads(&mut app, &["Lorem ipsum dolor sit amet, consectetur adipiscing elit"]); - let first = app.tree().text("lorem-output"); - app.click("lorem-again"); - app.eventually("another text", |tree| tree.text("lorem-output") != first); - }); - - step("TPS-07 a gap, TPS-10 a duration", || { - open_tool(&mut app, "dates"); - app.wait_for("dates-input"); - retype(&mut app, "dates-from", "2026-01-01 00:00"); - retype(&mut app, "dates-to", "2026-03-01 12:00"); - reads(&mut app, &["59 j 12 h 00", "8 sem 3 j", "1 428 h 00"]); - app.capture("TPS-07"); - retype(&mut app, "dates-duration", "PT1H30M"); - reads(&mut app, &["5 400"]); - retype(&mut app, "dates-duration", "1h30"); - reads(&mut app, &["PT1H30M"]); - retype(&mut app, "dates-duration", "P1M"); - reads(&mut app, &["Un mois ou une année n’a pas de durée fixe"]); - app.capture("TPS-10"); - }); - - step("CMP-13 numbers drawn that pass", || { - open_tool(&mut app, "checks"); - app.wait_for("checks-numbers"); - retype(&mut app, "checks-prefix", "4242"); - app.eventually("five that begin so", |tree| { - let drawn = tree.texts("output-value"); - drawn.len() == 5 && drawn.iter().all(|it| it.starts_with("4242")) - }); - app.capture("CMP-13-generate"); - }); - - step("CMP-05 a transfer timed", || { - open_tool(&mut app, "sizes"); - app.wait_for("sizes-input"); - retype(&mut app, "transfer-size", "4,7"); - retype(&mut app, "transfer-rate", "100"); - reads(&mut app, &["6 min 16 s"]); - app.capture("CMP-05"); - }); - - step("REF-01 a status found by code, name and words", || { - open_tool(&mut app, "http-status"); - for searched in ["418", "teapot", "trop de requêtes"] { - retype(&mut app, "reference-search", searched); - app.eventually("one row answers", |tree| tree.count("reference-row") == 1); - } - app.capture("REF-01"); - }); - - app.quit(); -} - -#[test] -fn recette_the_home() { - let profile = tempfile::tempdir().unwrap(); - let mut app = the_tools("39_recette_home", profile.path()); - - step("OUT-01 the home says what it holds", || { - reads(&mut app, &["32 utilitaires, tous hors ligne"]); - app.capture("OUT-01"); - }); - - step("OUT-02 a category found by its name, without its accents", || { - app.fill("tools-search", "generateur"); - for tool in ["json-generator", "identity", "lorem", "qr"] { - app.wait_for(&format!("tools-entry-{tool}")); - } - }); - - step("OUT-03 a reference found, opened by Enter", || { - app.press(Key::A, Modifiers::COMMAND); - app.type_text("418"); - app.wait_for("tools-reference-hit"); - reads(&mut app, &["teapot"]); - app.capture("OUT-03"); - app.press(Key::Enter, Modifiers::NONE); - app.wait_for("reference-search"); - app.click("tool-back"); - }); - - step("OUT-09 an example, then cleared", || { - open_tool(&mut app, "case"); - app.click("tool-sample"); - app.eventually("the field is filled", |tree| { - tree.find("case-input") - .and_then(egui::accesskit::Node::value) - .is_some_and(|it| !it.is_empty()) - }); - app.click("tool-clear"); - app.eventually("the field is empty", |tree| { - tree.find("case-input") - .and_then(egui::accesskit::Node::value) - .is_none_or(str::is_empty) - }); - }); - - step("OUT-10 what a tool worked out is kept as a note", || { - open_tool(&mut app, "hash"); - retype(&mut app, "hash-input", "DevNotes"); - app.click("tool-save-as-note"); - app.wait_for("save-as-note-what"); - app.capture("OUT-10-dialog"); - app.click("save-as-note-submit"); - app.wait_for("status-toast"); - app.capture("OUT-10-saved"); - }); - - step("OUT-07 three favourites over a relaunch", || { - for tool in ["case", "hash", "cron"] { - open_tool(&mut app, tool); - app.click("tool-favourite"); - } - app.click("tool-back"); - app.wait_for("tools-favourite-cron"); - }); - - let mut app = app.relaunch(); - app.fill("vault-passphrase", PASSPHRASE); - app.click("vault-submit"); - app.wait_for("area-tools"); - - step("OUT-07 they are still there, and go one by one", || { - for tool in ["case", "hash", "cron"] { - app.wait_for(&format!("tools-favourite-{tool}")); - } - app.capture("OUT-07"); - }); - - app.quit(); -} From fe67fd07f6839fb2b9b6aaa2586cb4084e4c1a79 Mon Sep 17 00:00:00 2001 From: Valentin Millet Date: Fri, 4 Dec 2026 10:50:04 +0100 Subject: [PATCH 2/2] A copied answer is copied again until it is the one shown --- e2e/src/sdk/tools.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/e2e/src/sdk/tools.rs b/e2e/src/sdk/tools.rs index 4fac11fd..194f70c2 100644 --- a/e2e/src/sdk/tools.rs +++ b/e2e/src/sdk/tools.rs @@ -114,9 +114,9 @@ impl Tools<'_> { /// An answer is copied as it should. pub fn expect_copied(&mut self, copied: Copied, says: &str) { match copied { - Copied::Shown(name) => self.expect_copied_as_shown(name, says), + Copied::Shown(name) => self.expect_copied_as_shown(name), Copied::Raw(name, raw) => { - self.expect_copied_as_shown(name, says); + self.expect_copied_as_shown(name); let named = format!(" {name},"); self.0.click_where("copy-raw", "the answer's « Raw »", |button| { said(button).contains(&named) @@ -244,12 +244,14 @@ impl Tools<'_> { } /// Copies an answer: every line of what is copied is on the screen. - fn expect_copied_as_shown(&mut self, name: &str, says: &str) { - self.copy(name); - let tree = self.0.tree(); - self.0 - .clipboard() - .expect_that(says, |held| !held.is_empty() && held.lines().all(|line| tree.mentions(line))); + /// Copied again while the clipboard holds another answer than the one shown: one still on + /// its way lands after the first click. + fn expect_copied_as_shown(&mut self, name: &str) { + let answered = |tree: &crate::driver::Tree| { + let held = clipboard::held(); + !held.is_empty() && held.lines().all(|line| tree.mentions(line)) + }; + self.0.click_until("the answer's copy", |app| Tools(app).copy(name), answered); } fn copy(&mut self, name: &str) {