openpencil/crates/op-host-web/tests/ci_workflow.rs
2026-07-08 23:50:39 +08:00

220 lines
7.6 KiB
Rust

#[test]
fn rust_check_runs_canvaskit_widget_host_tests() {
let workflow = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../.github/workflows/rust-check.yml"
))
.expect("rust-check workflow is readable");
assert!(
workflow.contains("Run CanvasKit web host tests"),
"rust-check should name the CanvasKit web host test step"
);
assert!(
workflow.contains("cargo test -p op-host-web"),
"rust-check should run op-host-web tests explicitly"
);
assert!(
workflow.contains("--features canvaskit"),
"rust-check must enable the production CanvasKit web host feature"
);
}
#[test]
fn release_workflow_documents_current_canvaskit_bundle_path() {
let workflow = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../.github/workflows/rust-release.yml"
))
.expect("rust-release workflow is readable");
assert!(
workflow.contains("wasm-bundle-build.yml"),
"release workflow notes should point at the current CanvasKit bundle workflow"
);
assert!(
!workflow.contains("--features skia"),
"release workflow must not describe the retired skia wasm build path"
);
assert!(
!workflow.contains("EMSDK"),
"release workflow must not describe the retired EMSDK wasm build path"
);
}
#[test]
fn release_workflow_resolves_macos_signing_identity_from_keychain() {
let workflow = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../.github/workflows/rust-release.yml"
))
.expect("rust-release workflow is readable");
assert!(
workflow.contains("Resolve macOS signing identity"),
"release workflow should resolve the imported Developer ID identity before signing"
);
assert!(
workflow.contains("security find-identity -v -p codesigning"),
"release workflow should query the imported keychain identity instead of guessing it"
);
assert!(
!workflow.contains("Developer ID Application ($APPLE_TEAM_ID)"),
"release workflow must not hard-code an incomplete Developer ID identity"
);
}
#[test]
fn release_workflow_installs_nsis_on_windows_runner() {
let workflow = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../.github/workflows/rust-release.yml"
))
.expect("rust-release workflow is readable");
assert!(
workflow.contains("Install NSIS (windows)"),
"release workflow should install NSIS before invoking makensis"
);
assert!(
workflow.contains("choco install nsis"),
"release workflow should not assume makensis is preinstalled on windows-latest"
);
assert!(
workflow.contains("GITHUB_PATH") && workflow.contains("makensis.exe"),
"release workflow should add makensis.exe to PATH after installing NSIS"
);
}
#[test]
fn release_workflow_distinguishes_published_npm_packages_from_check_failures() {
let workflow = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../.github/workflows/rust-release.yml"
))
.expect("rust-release workflow is readable");
assert!(
workflow.contains("already published; skipping"),
"release workflow should skip npm packages that are already published"
);
assert!(
workflow.contains("E404") && workflow.contains("failed to check npm package"),
"release workflow should publish only on npm 404 and fail on other npm view errors"
);
}
#[test]
fn web_smoke_page_uses_current_canvaskit_bundle_command() {
let smoke = std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/smoke/step-1b.html"))
.expect("web smoke page is readable");
assert!(
smoke.contains("--features canvaskit"),
"web smoke page should show the current CanvasKit bundle build command"
);
assert!(
smoke.contains("mod.mount_ck('op')"),
"web smoke page should mount the production CanvasKit shell"
);
assert!(
!smoke.contains("mod.mount('op')"),
"web smoke page must not mount the default wasm stub"
);
assert!(
!smoke.contains("--features skia"),
"web smoke page must not point users at the retired skia wasm build"
);
assert!(
!smoke.contains("EMSDK"),
"web smoke page must not require the retired EMSDK setup"
);
}
#[test]
fn web_integration_notes_avoid_legacy_ambiguous_markers() {
let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let files = [
"Cargo.toml",
"src/dom_io.rs",
"src/file_actions.rs",
"src/iconify_web.rs",
"src/lib.rs",
"src/live_sync.rs",
"src/raf_pump.rs",
"src/web_ai_transport.rs",
"src/web_chat.rs",
"src/web_clipboard.rs",
"src/web_fonts.rs",
];
for file in files {
let text = std::fs::read_to_string(manifest_dir.join(file))
.unwrap_or_else(|err| panic!("{file} is readable: {err}"));
assert!(
!text.contains("UNVERIFIED in-browser"),
"{file} should name the concrete smoke/daemon boundary instead of a blanket UNVERIFIED marker"
);
assert!(
!text.contains("EMSDK"),
"{file} should describe the current CanvasKit/web-sys boundary instead of the retired EMSDK path"
);
}
}
#[test]
fn browser_smoke_script_and_ci_cover_canvas_and_daemon_paths() {
let repo = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let script = std::fs::read_to_string(repo.join("tools/check-web-browser-smoke.sh"))
.expect("browser smoke script is readable");
let workflow = std::fs::read_to_string(repo.join(".github/workflows/wasm-bundle-build.yml"))
.expect("wasm bundle workflow is readable");
assert!(
script.contains("--dump-dom"),
"browser smoke should drive a real headless browser, not only curl"
);
assert!(
script.contains("/smoke/step-1b.html"),
"browser smoke should cover the pure CanvasKit mount harness"
);
assert!(
script.contains("/api/mcp/server"),
"browser smoke should cover the daemon health path"
);
assert!(
script.contains("data-op-smoke=\"ok\""),
"browser smoke should assert the DOM success marker written after mount"
);
assert!(
workflow.contains("tools/check-web-browser-smoke.sh"),
"bundle workflow should run the browser smoke after building the bundle"
);
}
#[test]
fn web_rust_publish_has_docker_and_start_script_entrypoints() {
let repo = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let dockerfile =
std::fs::read_to_string(repo.join("Dockerfile.web-rust")).expect("Dockerfile readable");
let start_script = std::fs::read_to_string(repo.join("scripts/start-web-rust.sh"))
.expect("web rust start script is readable");
assert!(
dockerfile.contains("op-host-web-server --serve-web"),
"web Rust Docker image should publish through the headless serve-web daemon"
);
assert!(
start_script.contains("tools/check-wasm-bundle.sh"),
"start script should build or verify the deployable CanvasKit bundle"
);
assert!(
start_script.contains("op-host-web-server") && start_script.contains("--serve-web"),
"start script should publish through op-host-web-server --serve-web"
);
assert!(
start_script.contains("OPENPENCIL_WEB_BUNDLE_DIR"),
"start script should point the daemon at the built web bundle explicitly"
);
}