Skip to content

Commit

Permalink
add test for length
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii committed Dec 3, 2024
1 parent ae1c7eb commit d7e14a2
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/backend/tests/it/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,53 @@ fn test_add_user_hidden_dapp_id_does_not_add_duplicate_dapp_id() {
vec!["test_dapp_id".to_string()]
);
}




#[test]
fn test_add_user_hidden_dapp_id_does_not_allow_long_ids() {
let pic_setup = setup();

let caller = Principal::from_text(CALLER).unwrap();

let create_profile_response =
pic_setup.update::<UserProfile>(caller, "create_user_profile", ());

let profile = create_profile_response.expect("Create failed");
assert_eq!(profile.settings.dapp.dapp_carousel.hidden_dapp_ids.len(), 0);

let add_hidden_dapp_id_arg = AddHiddenDappIdRequest {
dapp_id: "test_dapp_id".repeat(100),
current_user_version: profile.version,
};

let add_hidden_dapp_id_response = pic_setup.update::<Result<(), AddDappSettingsError>>(
caller,
"add_user_hidden_dapp_id",
add_hidden_dapp_id_arg,
);

assert_eq!(
add_hidden_dapp_id_response,
Ok(Err(AddDappSettingsError::DappIdTooLong))
);

let get_profile_response = pic_setup.update::<Result<UserProfile, GetUserProfileError>>(
caller,
"get_user_profile",
(),
);

assert_eq!(
get_profile_response
.expect("Call to get profile failed")
.expect("Get profile failed")
.settings
.dapp
.dapp_carousel
.hidden_dapp_ids
.len(),
0
);
}

0 comments on commit d7e14a2

Please sign in to comment.