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-10-13 00:10:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-13 00:10:53 +0300
commit74cb1a1df361969e97d1a85683c1dfca5ac8cad1 (patch)
treeae688dc2ce754a5115b39d7fad5d171883e723f5 /spec/frontend/invite_members
parent50b113507b3b03bdce4753ba3ff3ffb53d21f756 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/invite_members')
-rw-r--r--spec/frontend/invite_members/components/invite_members_modal_spec.js64
-rw-r--r--spec/frontend/invite_members/mock_data/api_responses.js52
2 files changed, 79 insertions, 37 deletions
diff --git a/spec/frontend/invite_members/components/invite_members_modal_spec.js b/spec/frontend/invite_members/components/invite_members_modal_spec.js
index d4fbf54c640..cfc2fd65cc1 100644
--- a/spec/frontend/invite_members/components/invite_members_modal_spec.js
+++ b/spec/frontend/invite_members/components/invite_members_modal_spec.js
@@ -132,10 +132,10 @@ describe('InviteMembersModal', () => {
const findUserLimitAlert = () => wrapper.findComponent(UserLimitNotification);
const findAccordion = () => wrapper.findComponent(GlCollapse);
const findErrorsIcon = () => wrapper.findComponent(GlIcon);
- const findMemberErrorMessage = (element) =>
- `${Object.keys(invitationsApiResponse.EXPANDED_RESTRICTED.message)[element]}: ${
- Object.values(invitationsApiResponse.EXPANDED_RESTRICTED.message)[element]
- }`;
+ const expectedErrorMessage = (index, errorType) => {
+ const [username, message] = Object.entries(errorType.parsedMessage)[index];
+ return `${username}: ${message}`;
+ };
const findActionButton = () => wrapper.findByTestId('invite-modal-submit');
const findCancelButton = () => wrapper.findByTestId('invite-modal-cancel');
@@ -317,8 +317,6 @@ describe('InviteMembersModal', () => {
mock.onPost(GROUPS_INVITATIONS_PATH).reply(code, data);
};
- const expectedEmailRestrictedError =
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups.";
const expectedSyntaxError = 'email contains an invalid email address';
describe('when no invites have been entered in the form and then some are entered', () => {
@@ -467,12 +465,16 @@ describe('InviteMembersModal', () => {
it('displays the restricted user api message for response with bad request', async () => {
mockInvitationsApi(HTTP_STATUS_CREATED, invitationsApiResponse.EMAIL_RESTRICTED);
+ await triggerMembersTokenSelect([user3]);
+
clickInviteButton();
await waitForPromises();
expect(findMemberErrorAlert().exists()).toBe(true);
- expect(findMemberErrorAlert().text()).toContain(expectedEmailRestrictedError);
+ expect(findMemberErrorAlert().text()).toContain(
+ expectedErrorMessage(0, invitationsApiResponse.EMAIL_RESTRICTED),
+ );
expect(membersFormGroupInvalidFeedback()).toBe('');
expect(findMembersSelect().props('exceptionState')).not.toBe(false);
});
@@ -480,19 +482,21 @@ describe('InviteMembersModal', () => {
it('displays all errors when there are multiple existing users that are restricted by email', async () => {
mockInvitationsApi(HTTP_STATUS_CREATED, invitationsApiResponse.MULTIPLE_RESTRICTED);
+ await triggerMembersTokenSelect([user3, user4, user5]);
+
clickInviteButton();
await waitForPromises();
expect(findMemberErrorAlert().exists()).toBe(true);
expect(findMemberErrorAlert().text()).toContain(
- Object.values(invitationsApiResponse.MULTIPLE_RESTRICTED.message)[0],
+ expectedErrorMessage(0, invitationsApiResponse.MULTIPLE_RESTRICTED),
);
expect(findMemberErrorAlert().text()).toContain(
- Object.values(invitationsApiResponse.MULTIPLE_RESTRICTED.message)[1],
+ expectedErrorMessage(1, invitationsApiResponse.MULTIPLE_RESTRICTED),
);
expect(findMemberErrorAlert().text()).toContain(
- Object.values(invitationsApiResponse.MULTIPLE_RESTRICTED.message)[2],
+ expectedErrorMessage(2, invitationsApiResponse.MULTIPLE_RESTRICTED),
);
expect(membersFormGroupInvalidFeedback()).toBe('');
expect(findMembersSelect().props('exceptionState')).not.toBe(false);
@@ -612,7 +616,9 @@ describe('InviteMembersModal', () => {
await waitForPromises();
expect(findMemberErrorAlert().exists()).toBe(true);
- expect(findMemberErrorAlert().text()).toContain(expectedEmailRestrictedError);
+ expect(findMemberErrorAlert().text()).toContain(
+ expectedErrorMessage(0, invitationsApiResponse.EMAIL_RESTRICTED),
+ );
expect(membersFormGroupInvalidFeedback()).toBe('');
expect(findMembersSelect().props('exceptionState')).not.toBe(false);
expect(findActionButton().props('loading')).toBe(false);
@@ -621,19 +627,21 @@ describe('InviteMembersModal', () => {
it('displays all errors when there are multiple emails that return a restricted error message', async () => {
mockInvitationsApi(HTTP_STATUS_CREATED, invitationsApiResponse.MULTIPLE_RESTRICTED);
+ await triggerMembersTokenSelect([user3, user4, user5]);
+
clickInviteButton();
await waitForPromises();
expect(findMemberErrorAlert().exists()).toBe(true);
expect(findMemberErrorAlert().text()).toContain(
- Object.values(invitationsApiResponse.MULTIPLE_RESTRICTED.message)[0],
+ expectedErrorMessage(0, invitationsApiResponse.MULTIPLE_RESTRICTED),
);
expect(findMemberErrorAlert().text()).toContain(
- Object.values(invitationsApiResponse.MULTIPLE_RESTRICTED.message)[1],
+ expectedErrorMessage(1, invitationsApiResponse.MULTIPLE_RESTRICTED),
);
expect(findMemberErrorAlert().text()).toContain(
- Object.values(invitationsApiResponse.MULTIPLE_RESTRICTED.message)[2],
+ expectedErrorMessage(2, invitationsApiResponse.MULTIPLE_RESTRICTED),
);
expect(membersFormGroupInvalidFeedback()).toBe('');
expect(findMembersSelect().props('exceptionState')).not.toBe(false);
@@ -689,10 +697,18 @@ describe('InviteMembersModal', () => {
expect(findMemberErrorAlert().props('title')).toContain(
"The following 4 members couldn't be invited",
);
- expect(findMemberErrorAlert().text()).toContain(findMemberErrorMessage(0));
- expect(findMemberErrorAlert().text()).toContain(findMemberErrorMessage(1));
- expect(findMemberErrorAlert().text()).toContain(findMemberErrorMessage(2));
- expect(findMemberErrorAlert().text()).toContain(findMemberErrorMessage(3));
+ expect(findMemberErrorAlert().text()).toContain(
+ expectedErrorMessage(0, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
+ expect(findMemberErrorAlert().text()).toContain(
+ expectedErrorMessage(1, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
+ expect(findMemberErrorAlert().text()).toContain(
+ expectedErrorMessage(2, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
+ expect(findMemberErrorAlert().text()).toContain(
+ expectedErrorMessage(3, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
expect(findAccordion().exists()).toBe(true);
expect(findMoreInviteErrorsButton().text()).toContain('Show more (2)');
expect(findErrorsIcon().attributes('class')).not.toContain('gl-rotate-180');
@@ -715,7 +731,9 @@ describe('InviteMembersModal', () => {
expect(findMemberErrorAlert().props('title')).toContain(
"The following 3 members couldn't be invited",
);
- expect(findMemberErrorAlert().text()).not.toContain(findMemberErrorMessage(0));
+ expect(findMemberErrorAlert().text()).not.toContain(
+ expectedErrorMessage(0, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
await removeMembersToken(user6);
@@ -723,14 +741,18 @@ describe('InviteMembersModal', () => {
expect(findMemberErrorAlert().props('title')).toContain(
"The following 2 members couldn't be invited",
);
- expect(findMemberErrorAlert().text()).not.toContain(findMemberErrorMessage(2));
+ expect(findMemberErrorAlert().text()).not.toContain(
+ expectedErrorMessage(2, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
await removeMembersToken(user4);
expect(findMemberErrorAlert().props('title')).toContain(
"The following member couldn't be invited",
);
- expect(findMemberErrorAlert().text()).not.toContain(findMemberErrorMessage(1));
+ expect(findMemberErrorAlert().text()).not.toContain(
+ expectedErrorMessage(1, invitationsApiResponse.EXPANDED_RESTRICTED),
+ );
await removeMembersToken(user5);
diff --git a/spec/frontend/invite_members/mock_data/api_responses.js b/spec/frontend/invite_members/mock_data/api_responses.js
index 4f773009f37..9190f85d7a0 100644
--- a/spec/frontend/invite_members/mock_data/api_responses.js
+++ b/spec/frontend/invite_members/mock_data/api_responses.js
@@ -6,36 +6,56 @@ const ERROR_EMAIL_INVALID = {
error: 'email contains an invalid email address',
};
+const BASE_ERROR_MEMBER_NOT_ALLOWED = `The member's email address is not allowed for this project. \
+Go to the &#39;Admin area &gt; Sign-up restrictions&#39;, and check`;
+
+const ALLOWED_DOMAIN_ERROR = `${BASE_ERROR_MEMBER_NOT_ALLOWED} &#39;Allowed domains for sign-ups&#39;.`;
+const DOMAIN_DENYLIST_ERROR = `${BASE_ERROR_MEMBER_NOT_ALLOWED} the &#39;Domain denylist&#39;.`;
+
+function htmlDecode(input) {
+ const doc = new DOMParser().parseFromString(input, 'text/html');
+ return doc.documentElement.textContent;
+}
+
+const DECODED_ALLOWED_DOMAIN_ERROR = htmlDecode(ALLOWED_DOMAIN_ERROR);
+const DECODED_DOMAIN_DENYLIST_ERROR = htmlDecode(DOMAIN_DENYLIST_ERROR);
+
const EMAIL_RESTRICTED = {
message: {
- 'email@example.com':
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups.",
+ 'email@example.com': ALLOWED_DOMAIN_ERROR,
+ },
+ parsedMessage: {
+ 'email@example.com': DECODED_ALLOWED_DOMAIN_ERROR,
},
status: 'error',
};
const MULTIPLE_RESTRICTED = {
message: {
- 'email@example.com':
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups.",
- 'email4@example.com':
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check the Domain denylist.",
- root:
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups.",
+ 'email@example.com': ALLOWED_DOMAIN_ERROR,
+ 'email4@example.com': DOMAIN_DENYLIST_ERROR,
+ root: ALLOWED_DOMAIN_ERROR,
+ },
+ parsedMessage: {
+ 'email@example.com': DECODED_ALLOWED_DOMAIN_ERROR,
+ 'email4@example.com': DECODED_DOMAIN_DENYLIST_ERROR,
+ root: DECODED_ALLOWED_DOMAIN_ERROR,
},
status: 'error',
};
const EXPANDED_RESTRICTED = {
message: {
- 'email@example.com':
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups.",
- 'email4@example.com':
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check the Domain denylist.",
- 'email5@example.com':
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check the Domain denylist.",
- root:
- "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups.",
+ 'email@example.com': ALLOWED_DOMAIN_ERROR,
+ 'email4@example.com': DOMAIN_DENYLIST_ERROR,
+ 'email5@example.com': DOMAIN_DENYLIST_ERROR,
+ root: ALLOWED_DOMAIN_ERROR,
+ },
+ parsedMessage: {
+ 'email@example.com': DECODED_ALLOWED_DOMAIN_ERROR,
+ 'email4@example.com': DECODED_DOMAIN_DENYLIST_ERROR,
+ 'email5@example.com': DECODED_DOMAIN_DENYLIST_ERROR,
+ root: DECODED_ALLOWED_DOMAIN_ERROR,
},
status: 'error',
};