chore: source formatting and spec allignment
This commit is contained in:
@@ -8,12 +8,12 @@
|
||||
//! be tested via `cargo test`. The full smoke test is launching the binary:
|
||||
//! cargo run -p bds-ui
|
||||
|
||||
use std::path::PathBuf;
|
||||
use bds_core::i18n::UiLocale;
|
||||
use bds_ui::app::Message;
|
||||
use bds_ui::state::navigation::{PanelTab, SidebarView};
|
||||
use bds_ui::state::tabs::{Tab, TabType};
|
||||
use bds_ui::state::toast::ToastLevel;
|
||||
use std::path::PathBuf;
|
||||
|
||||
// ── Smoke: Message enum is well-formed ──
|
||||
|
||||
@@ -53,7 +53,10 @@ fn new_message_variants_constructable() {
|
||||
|
||||
// Project
|
||||
let _switch = Message::SwitchProject("id".into());
|
||||
let _create = Message::CreateProject { name: "X".into(), data_path: None };
|
||||
let _create = Message::CreateProject {
|
||||
name: "X".into(),
|
||||
data_path: None,
|
||||
};
|
||||
let _delete = Message::DeleteProject("id".into());
|
||||
|
||||
// Dialogs
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
//! Validates toast system, menu sync logic, dialog i18n,
|
||||
//! and keyboard shortcut coverage.
|
||||
|
||||
use bds_core::i18n::{translate, UiLocale};
|
||||
use bds_ui::state::toast::{Toast, ToastLevel};
|
||||
use bds_core::i18n::{UiLocale, translate};
|
||||
use bds_ui::platform::menu::MenuAction;
|
||||
use bds_ui::state::toast::{Toast, ToastLevel};
|
||||
|
||||
// ── Toast system ──
|
||||
|
||||
@@ -89,10 +89,7 @@ fn menu_actions_that_need_tab() {
|
||||
|
||||
#[test]
|
||||
fn menu_actions_gated_by_offline() {
|
||||
let online_only = [
|
||||
MenuAction::FillMissingTranslations,
|
||||
MenuAction::UploadSite,
|
||||
];
|
||||
let online_only = [MenuAction::FillMissingTranslations, MenuAction::UploadSite];
|
||||
for action in &online_only {
|
||||
let key = action.i18n_key();
|
||||
let label = translate(UiLocale::En, key);
|
||||
@@ -105,7 +102,11 @@ fn menu_actions_gated_by_offline() {
|
||||
|
||||
#[test]
|
||||
fn dialog_keys_exist_in_all_locales() {
|
||||
let keys = ["dialog.selectFolder", "dialog.importMedia", "dialog.imageFilter"];
|
||||
let keys = [
|
||||
"dialog.selectFolder",
|
||||
"dialog.importMedia",
|
||||
"dialog.imageFilter",
|
||||
];
|
||||
for locale in UiLocale::all() {
|
||||
for key in &keys {
|
||||
let label = translate(*locale, key);
|
||||
@@ -120,27 +121,31 @@ fn dialog_keys_exist_in_all_locales() {
|
||||
fn accelerator_actions_match_spec() {
|
||||
// M2 spec: these actions must have keyboard shortcuts
|
||||
let accelerated = [
|
||||
MenuAction::NewPost, // Cmd+N
|
||||
MenuAction::ImportMedia, // Cmd+I
|
||||
MenuAction::Save, // Cmd+S
|
||||
MenuAction::Find, // Cmd+F
|
||||
MenuAction::Replace, // Cmd+H
|
||||
MenuAction::NewPost, // Cmd+N
|
||||
MenuAction::ImportMedia, // Cmd+I
|
||||
MenuAction::Save, // Cmd+S
|
||||
MenuAction::Find, // Cmd+F
|
||||
MenuAction::Replace, // Cmd+H
|
||||
MenuAction::EditPreferences, // Cmd+,
|
||||
MenuAction::ViewPosts, // Cmd+1
|
||||
MenuAction::ViewMedia, // Cmd+2
|
||||
MenuAction::ToggleSidebar, // Cmd+B
|
||||
MenuAction::TogglePanel, // Cmd+J
|
||||
MenuAction::ViewPosts, // Cmd+1
|
||||
MenuAction::ViewMedia, // Cmd+2
|
||||
MenuAction::ToggleSidebar, // Cmd+B
|
||||
MenuAction::TogglePanel, // Cmd+J
|
||||
MenuAction::PublishSelected, // Cmd+Shift+P
|
||||
MenuAction::PreviewPost, // Cmd+Shift+V
|
||||
MenuAction::PreviewPost, // Cmd+Shift+V
|
||||
MenuAction::GenerateSitemap, // Cmd+R
|
||||
MenuAction::ValidateSite, // Cmd+Shift+L
|
||||
MenuAction::UploadSite, // Cmd+Shift+U
|
||||
MenuAction::ValidateSite, // Cmd+Shift+L
|
||||
MenuAction::UploadSite, // Cmd+Shift+U
|
||||
];
|
||||
// All must be valid MenuAction variants with i18n keys
|
||||
for action in &accelerated {
|
||||
assert!(!action.i18n_key().is_empty());
|
||||
}
|
||||
assert_eq!(accelerated.len(), 15, "M2 spec has 15 accelerator-bound actions");
|
||||
assert_eq!(
|
||||
accelerated.len(),
|
||||
15,
|
||||
"M2 spec has 15 accelerator-bound actions"
|
||||
);
|
||||
}
|
||||
|
||||
// ── Toast i18n keys ──
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! Validates: all MenuAction variants registered, no collisions,
|
||||
//! bidirectional lookup, and i18n keys resolve in every locale.
|
||||
|
||||
use bds_core::i18n::{translate, UiLocale};
|
||||
use bds_core::i18n::{UiLocale, translate};
|
||||
use bds_ui::platform::menu::MenuAction;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -19,12 +19,8 @@ fn create_and_activate_default_project() {
|
||||
let (db, dir) = setup();
|
||||
let data_path = dir.path().join("my-blog");
|
||||
|
||||
let p = project::create_project(
|
||||
db.conn(),
|
||||
"My Blog",
|
||||
Some(data_path.to_str().unwrap()),
|
||||
)
|
||||
.unwrap();
|
||||
let p =
|
||||
project::create_project(db.conn(), "My Blog", Some(data_path.to_str().unwrap())).unwrap();
|
||||
|
||||
assert_eq!(p.name, "My Blog");
|
||||
assert_eq!(p.slug, "my-blog");
|
||||
@@ -103,10 +99,9 @@ fn default_meta_files_written() {
|
||||
let p_path = dir.path().join("meta-test");
|
||||
project::create_project(db.conn(), "Meta Test", Some(p_path.to_str().unwrap())).unwrap();
|
||||
|
||||
let project_json: serde_json::Value = serde_json::from_str(
|
||||
&std::fs::read_to_string(p_path.join("meta/project.json")).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let project_json: serde_json::Value =
|
||||
serde_json::from_str(&std::fs::read_to_string(p_path.join("meta/project.json")).unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(project_json["name"], "Meta Test");
|
||||
assert_eq!(project_json["maxPostsPerPage"], 50);
|
||||
|
||||
@@ -116,9 +111,8 @@ fn default_meta_files_written() {
|
||||
.unwrap();
|
||||
assert_eq!(categories, vec!["article", "aside", "page", "picture"]);
|
||||
|
||||
let tags: Vec<String> = serde_json::from_str(
|
||||
&std::fs::read_to_string(p_path.join("meta/tags.json")).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let tags: Vec<String> =
|
||||
serde_json::from_str(&std::fs::read_to_string(p_path.join("meta/tags.json")).unwrap())
|
||||
.unwrap();
|
||||
assert!(tags.is_empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user