mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 13:35:42 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -111,17 +111,6 @@ fn ensure_desktop_dependencies() -> Result<()> {
|
||||
install_desktop_dependencies()
|
||||
}
|
||||
|
||||
pub fn typecheck_desktop() -> Result<()> {
|
||||
run_command(
|
||||
&["pnpm", "typecheck"],
|
||||
RunOptions {
|
||||
cwd: DESKTOP_DIR.as_path(),
|
||||
..RunOptions::default()
|
||||
},
|
||||
)
|
||||
.map(drop)
|
||||
}
|
||||
|
||||
pub fn development_version(now: SystemTime) -> String {
|
||||
let seconds = now
|
||||
.duration_since(UNIX_EPOCH)
|
||||
@@ -1135,215 +1124,3 @@ fn codesign_ad_hoc(app_bundle: &Path) -> Result<()> {
|
||||
String::from_utf8_lossy(&output.stderr).trim_end()
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn strips_no_sandbox_only_by_container_policy() {
|
||||
let args = electron_args(&["--flag".to_owned()]);
|
||||
if cfg!(target_os = "linux")
|
||||
&& Path::new("/.dockerenv").exists()
|
||||
&& env::var("FLUXER_ELECTRON_NO_SANDBOX").as_deref() != Ok("0")
|
||||
{
|
||||
assert_eq!(args[0], "--no-sandbox");
|
||||
}
|
||||
assert!(args.contains(&"--flag".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disclaimed_electron_command_re_execs_through_the_launcher() {
|
||||
let command = disclaimed_electron_command(
|
||||
Path::new("/tmp/fluxer-dev"),
|
||||
Path::new("/tmp/Electron.app/Contents/MacOS/Electron"),
|
||||
);
|
||||
assert_eq!(
|
||||
command,
|
||||
vec![
|
||||
"/tmp/fluxer-dev",
|
||||
"desktop",
|
||||
"exec-disclaimed",
|
||||
"/tmp/Electron.app/Contents/MacOS/Electron",
|
||||
"."
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dev_electron_paths_point_inside_the_dev_bundle() {
|
||||
assert!(dev_electron_binary_path().ends_with(
|
||||
"fluxer_desktop/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron"
|
||||
));
|
||||
assert!(dev_electron_info_plist_path().ends_with(
|
||||
"fluxer_desktop/node_modules/electron/dist/Electron.app/Contents/Info.plist"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dev_electron_usage_descriptions_include_audio_capture() {
|
||||
assert!(
|
||||
MACOS_DEV_ELECTRON_USAGE_DESCRIPTIONS
|
||||
.iter()
|
||||
.any(|(key, _)| *key == "NSAudioCaptureUsageDescription")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn development_version_is_a_calver_electron_builder_accepts() {
|
||||
let at = |seconds: u64| development_version(UNIX_EPOCH + Duration::from_secs(seconds));
|
||||
assert_eq!(at(1_791_039_600), "2026.1003.150000");
|
||||
assert_eq!(at(1_767_225_605), "2026.101.5");
|
||||
assert_eq!(at(1_798_761_599), "2026.1231.235959");
|
||||
assert_eq!(at(1_709_208_000), "2024.229.120000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_the_developer_id_identity_and_skips_other_certificates() {
|
||||
let output = r#" 1) D9E17CA1546F517C814DFA8719A4FED295D7B019 "Apple Development: Someone (TT9JK7QNP2)"
|
||||
2) AA2A51260E57959F00CF6B117CEA2757748756FA "Developer ID Application: Fluxer Platform AB (3G5837T29K)"
|
||||
2 valid identities found"#;
|
||||
assert_eq!(
|
||||
parse_developer_id_identity(output).as_deref(),
|
||||
Some("Fluxer Platform AB (3G5837T29K)")
|
||||
);
|
||||
assert_eq!(
|
||||
parse_developer_id_identity(" 0 valid identities found"),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn electron_builder_packages_a_development_dir_for_the_host_without_notarizing() {
|
||||
let args = electron_builder_args(
|
||||
Path::new("/tmp/out"),
|
||||
"arm64",
|
||||
&MacSigning::DeveloperId("Fluxer Platform AB (3G5837T29K)".to_owned()),
|
||||
&[],
|
||||
);
|
||||
assert!(args.contains(&"--dir".to_owned()));
|
||||
assert!(args.contains(&"-c.mac.notarize=false".to_owned()));
|
||||
assert!(args.contains(&"-c.directories.output=/tmp/out".to_owned()));
|
||||
assert!(args.contains(&"--arm64".to_owned()));
|
||||
assert!(
|
||||
!args
|
||||
.iter()
|
||||
.any(|arg| arg.starts_with("-c.mac.sign.identity"))
|
||||
);
|
||||
let ad_hoc = electron_builder_args(Path::new("/tmp/out"), "x64", &MacSigning::AdHoc, &[]);
|
||||
assert!(ad_hoc.contains(&"-c.mac.sign.identity=-".to_owned()));
|
||||
assert!(ad_hoc.contains(&"--x64".to_owned()));
|
||||
let linux = electron_builder_args(
|
||||
Path::new("/tmp/out"),
|
||||
"x64",
|
||||
&MacSigning::AdHoc,
|
||||
&["--linux".to_owned()],
|
||||
);
|
||||
assert_eq!(linux.iter().filter(|arg| *arg == "--linux").count(), 1);
|
||||
assert!(!linux.contains(&"--mac".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_a_development_app_that_claims_the_production_scheme() {
|
||||
assert!(
|
||||
verify_url_schemes(
|
||||
r#"[{"CFBundleURLName":"app.fluxer.development","CFBundleURLSchemes":["fluxer-development"]}]"#
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
verify_url_schemes(r#"[{"CFBundleURLSchemes":["fluxer-development","Fluxer"]}]"#)
|
||||
.is_err()
|
||||
);
|
||||
assert!(verify_url_schemes(r#"[{"CFBundleURLSchemes":["fluxer"]}]"#).is_err());
|
||||
assert!(verify_url_schemes("[]").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_info_must_match_the_renderer_delivery() {
|
||||
let info = |channel: &str, offline: bool, modules: bool| {
|
||||
format!(
|
||||
r#"{{"buildVersion":"2026.1003.150000","releaseChannel":"development","buildChannel":"{channel}","offlineBuild":{offline},"modulesEnabled":{modules}}}"#
|
||||
)
|
||||
};
|
||||
let check = |raw: String, version: &str, delivery| {
|
||||
verify_development_build_info(&raw, version, delivery).is_ok()
|
||||
};
|
||||
let version = "2026.1003.150000";
|
||||
assert!(check(
|
||||
info("development", true, false),
|
||||
version,
|
||||
RendererDelivery::Offline
|
||||
));
|
||||
assert!(check(
|
||||
info("development", false, true),
|
||||
version,
|
||||
RendererDelivery::Modules
|
||||
));
|
||||
assert!(!check(
|
||||
info("canary", false, true),
|
||||
version,
|
||||
RendererDelivery::Modules
|
||||
));
|
||||
assert!(!check(
|
||||
info("development", true, false),
|
||||
version,
|
||||
RendererDelivery::Modules
|
||||
));
|
||||
assert!(!check(
|
||||
info("development", false, true),
|
||||
version,
|
||||
RendererDelivery::Offline
|
||||
));
|
||||
assert!(!check(
|
||||
info("development", true, true),
|
||||
version,
|
||||
RendererDelivery::Modules
|
||||
));
|
||||
assert!(!check(
|
||||
info("development", false, true),
|
||||
"2026.1003.150001",
|
||||
RendererDelivery::Modules
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn matches_only_the_exact_main_executable_of_the_installed_app() {
|
||||
let ps = " 501 /Applications/Fluxer Development.app/Contents/MacOS/Fluxer Development\n\
|
||||
502 /Applications/Fluxer Development.app/Contents/Frameworks/Fluxer Development Helper.app/Contents/MacOS/Fluxer Development Helper\n\
|
||||
503 /Applications/Fluxer Canary.app/Contents/MacOS/Fluxer Canary\n\
|
||||
504 /tmp/copy/Fluxer Development.app/Contents/MacOS/Fluxer Development\n";
|
||||
assert_eq!(
|
||||
parse_pids_for_executable(
|
||||
ps,
|
||||
"/Applications/Fluxer Development.app/Contents/MacOS/Fluxer Development"
|
||||
),
|
||||
vec![501]
|
||||
);
|
||||
assert!(
|
||||
parse_pids_for_executable(ps, "/Applications/Fluxer.app/Contents/MacOS/Fluxer")
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installs_under_the_development_bundle_name_only() {
|
||||
let app = installed_app_path(Path::new(DEFAULT_INSTALL_DIR));
|
||||
assert_eq!(app, Path::new("/Applications/Fluxer Development.app"));
|
||||
assert_eq!(
|
||||
app_executable_path(&app),
|
||||
Path::new("/Applications/Fluxer Development.app/Contents/MacOS/Fluxer Development")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renderer_tree_must_be_complete_and_free_of_service_workers() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
assert!(verify_renderer_tree(dir.path()).is_err());
|
||||
fs::write(dir.path().join("index.html"), "<!doctype html>").unwrap();
|
||||
fs::create_dir(dir.path().join("assets")).unwrap();
|
||||
assert!(verify_renderer_tree(dir.path()).is_ok());
|
||||
fs::write(dir.path().join("sw.js"), "").unwrap();
|
||||
assert!(verify_renderer_tree(dir.path()).is_err());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user