51 lines
2.2 KiB
Rust
51 lines
2.2 KiB
Rust
#[cfg(test)]
|
|
mod tests {
|
|
use std::fs;
|
|
|
|
#[test]
|
|
fn test_ssh_key_template_has_data_key_id_attribute() {
|
|
println!("🔧 Testing SSH Key Template Fix");
|
|
|
|
// Read the settings.html file
|
|
let settings_content = fs::read_to_string("src/views/dashboard/settings.html")
|
|
.expect("Failed to read settings.html");
|
|
|
|
// Check if the SSH key template has the data-key-id attribute
|
|
let has_template_section = settings_content.contains("id=\"sshKeyTemplate\"");
|
|
assert!(has_template_section, "SSH key template section not found");
|
|
|
|
// Check if the ssh-key-item div has data-key-id attribute
|
|
let lines: Vec<&str> = settings_content.lines().collect();
|
|
let mut found_template = false;
|
|
let mut found_data_key_id = false;
|
|
|
|
for (i, line) in lines.iter().enumerate() {
|
|
if line.contains("id=\"sshKeyTemplate\"") {
|
|
found_template = true;
|
|
// Check the next few lines for the ssh-key-item with data-key-id
|
|
for j in 1..=5 {
|
|
if i + j < lines.len() {
|
|
let next_line = lines[i + j];
|
|
if next_line.contains("ssh-key-item") && next_line.contains("data-key-id") {
|
|
found_data_key_id = true;
|
|
println!("✅ Found ssh-key-item with data-key-id attribute: {}", next_line.trim());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
assert!(found_template, "SSH key template not found");
|
|
assert!(found_data_key_id, "❌ SSH key template missing data-key-id attribute - this is the root cause of the button issues!");
|
|
|
|
println!("✅ SSH Key Template Fix Verified");
|
|
println!("📋 USER ACTION REQUIRED:");
|
|
println!(" 1. Refresh your browser (Ctrl+R or F5)");
|
|
println!(" 2. Go to Dashboard → Settings → SSH Keys");
|
|
println!(" 3. Create an SSH key (should work as before)");
|
|
println!(" 4. Test Set Default/Edit/Delete buttons");
|
|
println!(" 5. Check browser console - should now show valid key IDs");
|
|
}
|
|
} |