debian-mirror-gitlab/spec/frontend/settings_panels_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-12-13 13:39:08 +05:30
import $ from 'jquery';
2022-07-16 23:28:13 +05:30
import { loadHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
2021-03-11 19:13:27 +05:30
import initSettingsPanels, { isExpanded } from '~/settings_panels';
2018-03-27 19:54:05 +05:30
describe('Settings Panels', () => {
beforeEach(() => {
2022-07-16 23:28:13 +05:30
loadHTMLFixture('groups/edit.html');
});
afterEach(() => {
resetHTMLFixture();
2018-03-27 19:54:05 +05:30
});
describe('initSettingsPane', () => {
afterEach(() => {
2018-11-08 19:23:39 +05:30
window.location.hash = '';
2018-03-27 19:54:05 +05:30
});
it('should expand linked hash fragment panel', () => {
2018-12-13 13:39:08 +05:30
window.location.hash = '#js-general-settings';
2018-03-27 19:54:05 +05:30
2018-12-13 13:39:08 +05:30
const panel = document.querySelector('#js-general-settings');
2018-03-27 19:54:05 +05:30
// Our test environment automatically expands everything so we need to clear that out first
2018-12-13 13:39:08 +05:30
panel.classList.remove('expanded');
2018-03-27 19:54:05 +05:30
2021-03-11 19:13:27 +05:30
expect(isExpanded(panel)).toBe(false);
2018-03-27 19:54:05 +05:30
initSettingsPanels();
2021-03-11 19:13:27 +05:30
expect(isExpanded(panel)).toBe(true);
2018-03-27 19:54:05 +05:30
});
2022-04-04 11:22:00 +05:30
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-03-27 19:54:05 +05:30
});
2018-12-13 13:39:08 +05:30
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-03-11 19:13:27 +05:30
expect(isExpanded(panel)).toBe(true);
2018-12-13 13:39:08 +05:30
$(trigger).click();
2021-03-11 19:13:27 +05:30
expect(isExpanded(panel)).toBe(false);
2018-12-13 13:39:08 +05:30
expect(trigger.textContent).toEqual(originalText);
});
2018-03-27 19:54:05 +05:30
});