make aws credentials editable and refactor to hold name and id

This commit is contained in:
jfmonty2 committed 2026-11-20 06:14:34 -05:00
1 parent dbcf72fa38
commit 21efa29fdd
9 files changed
+289 -184

No files matched your search

+49 -2
View File
@@ -89,6 +89,7 @@ fn main() {
mod tests {
use gpui_kit::{AnyWindowHandle, TestAppContext};
use gpui_kit::test::TestWindowExt;
use uuid::Uuid;
use super::*;
use crate::credentials::AwsCredential;
use crate::test_data::{TEST_PASSPHRASE, TestEnv};
@@ -259,11 +260,13 @@ mod tests {
fn test_credentials_tabs(cx: &mut TestAppContext) {
let env = TestEnv::new().unwrap();
let cred = AwsCredential {
id: Uuid::new_v4(),
name: "work".into(),
access_key_id: "AKIAEXAMPLE".into(),
secret_access_key: "EXAMPLESECRET".into(),
is_default: false,
};
env.db().unwrap().save_aws_credential("work", &cred).unwrap();
env.db().unwrap().save_aws_credential(&cred).unwrap();
let window = open_app(&env, cx);
fill(window, "passphrase", TEST_PASSPHRASE, cx);
click(window, "submit", cx);
@@ -328,11 +331,13 @@ mod tests {
fn test_add_aws_credential_duplicate_name(cx: &mut TestAppContext) {
let env = TestEnv::new().unwrap();
let cred = AwsCredential {
id: Uuid::new_v4(),
name: "work".into(),
access_key_id: "AKIAEXAMPLE".into(),
secret_access_key: "EXAMPLESECRET".into(),
is_default: false,
};
env.db().unwrap().save_aws_credential("work", &cred).unwrap();
env.db().unwrap().save_aws_credential(&cred).unwrap();
let window = open_app(&env, cx);
fill(window, "passphrase", TEST_PASSPHRASE, cx);
click(window, "submit", cx);
@@ -354,4 +359,46 @@ mod tests {
});
assert_eq!(saved.access_key_id, "AKIAEXAMPLE");
}
#[gpui_kit::test]
fn test_edit_aws_credential(cx: &mut TestAppContext) {
let env = TestEnv::new().unwrap();
let cred = AwsCredential {
id: Uuid::new_v4(),
name: "work".into(),
access_key_id: "AKIAEXAMPLE".into(),
secret_access_key: "EXAMPLESECRET".into(),
is_default: false,
};
env.db().unwrap().save_aws_credential(&cred).unwrap();
let window = open_app(&env, cx);
fill(window, "passphrase", TEST_PASSPHRASE, cx);
click(window, "submit", cx);
click(window, "credentials", cx);
click(window, "edit-work", cx);
act(window, cx, |window, cx| {
window.click("aws-name", cx);
window.press("ctrl-a", cx);
window.input("personal", cx);
});
click(window, "aws-default", cx);
click(window, "aws-save", cx);
assert_eq!(error_message(window, cx), None);
assert!(is_visible(window, "personal", cx));
assert!(!is_visible(window, "work", cx));
let creds = cx.read(|cx| {
let AppSession::Unlocked(db) = cx.global::<AppSession>() else { panic!("locked") };
db.list_aws_credentials().unwrap()
});
assert_eq!(creds.len(), 1);
// fields that weren't touched keep the values the form was opened with
assert_eq!(creds[0].id, cred.id);
assert_eq!(creds[0].name, "personal");
assert_eq!(creds[0].access_key_id, "AKIAEXAMPLE");
assert_eq!(creds[0].secret_access_key, "EXAMPLESECRET");
assert!(creds[0].is_default);
}
}