Rework the integration UI so Add and Manage are separate surfaces, only active integrations appear in Manage, and integrations with settings (e.g. Bitcoin) can be edited via the same form used to add them. Replace the ModalDialog/initialComponent flow with a modal service and a single ModalHost that lazily mounts each dialog body, so forms and custom elements start fresh per open. Move integration components to settings/integrations, add an integrations service that unifies registry capabilities with live instances, and fix the select value refresh and bitcoin config reset.
94 lines
2.6 KiB
Plaintext
94 lines
2.6 KiB
Plaintext
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'dashtab/tests/helpers';
|
|
import { render, settled } from '@ember/test-helpers';
|
|
import Select from 'dashtab/components/settings/integrations/select';
|
|
|
|
module(
|
|
'Integration | Component | settings/integrations/select',
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('it renders the label, options and selected label', async function (assert) {
|
|
this.set('options', [
|
|
{ value: 'a', label: 'Option A' },
|
|
{ value: 'b', label: 'Option B' },
|
|
]);
|
|
this.set('noop', () => {});
|
|
|
|
await render(
|
|
<template>
|
|
<Select
|
|
@id="test-select"
|
|
@label="Pick one"
|
|
@options={{this.options}}
|
|
@value="b"
|
|
@onChange={{this.noop}}
|
|
/>
|
|
</template>
|
|
);
|
|
|
|
assert.dom('label').hasText('Pick one');
|
|
assert.dom('el-select').exists();
|
|
assert.dom('el-option').exists({ count: 2 });
|
|
assert.dom('el-selectedcontent').hasText('Option B');
|
|
});
|
|
|
|
test('it updates the selected label when the bound value changes', async function (assert) {
|
|
this.set('options', [
|
|
{ value: 'a', label: 'Option A' },
|
|
{ value: 'b', label: 'Option B' },
|
|
]);
|
|
this.set('noop', () => {});
|
|
this.set('value', 'a');
|
|
|
|
await render(
|
|
<template>
|
|
<Select
|
|
@id="test-select"
|
|
@label="Pick one"
|
|
@options={{this.options}}
|
|
@value={{this.value}}
|
|
@onChange={{this.noop}}
|
|
/>
|
|
</template>
|
|
);
|
|
|
|
assert.dom('el-selectedcontent').hasText('Option A');
|
|
|
|
this.set('value', 'b');
|
|
await settled();
|
|
|
|
assert.dom('el-selectedcontent').hasText('Option B');
|
|
});
|
|
|
|
test('it calls onChange with the chosen value', async function (assert) {
|
|
this.set('options', [
|
|
{ value: 'a', label: 'Option A' },
|
|
{ value: 'b', label: 'Option B' },
|
|
]);
|
|
|
|
const calls = [];
|
|
this.set('onChange', (value) => calls.push(value));
|
|
|
|
await render(
|
|
<template>
|
|
<Select
|
|
@id="test-select"
|
|
@label="Pick one"
|
|
@options={{this.options}}
|
|
@value="a"
|
|
@onChange={{this.onChange}}
|
|
/>
|
|
</template>
|
|
);
|
|
|
|
const select = document.querySelector('el-select');
|
|
const event = new Event('change', { bubbles: true });
|
|
Object.defineProperty(event, 'target', { value: { value: 'b' } });
|
|
select.dispatchEvent(event);
|
|
|
|
assert.deepEqual(calls, ['b']);
|
|
});
|
|
}
|
|
);
|