summaryrefslogtreecommitdiff
path: root/spec/frontend/admin/users
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/admin/users')
-rw-r--r--spec/frontend/admin/users/components/user_date_spec.js2
-rw-r--r--spec/frontend/admin/users/components/users_table_spec.js2
-rw-r--r--spec/frontend/admin/users/new_spec.js76
3 files changed, 78 insertions, 2 deletions
diff --git a/spec/frontend/admin/users/components/user_date_spec.js b/spec/frontend/admin/users/components/user_date_spec.js
index 6428b10059b..1a2f2938db5 100644
--- a/spec/frontend/admin/users/components/user_date_spec.js
+++ b/spec/frontend/admin/users/components/user_date_spec.js
@@ -1,6 +1,6 @@
import { shallowMount } from '@vue/test-utils';
-import UserDate from '~/admin/users/components/user_date.vue';
+import UserDate from '~/vue_shared/components/user_date.vue';
import { users } from '../mock_data';
const mockDate = users[0].createdAt;
diff --git a/spec/frontend/admin/users/components/users_table_spec.js b/spec/frontend/admin/users/components/users_table_spec.js
index f1fcc20fb65..424b0deebd3 100644
--- a/spec/frontend/admin/users/components/users_table_spec.js
+++ b/spec/frontend/admin/users/components/users_table_spec.js
@@ -3,8 +3,8 @@ import { mount } from '@vue/test-utils';
import AdminUserActions from '~/admin/users/components/user_actions.vue';
import AdminUserAvatar from '~/admin/users/components/user_avatar.vue';
-import AdminUserDate from '~/admin/users/components/user_date.vue';
import AdminUsersTable from '~/admin/users/components/users_table.vue';
+import AdminUserDate from '~/vue_shared/components/user_date.vue';
import { users, paths } from '../mock_data';
diff --git a/spec/frontend/admin/users/new_spec.js b/spec/frontend/admin/users/new_spec.js
new file mode 100644
index 00000000000..692c583dca8
--- /dev/null
+++ b/spec/frontend/admin/users/new_spec.js
@@ -0,0 +1,76 @@
+import {
+ setupInternalUserRegexHandler,
+ ID_USER_EMAIL,
+ ID_USER_EXTERNAL,
+ ID_WARNING,
+} from '~/admin/users/new';
+
+describe('admin/users/new', () => {
+ const FIXTURE = 'admin/users/new_with_internal_user_regex.html';
+
+ let elExternal;
+ let elUserEmail;
+ let elWarningMessage;
+
+ beforeEach(() => {
+ loadFixtures(FIXTURE);
+ setupInternalUserRegexHandler();
+
+ elExternal = document.getElementById(ID_USER_EXTERNAL);
+ elUserEmail = document.getElementById(ID_USER_EMAIL);
+ elWarningMessage = document.getElementById(ID_WARNING);
+
+ elExternal.checked = true;
+ });
+
+ const changeEmail = (val) => {
+ elUserEmail.value = val;
+ elUserEmail.dispatchEvent(new Event('input'));
+ };
+
+ const hasHiddenWarning = () => elWarningMessage.classList.contains('hidden');
+
+ describe('Behaviour of userExternal checkbox', () => {
+ it('hides warning by default', () => {
+ expect(hasHiddenWarning()).toBe(true);
+ });
+
+ describe('when matches email as internal', () => {
+ beforeEach(() => {
+ changeEmail('test@');
+ });
+
+ it('has external unchecked', () => {
+ expect(elExternal.checked).toBe(false);
+ });
+
+ it('shows warning', () => {
+ expect(hasHiddenWarning()).toBe(false);
+ });
+
+ describe('when external is checked again', () => {
+ beforeEach(() => {
+ elExternal.dispatchEvent(new Event('change'));
+ });
+
+ it('hides warning', () => {
+ expect(hasHiddenWarning()).toBe(true);
+ });
+ });
+ });
+
+ describe('when matches emails as external', () => {
+ beforeEach(() => {
+ changeEmail('test.ext@');
+ });
+
+ it('has external checked', () => {
+ expect(elExternal.checked).toBe(true);
+ });
+
+ it('hides warning', () => {
+ expect(hasHiddenWarning()).toBe(true);
+ });
+ });
+ });
+});