display what accouting would create
This commit is contained in:
@@ -197,6 +197,77 @@ mod tests {
|
||||
assert!(html.contains(r#"<optgroup label="System-created">"#));
|
||||
}
|
||||
|
||||
/// Choosing a compound type says what it will add, instead of leaving the
|
||||
/// choice to be discovered after the table exists.
|
||||
#[test]
|
||||
fn choosing_accounting_shows_the_columns_it_will_generate() {
|
||||
let mut state = page();
|
||||
assert!(!render_builder(&state).contains("compound-note"));
|
||||
|
||||
state.draft.columns.type_input = "accounting".to_string();
|
||||
let html = render_builder(&state);
|
||||
|
||||
assert!(html.contains("compound-note"));
|
||||
for generated in ["name", "tax_point_date", "debit", "credit", "account_id"] {
|
||||
assert!(
|
||||
html.contains(&format!("<code>{generated}</code>")),
|
||||
"the note is missing {generated}"
|
||||
);
|
||||
}
|
||||
// A definition row is named after its own type, so there is nothing to
|
||||
// type in and nothing to index.
|
||||
assert!(!html.contains(r#"name="column_name_input""#));
|
||||
assert!(!html.contains(r#"name="column_indexing_input""#));
|
||||
// It does declare the currency its DEBIT and CREDIT are kept in.
|
||||
assert!(html.contains(r#"name="column_currency_input""#));
|
||||
}
|
||||
|
||||
/// The column list can be reordered, and the ends say so by refusing.
|
||||
#[test]
|
||||
fn columns_carry_move_buttons_that_stop_at_the_ends() {
|
||||
let mut state = page();
|
||||
state.draft.columns.added.push(ColumnDefinition {
|
||||
name: "total".to_string(),
|
||||
data_type: "money".to_string(),
|
||||
indexed: false,
|
||||
quantity_ledger: false,
|
||||
money_mode: MoneyMode::Exact,
|
||||
currency: "EUR".to_string(),
|
||||
});
|
||||
|
||||
let html = render_builder(&state);
|
||||
|
||||
assert!(html.contains(r#""action": "move-column-down", "index": "0""#));
|
||||
assert!(html.contains(r#""action": "move-column-up", "index": "1""#));
|
||||
// The first column cannot move up, nor the last one down.
|
||||
assert!(!html.contains(r#""action": "move-column-up", "index": "0""#));
|
||||
assert!(!html.contains(r#""action": "move-column-down", "index": "1""#));
|
||||
assert_eq!(html.matches("disabled").count(), 2);
|
||||
}
|
||||
|
||||
/// And an added definition row is listed with the columns it stands for.
|
||||
#[test]
|
||||
fn the_column_list_shows_generated_columns_under_their_definition_row() {
|
||||
let mut state = page();
|
||||
state.draft.columns.added.push(ColumnDefinition {
|
||||
name: "accounting".to_string(),
|
||||
data_type: "accounting".to_string(),
|
||||
indexed: false,
|
||||
quantity_ledger: false,
|
||||
money_mode: MoneyMode::Exact,
|
||||
currency: "EUR".to_string(),
|
||||
});
|
||||
|
||||
let html = render_builder(&state);
|
||||
|
||||
assert!(html.contains("generated-row"));
|
||||
assert!(html.contains("generated by accounting"));
|
||||
assert!(html.contains("<code>tax_point_date</code>"));
|
||||
// A generated column is not the user's to remove: the definition row
|
||||
// is the only one of the two with a Remove button.
|
||||
assert_eq!(html.matches("remove-column").count(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_new_profile_fields_appear_only_for_a_new_profile() {
|
||||
let mut state = page();
|
||||
|
||||
Reference in New Issue
Block a user