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.
68 lines
1.7 KiB
Plaintext
68 lines
1.7 KiB
Plaintext
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'dashtab/tests/helpers';
|
|
import { render } from '@ember/test-helpers';
|
|
import Events from 'dashtab/components/settings/global-settings/sections/events';
|
|
|
|
class FakeCalendar {
|
|
visibleDays = 3;
|
|
calls = [];
|
|
|
|
setVisibleDays(days) {
|
|
this.calls.push(days);
|
|
this.visibleDays = days;
|
|
}
|
|
}
|
|
|
|
class FakeIntegrations {
|
|
rows = [];
|
|
}
|
|
|
|
class FakeModal {
|
|
open() {}
|
|
}
|
|
|
|
function register(owner, { calendar = new FakeCalendar() } = {}) {
|
|
owner.register('service:calendar', calendar, { instantiate: false });
|
|
owner.register('service:integrations', new FakeIntegrations(), {
|
|
instantiate: false,
|
|
});
|
|
owner.register('service:modal', new FakeModal(), { instantiate: false });
|
|
|
|
return { calendar };
|
|
}
|
|
|
|
function chooseOption(value) {
|
|
const select = document.querySelector('el-select');
|
|
const event = new Event('change', { bubbles: true });
|
|
Object.defineProperty(event, 'target', { value: { value } });
|
|
select.dispatchEvent(event);
|
|
}
|
|
|
|
module(
|
|
'Integration | Component | settings/global-settings/sections/events',
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('shows the current day count and saves the chosen one', async function (assert) {
|
|
const { calendar } = register(this.owner);
|
|
|
|
await render(<template><Events /></template>);
|
|
|
|
assert.dom('el-selectedcontent').hasText('3 days');
|
|
|
|
chooseOption('5');
|
|
|
|
assert.deepEqual(calendar.calls, [5]);
|
|
});
|
|
|
|
test('renders the calendar list', async function (assert) {
|
|
register(this.owner);
|
|
|
|
await render(<template><Events /></template>);
|
|
|
|
assert.dom('[data-add="calendar-caldav"]').exists();
|
|
assert.dom('[data-add="calendar-ics"]').exists();
|
|
});
|
|
}
|
|
);
|