use playwright_rs::{Error, PLAYWRIGHT_VERSION};
#[test]
fn test_browser_not_installed_error_type_exists() {
let error = Error::BrowserNotInstalled {
browser_name: "chromium".to_string(),
message: "Looks like Playwright Test or Playwright was just installed or updated."
.to_string(),
playwright_version: PLAYWRIGHT_VERSION.to_string(),
};
let error_message = error.to_string();
assert!(error_message.contains("chromium"));
assert!(error_message.contains("npx playwright"));
}
#[test]
fn test_browser_not_installed_includes_version() {
let error = Error::BrowserNotInstalled {
browser_name: "firefox".to_string(),
message: "Looks like Playwright Test or Playwright was just installed or updated."
.to_string(),
playwright_version: PLAYWRIGHT_VERSION.to_string(),
};
let error_message = error.to_string();
assert!(
error_message.contains(PLAYWRIGHT_VERSION),
"Error message should contain Playwright version {}",
PLAYWRIGHT_VERSION
);
}
#[test]
fn test_browser_not_installed_includes_install_command() {
let error = Error::BrowserNotInstalled {
browser_name: "webkit".to_string(),
message: "Looks like Playwright Test or Playwright was just installed or updated."
.to_string(),
playwright_version: PLAYWRIGHT_VERSION.to_string(),
};
let error_message = error.to_string();
let expected_command = format!("npx playwright@{} install", PLAYWRIGHT_VERSION);
assert!(
error_message.contains(&expected_command),
"Error message should contain install command: {}",
expected_command
);
}
#[test]
fn test_browser_not_installed_error_is_helpful() {
let error = Error::BrowserNotInstalled {
browser_name: "chromium".to_string(),
message: "Looks like Playwright Test or Playwright was just installed or updated."
.to_string(),
playwright_version: PLAYWRIGHT_VERSION.to_string(),
};
let error_message = error.to_string();
assert!(error_message.contains("chromium"));
assert!(error_message.contains("install") || error_message.contains("Install"));
assert!(error_message.contains("npx playwright"));
}
#[test]
fn test_browser_not_installed_different_browsers() {
let browsers = vec!["chromium", "firefox", "webkit"];
for browser in browsers {
let error = Error::BrowserNotInstalled {
browser_name: browser.to_string(),
message: format!("Browser '{}' is not installed", browser),
playwright_version: PLAYWRIGHT_VERSION.to_string(),
};
let error_message = error.to_string();
assert!(
error_message.contains(browser),
"Error for {} should mention the browser name",
browser
);
}
}