Files
raucao 11f8d3f049 WIP: Add calendar settings and a nested modal stack
Add a 'days with events' preference (default 3, range 1-7) that drives the upcoming events widget, and extend the fetch window to 8 days so the largest window can populate.

Add a Calendar settings pane (moved under Integrations) that lists the connected CalDAV/ICS sources in a two-column grid with add/edit/remove, and remove calendars from Manage Integrations.

Turn the modal service into a stack so add/edit forms open on top of the settings dialog, with one dialog per level, per-entry title ids, and a softened stacked backdrop.

Move CALENDAR_ACTOR into its own config module to break the calendar/caldav/ics import cycle.
2026-11-06 15:48:08 +04:00

116 lines
3.6 KiB
Plaintext

import { module, test } from 'qunit';
import { setupRenderingTest } from 'dashtab/tests/helpers';
import { render, click, settled, waitUntil } from '@ember/test-helpers';
import { fn, hash } from '@ember/helper';
import { on } from '@ember/modifier';
import ModalHost from 'dashtab/components/modal-host';
const BodyB = <template>
<div data-body="b">
<h3 id={{if @titleId @titleId "modal-title"}}>B</h3>
<button type="button" data-close {{on "click" @close}}>Close</button>
</div>
</template>;
const BodyA = <template>
<div data-body="a">
<h3 id={{if @titleId @titleId "modal-title"}}>A</h3>
<button
type="button"
data-replace
{{on "click" (fn @replace (hash component=BodyB props=(hash) size="md"))}}
>Replace</button>
<button type="button" data-close {{on "click" @close}}>Close</button>
</div>
</template>;
module('Integration | Component | modal-host', function (hooks) {
setupRenderingTest(hooks);
test('it renders nothing without an open modal', async function (assert) {
await render(<template><ModalHost /></template>);
assert.dom('[data-body]').doesNotExist();
assert.dom('dialog').doesNotExist();
});
test('it renders the current modal at the requested size', async function (assert) {
const modal = this.owner.lookup('service:modal');
await render(<template><ModalHost /></template>);
modal.open({ component: BodyA, props: {}, size: 'sm' });
await settled();
assert.dom('[data-body="a"]').exists();
assert.dom('el-dialog-panel').hasClass('sm:max-w-sm');
assert.dom('dialog[open]').exists();
});
test('replace swaps the body while the dialog stays open', async function (assert) {
const modal = this.owner.lookup('service:modal');
await render(<template><ModalHost /></template>);
modal.open({ component: BodyA, props: {}, size: 'md' });
await settled();
await click('[data-replace]');
assert.dom('[data-body="a"]').doesNotExist();
assert.dom('[data-body="b"]').exists();
assert.dom('dialog[open]').exists();
});
test('finishing the modal unmounts it', async function (assert) {
const modal = this.owner.lookup('service:modal');
await render(<template><ModalHost /></template>);
modal.open({ component: BodyA, props: {}, size: 'md' });
await settled();
modal.finished();
await settled();
assert.dom('[data-body]').doesNotExist();
assert.dom('dialog').doesNotExist();
});
test('opening a second modal keeps the first mounted', async function (assert) {
const modal = this.owner.lookup('service:modal');
await render(<template><ModalHost /></template>);
modal.open({ component: BodyA, props: {}, size: 'sm' });
await settled();
modal.open({ component: BodyB, props: {}, size: 'md' });
await settled();
assert.dom('[data-body="a"]').exists();
assert.dom('[data-body="b"]').exists();
assert.dom('dialog[open]').exists({ count: 2 });
});
test('closing the top modal reveals the one below', async function (assert) {
const modal = this.owner.lookup('service:modal');
await render(<template><ModalHost /></template>);
modal.open({ component: BodyA, props: {}, size: 'sm' });
await settled();
modal.open({ component: BodyB, props: {}, size: 'md' });
await settled();
await click('[data-body="b"] [data-close]');
// The native `close` event is queued as a task, so wait for the entry to
// unmount before asserting.
await waitUntil(() => !document.querySelector('[data-body="b"]'));
assert.dom('[data-body="a"]').exists();
assert.dom('[data-body="b"]').doesNotExist();
assert.dom('dialog[open]').exists({ count: 1 });
});
});