2018-10-15 09:36:19 -04:00
|
|
|
import $ from 'jquery';
|
2021-02-10 16:09:24 -05:00
|
|
|
import initSettingsPanels, { isExpanded } from '~/settings_panels';
|
2018-02-12 20:30:03 -05:00
|
|
|
|
|
|
|
describe('Settings Panels', () => {
|
|
|
|
beforeEach(() => {
|
2019-03-26 12:03:28 -04:00
|
|
|
loadFixtures('groups/edit.html');
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('initSettingsPane', () => {
|
|
|
|
afterEach(() => {
|
2018-06-15 11:58:27 -04:00
|
|
|
window.location.hash = '';
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should expand linked hash fragment panel', () => {
|
2018-10-15 09:36:19 -04:00
|
|
|
window.location.hash = '#js-general-settings';
|
2018-02-12 20:30:03 -05:00
|
|
|
|
2018-10-15 09:36:19 -04:00
|
|
|
const panel = document.querySelector('#js-general-settings');
|
2018-02-12 20:30:03 -05:00
|
|
|
// Our test environment automatically expands everything so we need to clear that out first
|
2018-10-15 09:36:19 -04:00
|
|
|
panel.classList.remove('expanded');
|
2018-02-12 20:30:03 -05:00
|
|
|
|
2021-02-10 16:09:24 -05:00
|
|
|
expect(isExpanded(panel)).toBe(false);
|
2018-02-12 20:30:03 -05:00
|
|
|
|
|
|
|
initSettingsPanels();
|
|
|
|
|
2021-02-10 16:09:24 -05:00
|
|
|
expect(isExpanded(panel)).toBe(true);
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
2022-02-02 16:16:54 -05:00
|
|
|
|
|
|
|
it('should expand panel containing linked hash', () => {
|
|
|
|
window.location.hash = '#group_description';
|
|
|
|
|
|
|
|
const panel = document.querySelector('#js-general-settings');
|
|
|
|
// Our test environment automatically expands everything so we need to clear that out first
|
|
|
|
panel.classList.remove('expanded');
|
|
|
|
|
|
|
|
expect(isExpanded(panel)).toBe(false);
|
|
|
|
|
|
|
|
initSettingsPanels();
|
|
|
|
|
|
|
|
expect(isExpanded(panel)).toBe(true);
|
|
|
|
});
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
2018-10-15 09:36:19 -04:00
|
|
|
|
|
|
|
it('does not change the text content of triggers', () => {
|
|
|
|
const panel = document.querySelector('#js-general-settings');
|
|
|
|
const trigger = panel.querySelector('.js-settings-toggle-trigger-only');
|
|
|
|
const originalText = trigger.textContent;
|
|
|
|
|
|
|
|
initSettingsPanels();
|
|
|
|
|
2021-02-10 16:09:24 -05:00
|
|
|
expect(isExpanded(panel)).toBe(true);
|
2018-10-15 09:36:19 -04:00
|
|
|
|
|
|
|
$(trigger).click();
|
|
|
|
|
2021-02-10 16:09:24 -05:00
|
|
|
expect(isExpanded(panel)).toBe(false);
|
2018-10-15 09:36:19 -04:00
|
|
|
expect(trigger.textContent).toEqual(originalText);
|
|
|
|
});
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|