Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { isRunnableDevEnvironment } from 'vite';
import { defineConfig, isRunnableDevEnvironment as fromVitePlus } from 'vite-plus';

export default defineConfig({
// This fixture serves SSR middleware only; dependency scanning adds timing-dependent logs.
optimizeDeps: { noDiscovery: true },
server: { host: '127.0.0.1', port: 0 },
plugins: [
{
Expand Down
60 changes: 0 additions & 60 deletions crates/vp_migration/src/import_rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2878,26 +2878,6 @@ mod tests {
assert!(rewrite_imports_in_directory(temp.path()).unwrap().modified_files.is_empty());
}

#[test]
fn test_rewrite_import_content_vite() {
let vite_config = r#"import { defineConfig } from 'vite'

export default defineConfig({
plugins: [],
});"#;

let result = rewrite_import_content(vite_config, &SkipPackages::default()).unwrap();
assert!(result.updated);
assert_eq!(
result.content,
r#"import { defineConfig } from 'vite-plus'

export default defineConfig({
plugins: [],
});"#
);
}

#[test]
fn test_rewrite_import_content_vite_double_quotes() {
let vite_config = r#"import { defineConfig } from "vite";
Expand Down Expand Up @@ -5607,14 +5587,6 @@ const { defineConfig } = require('vite-plus');"#
// Reference Types Rewriting Tests
// ====================================

#[test]
fn test_rewrite_reference_types_vite_client() {
let content = r#"/// <reference types="vite/client" />"#;
let result = rewrite_import_content(content, &SkipPackages::default()).unwrap();
assert!(result.updated);
assert_eq!(result.content, r#"/// <reference types="vite-plus/client" />"#);
}

#[test]
fn test_rewrite_reference_types_vite_client_single_quotes() {
let content = r#"/// <reference types='vite/client' />"#;
Expand All @@ -5631,30 +5603,6 @@ const { defineConfig } = require('vite-plus');"#
assert_eq!(result.content, r#"/// <reference types="vite-plus" />"#);
}

#[test]
fn test_rewrite_reference_types_bare_vitest() {
let content = r#"/// <reference types="vitest" />"#;
let result = rewrite_import_content(content, &SkipPackages::default()).unwrap();
assert!(result.updated);
assert_eq!(result.content, r#"/// <reference types="vite-plus/test" />"#);
}

#[test]
fn test_rewrite_reference_types_vitest_globals() {
let content = r#"/// <reference types="vitest/globals" />"#;
let result = rewrite_import_content(content, &SkipPackages::default()).unwrap();
assert!(result.updated);
assert_eq!(result.content, r#"/// <reference types="vite-plus/test/globals" />"#);
}

#[test]
fn test_rewrite_reference_types_vitest_config() {
let content = r#"/// <reference types="vitest/config" />"#;
let result = rewrite_import_content(content, &SkipPackages::default()).unwrap();
assert!(result.updated);
assert_eq!(result.content, r#"/// <reference types="vite-plus" />"#);
}

#[test]
fn test_rewrite_reference_types_vitest_browser() {
let content = r#"/// <reference types="vitest/browser" />"#;
Expand All @@ -5680,14 +5628,6 @@ const { defineConfig } = require('vite-plus');"#
}
}

#[test]
fn test_rewrite_reference_types_vitest_scoped_browser_context() {
let content = r#"/// <reference types="@vitest/browser/context" />"#;
let result = rewrite_import_content(content, &SkipPackages::default()).unwrap();
assert!(result.updated);
assert_eq!(result.content, r#"/// <reference types="vite-plus/test/browser/context" />"#);
}

#[test]
fn test_rewrite_reference_types_vitest_scoped_browser_playwright() {
let content = r#"/// <reference types="@vitest/browser/providers/playwright" />"#;
Expand Down
20 changes: 12 additions & 8 deletions crates/vp_pm_cli/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ mod tests {
let temp_dir = TempDir::new().unwrap();
let target_file = temp_dir.path().join("test.txt");

server.mock(|when, then| {
let mock = server.mock(|when, then| {
when.method(GET).path("/server_error");
then.status(500).body("Internal Server Error");
});
Expand All @@ -1239,8 +1239,10 @@ mod tests {

// Should fail after retries
let result = client.download_file(&url, &target_file, None).await;
// println!("result: {:?}", result);
assert!(result.is_err(), "Expected download to fail with 500 after retries");

// Should try 3 times, 1 for first request, 2 for retries
mock.assert_hits(3);
}

#[tokio::test]
Expand Down Expand Up @@ -1409,7 +1411,6 @@ mod tests {
}

#[tokio::test]
#[ignore] // Flaky on musl/Alpine — temp file race condition
async fn test_verify_file_hash_sha1() {
use sha1::Sha1;
use sha2::Digest;
Expand All @@ -1422,6 +1423,8 @@ mod tests {
let content = b"Hello, World!";
let mut file = tokio::fs::File::create(&test_file).await.unwrap();
file.write_all(content).await.unwrap();
// Finish the background write before hashing through another file handle.
file.flush().await.unwrap();

// Calculate expected SHA1
let mut hasher = Sha1::new();
Expand All @@ -1430,12 +1433,12 @@ mod tests {

// Test successful verification
let result = verify_file_hash(&test_file, &expected_hash).await;
assert!(result.is_ok());
assert!(result.is_ok(), "{result:?}");

// Test failed verification
let wrong_hash = "sha1.0000000000000000000000000000000000000000";
let result = verify_file_hash(&test_file, wrong_hash).await;
assert!(result.is_err());
assert!(matches!(result, Err(Error::HashMismatch { .. })), "{result:?}");
}

#[tokio::test]
Expand Down Expand Up @@ -1470,7 +1473,6 @@ mod tests {
}

#[tokio::test]
#[ignore] // Flaky on musl/Alpine — temp file race condition
async fn test_verify_file_hash_sha224() {
use sha2::{Digest, Sha224};
use tokio::io::AsyncWriteExt;
Expand All @@ -1482,6 +1484,8 @@ mod tests {
let content = b"Test content for SHA224";
let mut file = tokio::fs::File::create(&test_file).await.unwrap();
file.write_all(content).await.unwrap();
// Finish the background write before hashing through another file handle.
file.flush().await.unwrap();

// Calculate expected SHA224
let mut hasher = Sha224::new();
Expand All @@ -1490,12 +1494,12 @@ mod tests {

// Test successful verification
let result = verify_file_hash(&test_file, &expected_hash).await;
assert!(result.is_ok());
assert!(result.is_ok(), "{result:?}");

// Test failed verification
let wrong_hash = "sha224.00000000000000000000000000000000000000000000000000000000";
let result = verify_file_hash(&test_file, wrong_hash).await;
assert!(result.is_err());
assert!(matches!(result, Err(Error::HashMismatch { .. })), "{result:?}");
}

#[tokio::test]
Expand Down
39 changes: 0 additions & 39 deletions crates/vp_pm_cli/src/resolution/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,6 @@ mod tests {
assert_eq!(command.args, vec!["link", "react"]);
}

#[test]
fn test_pnpm_link_directory() {
let resolution = resolve(
&pnpm("10.0.0"),
LinkArgs { package: Some("./packages/utils".to_string()), ..Default::default() },
);
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "pnpm");
assert_eq!(command.args, vec!["link", "./packages/utils"]);
}

#[test]
fn test_pnpm_link_absolute_directory() {
let resolution = resolve(
&pnpm("10.0.0"),
LinkArgs {
package: Some("/absolute/path/to/package".to_string()),
..Default::default()
},
);
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "pnpm");
assert_eq!(command.args, vec!["link", "/absolute/path/to/package"]);
}

#[test]
fn test_yarn_link_basic() {
let resolution = resolve(&yarn("4.0.0"), LinkArgs::default());
Expand All @@ -127,18 +100,6 @@ mod tests {
assert_eq!(command.args, vec!["link", "react"]);
}

#[test]
fn test_yarn_classic_link_package() {
let resolution = resolve(
&yarn("1.22.0"),
LinkArgs { package: Some("react".to_string()), ..Default::default() },
);
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "yarn");
assert_eq!(command.args, vec!["link", "react"]);
}

#[test]
fn test_npm_link_basic() {
let resolution = resolve(&npm("11.0.0"), LinkArgs::default());
Expand Down
9 changes: 0 additions & 9 deletions crates/vp_pm_cli/src/resolution/commands/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,4 @@ mod tests {
assert_eq!(command.program, "npm");
assert_eq!(command.args, vec!["ping"]);
}

#[test]
fn test_yarn_classic_ping_uses_npm() {
let resolution = resolve(&yarn("1.22.0"), PingArgs::default());
let command = expect_run(resolution.outcome);

assert_eq!(command.program, "npm");
assert_eq!(command.args, vec!["ping"]);
}
}
14 changes: 0 additions & 14 deletions crates/vp_pm_cli/src/resolution/commands/unlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,6 @@ mod tests {
assert_eq!(command.args, vec!["unlink", "react"]);
}

#[test]
fn test_yarn_classic_unlink_package() {
let command = expect_run(
resolve(
&yarn("1.22.0"),
UnlinkArgs { package: Some("react".to_string()), ..Default::default() },
)
.outcome,
);

assert_eq!(command.program, "yarn");
assert_eq!(command.args, vec!["unlink", "react"]);
}

#[test]
fn test_yarn_unlink_recursive() {
for version in ["3.0.0", "3.6.0", "4.18.0"] {
Expand Down
50 changes: 0 additions & 50 deletions crates/vp_setup/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ mod tests {
})
}

#[test]
fn test_cli_package_name_construction() {
let suffix = "darwin-arm64";
let name = format!("{PLATFORM_PACKAGE_SCOPE}/{CLI_PACKAGE_NAME_PREFIX}-{suffix}");
assert_eq!(name, "@voidzero-dev/vite-plus-cli-darwin-arm64");
}

#[test]
fn test_platform_package_accepts_supported_provenance_predicates() {
for predicate_type in SUPPORTED_PROVENANCE_PREDICATE_TYPES {
Expand Down Expand Up @@ -374,47 +367,4 @@ mod tests {
assert!(error.to_string().contains(TEST_PACKAGE_NAME));
assert!(error.to_string().contains(TEST_VERSION));
}

#[test]
fn test_all_platform_suffixes_match_published_cli_packages() {
// These are the actual published CLI package suffixes
// (from packages/cli/publish-native-addons.ts RUST_TARGETS keys)
let published_suffixes = [
"darwin-arm64",
"darwin-x64",
"linux-arm64-gnu",
"linux-arm64-musl",
"linux-x64-gnu",
"linux-x64-musl",
"win32-arm64-msvc",
"win32-x64-msvc",
];

let published_packages: Vec<String> = published_suffixes
.iter()
.map(|s| format!("{PLATFORM_PACKAGE_SCOPE}/{CLI_PACKAGE_NAME_PREFIX}-{s}"))
.collect();

// All known platform suffixes that detect_platform_suffix() can return
let detection_suffixes = [
"darwin-arm64",
"darwin-x64",
"linux-arm64-gnu",
"linux-x64-gnu",
"linux-arm64-musl",
"linux-x64-musl",
"win32-arm64-msvc",
"win32-x64-msvc",
];

for suffix in &detection_suffixes {
let package_name =
format!("{PLATFORM_PACKAGE_SCOPE}/{CLI_PACKAGE_NAME_PREFIX}-{suffix}");
assert!(
published_packages.contains(&package_name),
"Platform suffix '{suffix}' produces CLI package name '{package_name}' \
which does not match any published CLI package"
);
}
}
}
18 changes: 0 additions & 18 deletions crates/vp_static_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,24 +586,6 @@ mod tests {

// ── Config file resolution ──────────────────────────────────────────

#[test]
fn resolves_ts_config() {
let dir = TempDir::new().unwrap();
let dir_path = vt_path::AbsolutePathBuf::new(dir.path().to_path_buf()).unwrap();
std::fs::write(dir.path().join("vite.config.ts"), "export default { run: {} }").unwrap();
let result = resolve_static_config(&dir_path);
assert!(result.get("run").is_some());
}

#[test]
fn resolves_js_config() {
let dir = TempDir::new().unwrap();
let dir_path = vt_path::AbsolutePathBuf::new(dir.path().to_path_buf()).unwrap();
std::fs::write(dir.path().join("vite.config.js"), "export default { run: {} }").unwrap();
let result = resolve_static_config(&dir_path);
assert!(result.get("run").is_some());
}

#[test]
fn resolves_mts_config() {
let dir = TempDir::new().unwrap();
Expand Down
Loading