Rotate through photos from enabled feeds with a persisted shuffle-bag queue. Weekly changes at local Monday midnight and daily at local midnight; Off keeps the selected photo. Legacy configs migrate to the weekly default, and Rotation now sits above Feeds in the Photos settings.
62 lines
2.1 KiB
Plaintext
62 lines
2.1 KiB
Plaintext
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'dashtab/tests/helpers';
|
|
import { render, click } from '@ember/test-helpers';
|
|
import RotationSettings from 'dashtab/components/settings/global-settings/sections/rotation-settings';
|
|
import FakePhotos from 'dashtab/tests/helpers/fake-photos';
|
|
|
|
module(
|
|
'Integration | Component | settings/rotation-settings',
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
function setup(context) {
|
|
const photos = new FakePhotos();
|
|
context.owner.register('service:photos', photos, {
|
|
instantiate: false,
|
|
});
|
|
return photos;
|
|
}
|
|
|
|
test('defaults to Weekly', async function (assert) {
|
|
setup(this);
|
|
|
|
await render(<template><RotationSettings /></template>);
|
|
|
|
assert.dom('legend').hasText('Rotation');
|
|
assert.dom('[data-test-rotation-option="weekly"]').isChecked();
|
|
assert.dom('[data-test-rotation-option="daily"]').isNotChecked();
|
|
assert.dom('[data-test-rotation-option="off"]').isNotChecked();
|
|
assert
|
|
.dom('[data-test-rotation]')
|
|
.includesText('Every Monday at local midnight.');
|
|
});
|
|
|
|
test('switching to Daily updates the mode and copy', async function (assert) {
|
|
const photos = setup(this);
|
|
|
|
await render(<template><RotationSettings /></template>);
|
|
await click('[data-test-rotation-option="daily"]');
|
|
|
|
assert.deepEqual(photos.calls.setRotation, ['daily']);
|
|
assert.strictEqual(photos.rotation, 'daily');
|
|
assert.dom('[data-test-rotation-option="daily"]').isChecked();
|
|
assert
|
|
.dom('[data-test-rotation]')
|
|
.includesText('Every day at local midnight.');
|
|
});
|
|
|
|
test('Off shows the keep-selected copy', async function (assert) {
|
|
const photos = setup(this);
|
|
|
|
await render(<template><RotationSettings /></template>);
|
|
await click('[data-test-rotation-option="off"]');
|
|
|
|
assert.deepEqual(photos.calls.setRotation, ['off']);
|
|
assert.strictEqual(photos.rotation, 'off');
|
|
assert
|
|
.dom('[data-test-rotation]')
|
|
.includesText('Keep the selected photo.');
|
|
});
|
|
}
|
|
);
|