web fixes
This commit is contained in:
@@ -213,6 +213,7 @@ mod tests {
|
||||
table: "invoice".to_string(),
|
||||
},
|
||||
tables: vec![table("invoice", "dynamic"), table("accounts", "system")],
|
||||
link_targets: vec![table("invoice", "dynamic"), table("accounts", "system")],
|
||||
detail: Some(TableDetailView {
|
||||
id: 7,
|
||||
row_display_columns: vec!["number".to_string()],
|
||||
@@ -387,6 +388,7 @@ mod tests {
|
||||
data_type: "money".to_string(),
|
||||
indexed: true,
|
||||
quantity_ledger: false,
|
||||
required: false,
|
||||
money_mode: crate::schema::MoneyMode::Rounded,
|
||||
currency: "EUR".to_string(),
|
||||
});
|
||||
@@ -419,12 +421,14 @@ mod tests {
|
||||
fn the_append_panel_offers_link_targets_and_an_alias() {
|
||||
let mut state = page();
|
||||
state.columns.type_input = "link".to_string();
|
||||
state.tables.push(table("customer", "dynamic"));
|
||||
state.tables.push(TableSummary {
|
||||
// The link targets are their own list: a profile's table may point at
|
||||
// a shared one, which is not among the profile's own tables.
|
||||
state.link_targets.push(table("customer", "dynamic"));
|
||||
state.link_targets.push(TableSummary {
|
||||
global: true,
|
||||
..table("currencies", "dynamic")
|
||||
});
|
||||
state.tables.push(table("audit_log", "system"));
|
||||
state.link_targets.push(table("audit_log", "system"));
|
||||
|
||||
let html = render_column_panel(&state);
|
||||
|
||||
@@ -436,6 +440,76 @@ mod tests {
|
||||
assert!(html.contains(r#"<optgroup label="User-created">"#));
|
||||
assert!(html.contains(r#"<optgroup label="System-created">"#));
|
||||
assert!(!html.contains(r#"<option value="invoice""#));
|
||||
// The chart of accounts is reached through ACCOUNTING, never linked to.
|
||||
assert!(!html.contains(r#"<option value="accounts""#));
|
||||
}
|
||||
|
||||
/// The append screen holds a column to the same rules the builder does,
|
||||
/// because both are the rules the server applies.
|
||||
#[test]
|
||||
fn the_append_panel_leaves_a_links_index_to_the_server() {
|
||||
let mut state = page();
|
||||
assert!(render_column_panel(&state).contains(r#"name="column_indexing_input""#));
|
||||
|
||||
state.columns.type_input = "link".to_string();
|
||||
let html = render_column_panel(&state);
|
||||
|
||||
assert!(!html.contains(r#"name="column_indexing_input""#), "{html}");
|
||||
assert!(html.contains("Indexed automatically"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_append_panel_offers_required_and_reports_it() {
|
||||
let mut state = page();
|
||||
assert!(render_column_panel(&state).contains(r#"name="column_required_input""#));
|
||||
|
||||
state.columns.added.push(crate::schema::ColumnDefinition {
|
||||
name: "issued_on".to_string(),
|
||||
data_type: "date".to_string(),
|
||||
indexed: false,
|
||||
quantity_ledger: false,
|
||||
required: true,
|
||||
money_mode: crate::schema::MoneyMode::Exact,
|
||||
currency: String::new(),
|
||||
});
|
||||
let html = render_column_panel(&state);
|
||||
|
||||
assert!(html.contains(r#"name="column_required" value="yes""#));
|
||||
assert!(html.contains(r#"<span class="tag">required</span>"#));
|
||||
}
|
||||
|
||||
/// A staged link is reported as indexed rather than offered a toggle that
|
||||
/// would send a request the server refuses.
|
||||
#[test]
|
||||
fn a_staged_link_is_shown_as_indexed_by_the_server() {
|
||||
let mut state = page();
|
||||
state.columns.added.push(crate::schema::ColumnDefinition {
|
||||
name: "billing_customer".to_string(),
|
||||
data_type: "link(customer)".to_string(),
|
||||
indexed: false,
|
||||
quantity_ledger: false,
|
||||
required: false,
|
||||
money_mode: crate::schema::MoneyMode::Exact,
|
||||
currency: String::new(),
|
||||
});
|
||||
|
||||
let html = render_column_panel(&state);
|
||||
|
||||
assert!(html.contains("indexed automatically"), "{html}");
|
||||
assert!(!html.contains(r#""action": "toggle-index", "index": "0""#));
|
||||
}
|
||||
|
||||
/// A shared table keeps no quantity ledger, which belongs to one profile.
|
||||
#[test]
|
||||
fn the_append_panel_offers_no_quantity_ledger_on_a_shared_table() {
|
||||
let mut state = page();
|
||||
assert!(render_column_panel(&state).contains(r#"name="column_quantity_ledger_input""#));
|
||||
|
||||
state.columns.global = true;
|
||||
let html = render_column_panel(&state);
|
||||
|
||||
assert!(!html.contains(r#"name="column_quantity_ledger_input""#), "{html}");
|
||||
assert!(html.contains("keeps no books of its own"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user