v0.2.12-pre.006
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-solprices-desk/tests/desktop_contract.rs
|
||||
// version: 5
|
||||
// version: 6
|
||||
|
||||
//! Desktop scaffold, shared-template and Config packaging contract audits for SOL Prices Desk `0.2.12`.
|
||||
|
||||
@@ -192,29 +192,21 @@ fn pre_002_fix_001_reuses_the_common_ksp_desktop_template() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_005_market_price_runtime_adds_single_refresh_without_many_or_all_controls() {
|
||||
fn pre_005_market_price_runtime_preserves_single_refresh_contract() {
|
||||
let root = app_root();
|
||||
let manifest = read_text(root.join("Cargo.toml").as_path());
|
||||
assert!(manifest.contains(r#"ksp-offchain-transport-lib = { path = "../ksp-offchain-transport-lib" }"#));
|
||||
assert!(!manifest.contains("reqwest"));
|
||||
let lib_rs = read_text(root.join("src/lib.rs").as_path());
|
||||
assert!(lib_rs.contains("mod market_price_runtime;"));
|
||||
assert!(lib_rs.contains("MarketPriceProviderRowDto"));
|
||||
assert!(lib_rs.contains("MarketPriceRuntime"));
|
||||
let runtime_rs = read_text(root.join("src/market_price_runtime.rs").as_path());
|
||||
assert!(runtime_rs.contains("pub(crate) async fn refresh_one"));
|
||||
assert!(runtime_rs.contains("service().refresh(&provider_id).await"));
|
||||
assert!(runtime_rs.contains("self.set_loading(&provider_id, true)"));
|
||||
assert!(runtime_rs.contains("self.begin_refresh(provider_ids.as_slice())"));
|
||||
assert!(runtime_rs.contains("apply_outcome_to_state"));
|
||||
let tauri_rs = read_text(root.join("src/tauri.rs").as_path());
|
||||
assert!(tauri_rs.contains("refresh_market_price"));
|
||||
for forbidden in ["refresh_market_prices", "refresh_all_market_prices"] {
|
||||
assert!(!tauri_rs.contains(forbidden));
|
||||
}
|
||||
let main_html = read_text(root.join("frontend/main.html").as_path());
|
||||
assert!(main_html.contains(r#"id="marketPriceTable""#));
|
||||
assert!(main_html.contains(">Action</th>"));
|
||||
assert!(main_html.contains("rafraîchie explicitement"));
|
||||
let main_typescript = read_text(root.join("frontend/ts/main.ts").as_path());
|
||||
assert!(main_typescript.contains(r#""refresh_market_price""#));
|
||||
assert!(main_typescript.contains("SOL Prices Desk market-price refresh control clicked"));
|
||||
@@ -224,3 +216,33 @@ fn pre_005_market_price_runtime_adds_single_refresh_without_many_or_all_controls
|
||||
assert!(!main_typescript.contains("parseFloat("));
|
||||
assert!(!main_typescript.contains("Number(provider.price"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_006_market_price_runtime_adds_selected_and_global_refresh_without_polling() {
|
||||
let root = app_root();
|
||||
let lib_rs = read_text(root.join("src/lib.rs").as_path());
|
||||
assert!(lib_rs.contains("MarketPriceRefreshManyRequestDto"));
|
||||
assert!(lib_rs.contains("MarketPriceRefreshResultDto"));
|
||||
let runtime_rs = read_text(root.join("src/market_price_runtime.rs").as_path());
|
||||
assert!(runtime_rs.contains("pub(crate) async fn refresh_many"));
|
||||
assert!(runtime_rs.contains("service().refresh_many(provider_ids.as_slice()).await"));
|
||||
assert!(runtime_rs.contains("pub(crate) async fn refresh_all"));
|
||||
assert!(runtime_rs.contains("service().refresh_all().await"));
|
||||
assert!(runtime_rs.contains("begin_refresh_in_state"));
|
||||
let tauri_rs = read_text(root.join("src/tauri.rs").as_path());
|
||||
assert!(tauri_rs.contains("refresh_market_prices"));
|
||||
assert!(tauri_rs.contains("refresh_all_market_prices"));
|
||||
let main_html = read_text(root.join("frontend/main.html").as_path());
|
||||
assert!(main_html.contains(r#"id="refreshSelectedButton""#));
|
||||
assert!(main_html.contains(r#"id="refreshAllButton""#));
|
||||
assert!(main_html.contains(r#"id="selectedProviderCount""#));
|
||||
let main_typescript = read_text(root.join("frontend/ts/main.ts").as_path());
|
||||
assert!(main_typescript.contains(r#""refresh_market_prices""#));
|
||||
assert!(main_typescript.contains(r#""refresh_all_market_prices""#));
|
||||
assert!(main_typescript.contains("selectedProviderIdsInRowOrder"));
|
||||
assert!(main_typescript.contains("SOL Prices Desk selected market-price refresh control clicked"));
|
||||
assert!(main_typescript.contains("SOL Prices Desk global market-price refresh control clicked"));
|
||||
for forbidden in ["setInterval(", "setTimeout(", "requestAnimationFrame("] {
|
||||
assert!(!main_typescript.contains(forbidden), "pre.006 must not add consumer scheduling: {forbidden}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-solprices-desk/tests/desktop_security.rs
|
||||
// version: 5
|
||||
// version: 6
|
||||
|
||||
//! Security, ownership and frontend instrumentation canaries for SOL Prices Desk.
|
||||
|
||||
@@ -69,7 +69,7 @@ fn pre_002_frontend_has_no_network_persistence_or_native_dialog_surface() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_005_tauri_commands_remain_centralized_and_only_single_refresh_is_present() {
|
||||
fn pre_005_tauri_commands_remain_centralized_and_single_refresh_is_preserved() {
|
||||
let root = app_root();
|
||||
let mut rust_files = std::vec::Vec::new();
|
||||
collect_files(root.join("src").as_path(), "rs", &mut rust_files);
|
||||
@@ -85,10 +85,8 @@ fn pre_005_tauri_commands_remain_centralized_and_only_single_refresh_is_present(
|
||||
if path.file_name().and_then(std::ffi::OsStr::to_str) != std::option::Option::Some("tauri.rs") {
|
||||
assert!(!source.contains("tauri::generate_handler!"), "{} registers Tauri handlers outside tauri.rs", path.display());
|
||||
}
|
||||
assert!(!source.contains("refresh_market_prices"), "{} advances multi-refresh before pre.006", path.display());
|
||||
assert!(!source.contains("refresh_all_market_prices"), "{} advances global refresh before pre.006", path.display());
|
||||
}
|
||||
assert_eq!(command_count, 5);
|
||||
assert!(command_count >= 5);
|
||||
let tauri = read_text(root.join("src/tauri.rs").as_path());
|
||||
assert!(tauri.contains("refresh_market_price"));
|
||||
}
|
||||
@@ -114,3 +112,33 @@ fn pre_005_frontend_refresh_interactions_are_logged_without_business_values() {
|
||||
assert!(!main.contains(forbidden), "main frontend logging must not serialize business/secret values: {forbidden}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_006_selected_and_global_refresh_commands_are_centralized_and_bounded() {
|
||||
let root = app_root();
|
||||
let tauri = read_text(root.join("src/tauri.rs").as_path());
|
||||
assert_eq!(tauri.matches("#[tauri::command]").count(), 7);
|
||||
assert!(tauri.contains("refresh_market_price"));
|
||||
assert!(tauri.contains("refresh_market_prices"));
|
||||
assert!(tauri.contains("refresh_all_market_prices"));
|
||||
let runtime = read_text(root.join("src/market_price_runtime.rs").as_path());
|
||||
assert!(runtime.contains("ERROR_CODE_MARKET_PRICE_REFRESH_CONFLICT"));
|
||||
assert!(runtime.contains("ERROR_CODE_MARKET_PRICE_SELECTION_INVALID"));
|
||||
assert!(runtime.contains("refresh_many(provider_ids.as_slice()).await"));
|
||||
assert!(runtime.contains("refresh_all().await"));
|
||||
assert!(!runtime.contains("tokio::time::sleep"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_006_frontend_batch_controls_are_logged_without_price_or_provider_payloads() {
|
||||
let root = app_root();
|
||||
let main = read_text(root.join("frontend/ts/main.ts").as_path());
|
||||
assert!(main.contains("SOL Prices Desk market-price selection control changed"));
|
||||
assert!(main.contains("SOL Prices Desk selected market-price refresh control clicked"));
|
||||
assert!(main.contains("SOL Prices Desk global market-price refresh control clicked"));
|
||||
assert!(main.contains("requestedCount: result.requestedCount"));
|
||||
assert!(main.contains("refreshedCount: result.refreshedCount"));
|
||||
for forbidden in ["JSON.stringify(result)", "JSON.stringify(currentMarketPriceRows)", "price: provider.price", "apiKey", "authorization"] {
|
||||
assert!(!main.contains(forbidden), "batch frontend logging must not serialize price/provider/secret values: {forbidden}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user