Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 06:11:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 06:11:24 +0300
commit729e66ee8e5790eefb3771040839155c499faab3 (patch)
tree19cd1fd73c2373c20d2888e857de022129a79eaa /spec/frontend/pages/admin
parent431b84710e87a649de02d398568804f820e3b0fe (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pages/admin')
-rw-r--r--spec/frontend/pages/admin/application_settings/account_and_limits_spec.js67
1 files changed, 53 insertions, 14 deletions
diff --git a/spec/frontend/pages/admin/application_settings/account_and_limits_spec.js b/spec/frontend/pages/admin/application_settings/account_and_limits_spec.js
index 85ed94b748d..d422f5dade3 100644
--- a/spec/frontend/pages/admin/application_settings/account_and_limits_spec.js
+++ b/spec/frontend/pages/admin/application_settings/account_and_limits_spec.js
@@ -1,20 +1,15 @@
-import $ from 'jquery';
import { loadHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
-import initUserInternalRegexPlaceholder, {
+import initAccountAndLimitsSection, {
PLACEHOLDER_USER_EXTERNAL_DEFAULT_FALSE,
PLACEHOLDER_USER_EXTERNAL_DEFAULT_TRUE,
} from '~/pages/admin/application_settings/account_and_limits';
describe('AccountAndLimits', () => {
const FIXTURE = 'application_settings/accounts_and_limit.html';
- let $userDefaultExternal;
- let $userInternalRegex;
beforeEach(() => {
loadHTMLFixture(FIXTURE);
- initUserInternalRegexPlaceholder();
- $userDefaultExternal = $('#application_setting_user_default_external');
- $userInternalRegex = document.querySelector('#application_setting_user_default_internal_regex');
+ initAccountAndLimitsSection();
});
afterEach(() => {
@@ -22,18 +17,62 @@ describe('AccountAndLimits', () => {
});
describe('Changing of userInternalRegex when userDefaultExternal', () => {
+ /** @type {HTMLInputElement} */
+ let userDefaultExternalCheckbox;
+ /** @type {HTMLInputElement} */
+ let userInternalRegexInput;
+
+ beforeEach(() => {
+ userDefaultExternalCheckbox = document.getElementById(
+ 'application_setting_user_default_external',
+ );
+ userInternalRegexInput = document.getElementById(
+ 'application_setting_user_default_internal_regex',
+ );
+ });
+
it('is unchecked', () => {
- expect($userDefaultExternal.prop('checked')).toBe(false);
- expect($userInternalRegex.placeholder).toEqual(PLACEHOLDER_USER_EXTERNAL_DEFAULT_FALSE);
- expect($userInternalRegex.readOnly).toBe(true);
+ expect(userDefaultExternalCheckbox.checked).toBe(false);
+ expect(userInternalRegexInput.placeholder).toEqual(PLACEHOLDER_USER_EXTERNAL_DEFAULT_FALSE);
+ expect(userInternalRegexInput.readOnly).toBe(true);
});
it('is checked', () => {
- if (!$userDefaultExternal.prop('checked')) $userDefaultExternal.click();
+ if (!userDefaultExternalCheckbox.checked) userDefaultExternalCheckbox.click();
+
+ expect(userDefaultExternalCheckbox.checked).toBe(true);
+ expect(userInternalRegexInput.placeholder).toEqual(PLACEHOLDER_USER_EXTERNAL_DEFAULT_TRUE);
+ expect(userInternalRegexInput.readOnly).toBe(false);
+ });
+ });
+
+ describe('Dormant users period input logic', () => {
+ /** @type {HTMLInputElement} */
+ let checkbox;
+ /** @type {HTMLInputElement} */
+ let input;
+
+ const updateCheckbox = (checked) => {
+ checkbox.checked = checked;
+ checkbox.dispatchEvent(new Event('change'));
+ };
+
+ beforeEach(() => {
+ checkbox = document.getElementById('application_setting_deactivate_dormant_users');
+ input = document.getElementById('application_setting_deactivate_dormant_users_period');
+ });
+
+ it('initial state', () => {
+ expect(checkbox.checked).toBe(false);
+ expect(input.disabled).toBe(true);
+ });
+
+ it('changes field enabled flag on checkbox change', () => {
+ updateCheckbox(true);
+ expect(input.disabled).toBe(false);
- expect($userDefaultExternal.prop('checked')).toBe(true);
- expect($userInternalRegex.placeholder).toEqual(PLACEHOLDER_USER_EXTERNAL_DEFAULT_TRUE);
- expect($userInternalRegex.readOnly).toBe(false);
+ updateCheckbox(false);
+ expect(input.disabled).toBe(true);
});
});
});