diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-10 06:07:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-10 06:07:43 +0300 |
commit | 677227413ae31f5a02fd4c8e10f6ef50c228334f (patch) | |
tree | fbd07453cf1aaded55f081bb42fa043b3f3ffc2b /spec | |
parent | 3f22924df411018ba665ecf72ab0768d61173477 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 103 insertions, 21 deletions
diff --git a/spec/features/projects/issues/email_participants_spec.rb b/spec/features/projects/issues/email_participants_spec.rb index 753c4ea18c5..a902c8294d7 100644 --- a/spec/features/projects/issues/email_participants_spec.rb +++ b/spec/features/projects/issues/email_participants_spec.rb @@ -65,4 +65,18 @@ RSpec.describe 'viewing an issue', :js, feature_category: :service_desk do end end end + + context 'for feature flags' do + before do + sign_in(user) + end + + it 'pushes service_desk_new_note_email_native_attachments feature flag to frontend' do + stub_feature_flags(service_desk_new_note_email_native_attachments: true) + + visit project_issue_path(project, issue) + + expect(page).to have_pushed_frontend_feature_flags(serviceDeskNewNoteEmailNativeAttachments: true) + end + end end diff --git a/spec/frontend/notes/components/attachments_warning_spec.js b/spec/frontend/notes/components/attachments_warning_spec.js new file mode 100644 index 00000000000..0e99c26ed2b --- /dev/null +++ b/spec/frontend/notes/components/attachments_warning_spec.js @@ -0,0 +1,16 @@ +import { mount } from '@vue/test-utils'; +import AttachmentsWarning from '~/notes/components/attachments_warning.vue'; + +describe('Attachments Warning Component', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(AttachmentsWarning); + }); + + it('shows warning', () => { + const expected = + 'Attachments are sent by email. Attachments over 10 MB are sent as links to your GitLab instance, and only accessible to project members.'; + expect(wrapper.text()).toBe(expected); + }); +}); 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); + }); + }); }); diff --git a/spec/frontend/packages_and_registries/shared/components/registry_list_spec.js b/spec/frontend/packages_and_registries/shared/components/registry_list_spec.js index aaca58d21bb..2e2d5e26d33 100644 --- a/spec/frontend/packages_and_registries/shared/components/registry_list_spec.js +++ b/spec/frontend/packages_and_registries/shared/components/registry_list_spec.js @@ -54,6 +54,28 @@ describe('Registry List', () => { it('exists', () => { expect(findSelectAll().exists()).toBe(true); + expect(findSelectAll().attributes('aria-label')).toBe('Select all'); + expect(findSelectAll().attributes('disabled')).toBeUndefined(); + expect(findSelectAll().attributes('indeterminate')).toBeUndefined(); + }); + + it('sets disabled prop to true when items length is 0', () => { + mountComponent({ propsData: { ...defaultPropsData, items: [] } }); + + expect(findSelectAll().attributes('disabled')).toBe('true'); + }); + + it('when few are selected, sets indeterminate prop to true', async () => { + await findScopedSlotSelectButton(0).trigger('click'); + + expect(findSelectAll().attributes('indeterminate')).toBe('true'); + }); + + it('when all are selected, sets the right checkbox label', async () => { + findSelectAll().vm.$emit('change', true); + await nextTick(); + + expect(findSelectAll().attributes('aria-label')).toBe('Unselect all'); }); it('select and unselect all', async () => { @@ -63,7 +85,7 @@ describe('Registry List', () => { }); // simulate selection - findSelectAll().vm.$emit('input', true); + findSelectAll().vm.$emit('change', true); await nextTick(); // all rows selected @@ -72,12 +94,12 @@ describe('Registry List', () => { }); // simulate de-selection - findSelectAll().vm.$emit('input', ''); + findSelectAll().vm.$emit('change', false); await nextTick(); // no row is not selected items.forEach((item, index) => { - expect(findScopedSlotIsSelectedValue(index).text()).toBe(''); + expect(findScopedSlotIsSelectedValue(index).text()).toBe('false'); }); }); }); diff --git a/spec/mailers/emails/service_desk_spec.rb b/spec/mailers/emails/service_desk_spec.rb index e753bf2c76c..1f55aabc535 100644 --- a/spec/mailers/emails/service_desk_spec.rb +++ b/spec/mailers/emails/service_desk_spec.rb @@ -70,7 +70,7 @@ RSpec.describe Emails::ServiceDesk do is_expected.to have_referable_subject(issue, include_project: false, reply: reply_in_subject) is_expected.to have_body_text(expected_body) expect(subject.attachments.count).to eq(attachments_count.to_i) - expect(subject.content_type).to include('text/html') + expect(subject.content_type).to include(attachments_count.to_i > 0 ? 'multipart/mixed' : 'text/html') end end end |