2021-06-30 09:08:07 +00:00
|
|
|
import initSetHelperText, {
|
2021-07-19 12:10:08 +00:00
|
|
|
HELPER_TEXT_SERVICE_PING_DISABLED,
|
|
|
|
HELPER_TEXT_SERVICE_PING_ENABLED,
|
2021-06-30 09:08:07 +00:00
|
|
|
} from '~/pages/admin/application_settings/metrics_and_profiling/usage_statistics';
|
2022-05-13 12:08:49 +00:00
|
|
|
import { loadHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2021-06-30 09:08:07 +00:00
|
|
|
|
|
|
|
describe('UsageStatistics', () => {
|
|
|
|
const FIXTURE = 'application_settings/usage.html';
|
2021-08-04 06:09:49 +00:00
|
|
|
let servicePingCheckBox;
|
|
|
|
let servicePingFeaturesCheckBox;
|
|
|
|
let servicePingFeaturesLabel;
|
|
|
|
let servicePingFeaturesHelperText;
|
2021-06-30 09:08:07 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-05-13 12:08:49 +00:00
|
|
|
loadHTMLFixture(FIXTURE);
|
2021-06-30 09:08:07 +00:00
|
|
|
initSetHelperText();
|
2021-08-04 06:09:49 +00:00
|
|
|
servicePingCheckBox = document.getElementById('application_setting_usage_ping_enabled');
|
|
|
|
servicePingFeaturesCheckBox = document.getElementById(
|
2021-06-30 09:08:07 +00:00
|
|
|
'application_setting_usage_ping_features_enabled',
|
|
|
|
);
|
2021-08-04 06:09:49 +00:00
|
|
|
servicePingFeaturesLabel = document.getElementById('service_ping_features_label');
|
|
|
|
servicePingFeaturesHelperText = document.getElementById('service_ping_features_helper_text');
|
2021-06-30 09:08:07 +00:00
|
|
|
});
|
|
|
|
|
2022-05-13 12:08:49 +00:00
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
|
|
|
});
|
|
|
|
|
2021-08-04 06:09:49 +00:00
|
|
|
const expectEnabledservicePingFeaturesCheckBox = () => {
|
|
|
|
expect(servicePingFeaturesCheckBox.classList.contains('gl-cursor-not-allowed')).toBe(false);
|
|
|
|
expect(servicePingFeaturesHelperText.textContent).toEqual(HELPER_TEXT_SERVICE_PING_ENABLED);
|
2021-06-30 09:08:07 +00:00
|
|
|
};
|
|
|
|
|
2021-08-04 06:09:49 +00:00
|
|
|
const expectDisabledservicePingFeaturesCheckBox = () => {
|
|
|
|
expect(servicePingFeaturesLabel.classList.contains('gl-cursor-not-allowed')).toBe(true);
|
|
|
|
expect(servicePingFeaturesHelperText.textContent).toEqual(HELPER_TEXT_SERVICE_PING_DISABLED);
|
2021-06-30 09:08:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('Registration Features checkbox', () => {
|
2021-08-04 06:09:49 +00:00
|
|
|
it('is disabled when Service Ping checkbox is unchecked', () => {
|
|
|
|
expect(servicePingCheckBox.checked).toBe(false);
|
|
|
|
expectDisabledservicePingFeaturesCheckBox();
|
2021-06-30 09:08:07 +00:00
|
|
|
});
|
|
|
|
|
2021-08-04 06:09:49 +00:00
|
|
|
it('is enabled when Servie Ping checkbox is checked', () => {
|
|
|
|
servicePingCheckBox.click();
|
|
|
|
expect(servicePingCheckBox.checked).toBe(true);
|
|
|
|
expectEnabledservicePingFeaturesCheckBox();
|
2021-06-30 09:08:07 +00:00
|
|
|
});
|
|
|
|
|
2021-08-04 06:09:49 +00:00
|
|
|
it('is switched to disabled when Service Ping checkbox is unchecked ', () => {
|
|
|
|
servicePingCheckBox.click();
|
|
|
|
servicePingFeaturesCheckBox.click();
|
|
|
|
expectEnabledservicePingFeaturesCheckBox();
|
2021-06-30 09:08:07 +00:00
|
|
|
|
2021-08-04 06:09:49 +00:00
|
|
|
servicePingCheckBox.click();
|
|
|
|
expect(servicePingCheckBox.checked).toBe(false);
|
|
|
|
expect(servicePingFeaturesCheckBox.checked).toBe(false);
|
|
|
|
expectDisabledservicePingFeaturesCheckBox();
|
2021-06-30 09:08:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|