Introduce a per-section content registry (contentFor) mirroring the integration form registry, and use it for a new Advanced > Protocol Gateway section that explains Sockethub and edits the server URL, with a live connection status. The URL field loads the stored value via sockethub.loadUrl() so it never prefills the default over a saved URL, and save failures surface inline. Also narrow the settings dialog (sm:max-w-4xl) and sidebar (sm:w-52) and shorten it (min(80vh,40rem)).
89 lines
2.7 KiB
Plaintext
89 lines
2.7 KiB
Plaintext
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'dashtab/tests/helpers';
|
|
import { render, click } from '@ember/test-helpers';
|
|
import GlobalSettings from 'dashtab/components/settings/global-settings';
|
|
import { SETTINGS_SECTIONS } from 'dashtab/config/settings';
|
|
|
|
function sectionButton(element, label) {
|
|
return [...element.querySelectorAll('nav button')].find(
|
|
(button) => button.textContent.trim() === label
|
|
);
|
|
}
|
|
|
|
module('Integration | Component | settings/global-settings', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('renders a nav entry for every section', async function (assert) {
|
|
const noop = () => {};
|
|
|
|
await render(<template><GlobalSettings @close={{noop}} /></template>);
|
|
|
|
for (const section of SETTINGS_SECTIONS) {
|
|
assert
|
|
.dom('nav[aria-label="Settings"]')
|
|
.includesText(section.label, `nav lists "${section.label}"`);
|
|
}
|
|
});
|
|
|
|
test('shows the first section by default', async function (assert) {
|
|
const noop = () => {};
|
|
|
|
await render(<template><GlobalSettings @close={{noop}} /></template>);
|
|
|
|
assert.dom('#modal-title').exists({ count: 1 });
|
|
assert.dom('#modal-title').hasText(SETTINGS_SECTIONS[0].label);
|
|
});
|
|
|
|
test('switching sections updates the heading and aria-current', async function (assert) {
|
|
const noop = () => {};
|
|
|
|
await render(<template><GlobalSettings @close={{noop}} /></template>);
|
|
|
|
const target = SETTINGS_SECTIONS[1];
|
|
const button = sectionButton(this.element, target.label);
|
|
|
|
await click(button);
|
|
|
|
assert.dom('#modal-title').hasText(target.label);
|
|
assert.dom(button).hasAttribute('aria-current', 'true');
|
|
assert
|
|
.dom(sectionButton(this.element, SETTINGS_SECTIONS[0].label))
|
|
.doesNotHaveAttribute('aria-current');
|
|
});
|
|
|
|
test('the close button calls @close', async function (assert) {
|
|
let closed = false;
|
|
const close = () => {
|
|
closed = true;
|
|
};
|
|
|
|
await render(<template><GlobalSettings @close={{close}} /></template>);
|
|
await click('[aria-label="Close settings"]');
|
|
|
|
assert.true(closed);
|
|
});
|
|
|
|
test('renders a section content component when one is registered', async function (assert) {
|
|
const noop = () => {};
|
|
|
|
this.owner.register(
|
|
'service:sockethub',
|
|
{
|
|
url: null,
|
|
status: 'disconnected',
|
|
error: null,
|
|
loadUrl() {},
|
|
setUrl() {},
|
|
},
|
|
{ instantiate: false }
|
|
);
|
|
|
|
await render(<template><GlobalSettings @close={{noop}} /></template>);
|
|
await click(sectionButton(this.element, 'Protocol Gateway'));
|
|
|
|
assert.dom('#modal-title').hasText('Protocol Gateway');
|
|
assert.dom('a[href="https://sockethub.org"]').exists();
|
|
assert.dom('input#sockethub-url').exists();
|
|
});
|
|
});
|