exchange broker options
This commit is contained in:
@@ -40,6 +40,19 @@ pub(crate) async fn load_page(
|
||||
return Err(LoadError::Forbidden);
|
||||
}
|
||||
|
||||
let mut exchange_rates = state.exchange_rates.clone();
|
||||
let rate_sources = exchange_rates
|
||||
.list_rate_sources(
|
||||
authenticated_request(headers, Empty {}).map_err(|_| LoadError::Unauthenticated)?,
|
||||
)
|
||||
.await
|
||||
.map_err(|error| LoadError::Backend(error.message().to_string()))?
|
||||
.into_inner()
|
||||
.sources
|
||||
.into_iter()
|
||||
.map(|source| source.id)
|
||||
.collect();
|
||||
|
||||
let mut definitions = state.definitions;
|
||||
// What a column may be is the backend's to say; the picker and every rule
|
||||
// the draft applies are read from this.
|
||||
@@ -135,6 +148,7 @@ pub(crate) async fn load_page(
|
||||
.into_iter()
|
||||
.map(|profile| profile.name)
|
||||
.collect(),
|
||||
rate_sources,
|
||||
draft,
|
||||
status,
|
||||
error,
|
||||
|
||||
@@ -249,6 +249,7 @@ mod tests {
|
||||
nav: crate::ui::Nav::default(),
|
||||
shared_profile: "__global".to_string(),
|
||||
profiles: vec!["billing".to_string()],
|
||||
rate_sources: vec!["ecb".to_string()],
|
||||
draft,
|
||||
status: None,
|
||||
error: None,
|
||||
|
||||
@@ -198,6 +198,8 @@ impl BuilderForm {
|
||||
pub(crate) struct AddTablePageState {
|
||||
pub nav: crate::ui::Nav,
|
||||
pub profiles: Vec<String>,
|
||||
/// Provider IDs returned by ExchangeRateService.ListRateSources.
|
||||
pub rate_sources: Vec<String>,
|
||||
/// The profile a global table lands in, as the profile tree reports it.
|
||||
/// The builder posts it as the created table's scope.
|
||||
pub shared_profile: String,
|
||||
@@ -511,6 +513,7 @@ mod tests {
|
||||
nav: crate::ui::Nav::default(),
|
||||
shared_profile: "__global".to_string(),
|
||||
profiles: Vec::new(),
|
||||
rate_sources: vec!["ecb".to_string()],
|
||||
draft: posted_form().to_draft(),
|
||||
status: None,
|
||||
error: None,
|
||||
@@ -597,6 +600,7 @@ mod tests {
|
||||
nav: crate::ui::Nav::default(),
|
||||
shared_profile: "__global".to_string(),
|
||||
profiles: Vec::new(),
|
||||
rate_sources: vec!["ecb".to_string()],
|
||||
draft,
|
||||
status: None,
|
||||
error: None,
|
||||
|
||||
@@ -111,6 +111,7 @@ mod tests {
|
||||
nav: Nav::default(),
|
||||
shared_profile: "__global".to_string(),
|
||||
profiles: vec!["billing".to_string()],
|
||||
rate_sources: vec!["ecb".to_string()],
|
||||
draft,
|
||||
status: None,
|
||||
error: None,
|
||||
@@ -221,13 +222,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_page_offers_the_new_profile_option_and_the_currency_list() {
|
||||
fn the_page_offers_backend_vocabularies_for_profile_setup() {
|
||||
let html = render_page(&page());
|
||||
|
||||
assert!(!html.contains("Template error"), "{html}");
|
||||
assert!(html.contains(r#"value="__new__""#));
|
||||
assert!(html.contains(r#"<datalist id="currency-codes">"#));
|
||||
assert!(html.contains(r#"<option value="EUR">"#));
|
||||
assert!(html.contains(r#"<datalist id="rate-source-ids">"#));
|
||||
assert!(html.contains(r#"<option value="ecb">"#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -373,7 +376,16 @@ mod tests {
|
||||
state.draft.creating_new_profile = true;
|
||||
let html = render_builder(&state);
|
||||
assert!(html.contains(r#"name="profile_name_input""#));
|
||||
assert!(html.contains(r#"name="accounting_currency" value="EUR" list="currency-codes""#));
|
||||
assert!(html.contains(r#"name="accounting_currency""#));
|
||||
assert!(html.contains(r#"list="currency-codes""#));
|
||||
assert!(html.contains(r#"name="rate_source_id""#));
|
||||
assert!(html.contains(r#"list="rate-source-ids""#));
|
||||
let foreign_currency_input = html
|
||||
.split(r#"name="foreign_currencies""#)
|
||||
.nth(1)
|
||||
.and_then(|rest| rest.split('>').next())
|
||||
.expect("the initial foreign-currency input should be rendered");
|
||||
assert!(foreign_currency_input.contains(r#"list="currency-codes""#));
|
||||
}
|
||||
|
||||
/// The dialog only exists when there is a failure, and it carries the same
|
||||
|
||||
Reference in New Issue
Block a user