nigig-org/crates/apps/spreadsheet/spreadsheet-ui/tests/ui.rs
andodeki 456cfa5a68
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
nigig-map / test (push) Has been cancelled
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
repo hygiene / hygiene (push) Has been cancelled
fix: use re-exported makepad-test from makepad-widgets
Remove direct dependencies on makepad-test and use the re-exported
version from makepad-widgets instead. This avoids path dependency
issues and follows the correct pattern for using Makepad crates.

Changes:
- Add 'test' feature to makepad-widgets dependencies
- Remove direct makepad-test dependencies
- Update imports to use makepad_widgets::makepad_test

Affected crates:
- crates/apps/map
- crates/apps/pdf/pdf-makepad
- crates/apps/spreadsheet/spreadsheet-ui
2026-07-31 19:49:54 +00:00

56 lines
2.1 KiB
Rust

use makepad_widgets::makepad_test::{run_with_config, Selector, TestApp, TestConfig};
fn run_ui_test(test_name: &str, body: impl FnOnce(TestApp)) {
let mut config = TestConfig::current_package(
env!("CARGO_MANIFEST_DIR"),
env!("CARGO_PKG_NAME"),
format!("ui::{test_name}"),
)
.expect("makepad test configuration");
// StudioHub launches the package through a child shell. Explicitly pass
// the isolated Cargo path so the child can find the same toolchain as the
// outer `cargo test` process.
if let Ok(path) = std::env::var("PATH") {
config.env.insert("PATH".into(), path.clone());
for directory in path.split(':') {
let cargo = std::path::Path::new(directory).join("cargo");
if cargo.is_file() {
config
.env
.insert("CARGO".into(), cargo.to_string_lossy().into_owned());
break;
}
}
}
for key in ["CARGO_HOME", "RUSTUP_HOME", "RUSTC"] {
if let Ok(value) = std::env::var(key) {
config.env.insert(key.into(), value);
}
}
// The current Makepad Linux branch has an incomplete `MAKEPAD=headless`
// cfg path. Let Linux compile its native backend; the Studio hub still
// drives the app through the test protocol.
config.env.remove("MAKEPAD");
run_with_config(config, body).expect("Makepad app failed to start or test failed");
}
#[test]
fn spreadsheet_workspace_smoke() {
run_ui_test("spreadsheet_workspace_smoke", |app: TestApp| {
app.locator(Selector::id("formula_input")).wait_visible();
app.locator(Selector::id("grid")).wait_visible();
app.locator(Selector::id("add_sheet_btn")).wait_visible();
});
}
#[test]
fn spreadsheet_workspace_can_add_sheet() {
run_ui_test("spreadsheet_workspace_can_add_sheet", |app: TestApp| {
app.locator(Selector::id("add_sheet_btn"))
.wait_visible()
.click();
app.locator(Selector::id("sheet_status"))
.wait_text("Active Sheet: Sheet4 | AutoCalc On");
});
}