Add theme selection (#2428)

* fix: 🐛 remove theme from main menu bar and move to settings pag

* chore: 🤖 move toggletheme to app controller
This commit is contained in:
Dharini Jeeva authored and Zhihe Li committed 2024-09-24 11:58:24 -04:00
1 parent 25b3a940a3
commit 777380e19f
8 files changed
+132 -110

No files matched your search

@@ -4,10 +4,19 @@
*/
import { module, test } from 'qunit';
import { currentURL, click, visit } from '@ember/test-helpers';
import {
currentURL,
click,
visit,
getRootElement,
select,
} from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { authenticateSession } from 'ember-simple-auth/test-support';
import {
authenticateSession,
currentSession,
} from 'ember-simple-auth/test-support';
import WindowMockIPC from '../../../helpers/window-mock-ipc';
import setupStubs from 'api/test-support/handlers/cache-daemon-search';
@@ -94,4 +103,31 @@ module('Acceptance | projects | settings | index', function (hooks) {
await click(`[href="${urls.settings}"]`);
assert.strictEqual(currentURL(), urls.settings);
});
test('color theme is applied from session data', async function (assert) {
await visit(urls.settings);
// system default
assert.notOk(currentSession().get('data.theme'));
assert.notOk(getRootElement().classList.contains('rose-theme-light'));
assert.notOk(getRootElement().classList.contains('rose-theme-dark'));
// toggle light mode
await select('[name="theme"]', 'light');
assert.strictEqual(currentSession().get('data.theme'), 'light');
assert.ok(getRootElement().classList.contains('rose-theme-light'));
assert.notOk(getRootElement().classList.contains('rose-theme-dark'));
// toggle dark mode
await select('[name="theme"]', 'dark');
assert.strictEqual(currentSession().get('data.theme'), 'dark');
assert.notOk(getRootElement().classList.contains('rose-theme-light'));
assert.ok(getRootElement().classList.contains('rose-theme-dark'));
// toggle system default
await select('[name="theme"]', 'system-default-theme');
assert.strictEqual(
currentSession().get('data.theme'),
'system-default-theme',
);
assert.notOk(getRootElement().classList.contains('rose-theme-light'));
assert.notOk(getRootElement().classList.contains('rose-theme-dark'));
});
});