Reimbursement form fixes and improvements #223

Merged
raucao merged 7 commits from bugfix/220-reimbursement_sums into master 2024-03-21 10:38:45 +00:00
3 changed files with 37 additions and 4 deletions
Showing only changes of commit 7afc75dbff - Show all commits
@@ -74,7 +74,7 @@ export default class AddReimbursementComponent extends Component {
}
updateTotalAmountFromFiat() {
let btcAmount = parseFloat(this.total);
let btcAmount = 0;
if (this.exchangeRates.btceur > 0 && this.totalEUR > 0) {
btcAmount += (this.totalEUR / this.exchangeRates.btceur);
@@ -14,6 +14,7 @@
<p class="label">Total amount (BTC):</p>
<p>
<Input @type="text"
@name="total-btc"
@placeholder="0.0015"
@value={{this.total}}
@required={{true}}
@@ -49,7 +50,9 @@
<p class="actions">
<button {{on "click" this.showExpenseForm}}
class="green small" type="button">+ Add another item</button>
id="add-another-item" class="green small" type="button">
+ Add another item
</button>
</p>
{{else}}
<p>No line items yet.</p>
@@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { click, fillIn, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import contributors from '../../../fixtures/contributors';
@@ -22,7 +22,37 @@ module('Integration | Component | add-reimbursement', function(hooks) {
assert.equal(this.element.querySelector('select#contributor option:checked').value, "3",
'preselects the connected contributor account');
});
test('Adding expense items', async function(assert) {
await render(hbs`<AddReimbursement />`);
assert.ok(true);
assert.dom(this.element).includesText('New expense item');
await fillIn('form input[name="expense-amount"]', '49');
await fillIn('form input[name="expense-title"]', 'Domain kosmos.org (yearly fee)');
await click('form#add-expense-item input[type="submit"]');
assert.equal(this.element.querySelector('input[name="total-eur"]').value, '49',
'updates the total EUR amount');
assert.equal(this.element.querySelector('input[name="total-usd"]').value, '0',
'does not update the total USD amount');
assert.equal(this.element.querySelector('input[name="total-btc"]').value, '0.00534493',
'updates the total BTC amount');
assert.dom(this.element).doesNotIncludeText('New expense item');
await click('button#add-another-item');
await fillIn('form input[name="expense-amount"]', '29');
await fillIn('select[name="expense-currency"]', 'USD');
await fillIn('form input[name="expense-title"]', 'Domain kosmos.social (yearly fee)');
await click('form#add-expense-item input[type="submit"]');
assert.equal(this.element.querySelector('input[name="total-usd"]').value, '29',
'updates the total USD amount');
assert.equal(this.element.querySelector('input[name="total-eur"]').value, '49',
'does not update the total EUR amount');
assert.equal(this.element.querySelector('input[name="total-btc"]').value, '0.00804268',
'updates the total BTC amount');
});
});