summaryrefslogtreecommitdiff
path: root/spec/frontend/notes/components/comment_field_layout_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/notes/components/comment_field_layout_spec.js')
-rw-r--r--spec/frontend/notes/components/comment_field_layout_spec.js64
1 files changed, 47 insertions, 17 deletions
diff --git a/spec/frontend/notes/components/comment_field_layout_spec.js b/spec/frontend/notes/components/comment_field_layout_spec.js
index 6662492fd81..93b54f95021 100644
--- a/spec/frontend/notes/components/comment_field_layout_spec.js
+++ b/spec/frontend/notes/components/comment_field_layout_spec.js
@@ -1,17 +1,13 @@
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import CommentFieldLayout from '~/notes/components/comment_field_layout.vue';
+import AttachmentsWarning from '~/notes/components/attachments_warning.vue';
import EmailParticipantsWarning from '~/notes/components/email_participants_warning.vue';
import NoteableWarning from '~/vue_shared/components/notes/noteable_warning.vue';
describe('Comment Field Layout Component', () => {
let wrapper;
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
- });
-
const LOCKED_DISCUSSION_DOCS_PATH = 'docs/locked/path';
const CONFIDENTIAL_ISSUES_DOCS_PATH = 'docs/confidential/path';
@@ -22,18 +18,32 @@ describe('Comment Field Layout Component', () => {
confidential_issues_docs_path: CONFIDENTIAL_ISSUES_DOCS_PATH,
};
+ const commentFieldWithAttachmentData = {
+ noteableData: {
+ ...noteableDataMock,
+ issue_email_participants: [{ email: 'someone@gitlab.com' }, { email: 'another@gitlab.com' }],
+ },
+ containsLink: true,
+ };
+
const findIssuableNoteWarning = () => wrapper.findComponent(NoteableWarning);
const findEmailParticipantsWarning = () => wrapper.findComponent(EmailParticipantsWarning);
+ const findAttachmentsWarning = () => wrapper.findComponent(AttachmentsWarning);
const findErrorAlert = () => wrapper.findByTestId('comment-field-alert-container');
- const createWrapper = (props = {}, slots = {}) => {
+ const createWrapper = (props = {}, provide = {}) => {
wrapper = extendedWrapper(
shallowMount(CommentFieldLayout, {
propsData: {
noteableData: noteableDataMock,
...props,
},
- slots,
+ provide: {
+ glFeatures: {
+ serviceDeskNewNoteEmailNativeAttachments: true,
+ },
+ ...provide,
+ },
}),
);
};
@@ -108,23 +118,25 @@ describe('Comment Field Layout Component', () => {
expect(findEmailParticipantsWarning().exists()).toBe(false);
});
+
+ it('does not show AttachmentWarning', () => {
+ createWrapper();
+
+ expect(findAttachmentsWarning().exists()).toBe(false);
+ });
});
describe('issue has email participants', () => {
beforeEach(() => {
- createWrapper({
- noteableData: {
- ...noteableDataMock,
- issue_email_participants: [
- { email: 'someone@gitlab.com' },
- { email: 'another@gitlab.com' },
- ],
- },
- });
+ createWrapper(commentFieldWithAttachmentData);
});
it('shows EmailParticipantsWarning', () => {
- expect(findEmailParticipantsWarning().isVisible()).toBe(true);
+ expect(findEmailParticipantsWarning().exists()).toBe(true);
+ });
+
+ it('shows AttachmentsWarning', () => {
+ expect(findAttachmentsWarning().isVisible()).toBe(true);
});
it('sets EmailParticipantsWarning props', () => {
@@ -148,4 +160,22 @@ describe('Comment Field Layout Component', () => {
expect(findEmailParticipantsWarning().exists()).toBe(false);
});
});
+
+ describe('serviceDeskNewNoteEmailNativeAttachments flag', () => {
+ it('shows warning message when flag is enabled', () => {
+ createWrapper(commentFieldWithAttachmentData, {
+ glFeatures: { serviceDeskNewNoteEmailNativeAttachments: true },
+ });
+
+ expect(findAttachmentsWarning().exists()).toBe(true);
+ });
+
+ it('shows warning message when flag is disables', () => {
+ createWrapper(commentFieldWithAttachmentData, {
+ glFeatures: { serviceDeskNewNoteEmailNativeAttachments: false },
+ });
+
+ expect(findAttachmentsWarning().exists()).toBe(false);
+ });
+ });
});