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>2020-07-20 15:26:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/vue_shared/components/notes
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/vue_shared/components/notes')
-rw-r--r--spec/frontend/vue_shared/components/notes/__snapshots__/noteable_warning_spec.js.snap58
-rw-r--r--spec/frontend/vue_shared/components/notes/noteable_warning_spec.js196
2 files changed, 254 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/notes/__snapshots__/noteable_warning_spec.js.snap b/spec/frontend/vue_shared/components/notes/__snapshots__/noteable_warning_spec.js.snap
new file mode 100644
index 00000000000..573bc9abe4d
--- /dev/null
+++ b/spec/frontend/vue_shared/components/notes/__snapshots__/noteable_warning_spec.js.snap
@@ -0,0 +1,58 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Issue Warning Component when issue is locked but not confidential renders information about locked issue 1`] = `
+<span>
+
+ This issue is locked.
+ Only project members can comment.
+
+ <gl-link-stub
+ href="locked-path"
+ target="_blank"
+ >
+ Learn more
+ </gl-link-stub>
+</span>
+`;
+
+exports[`Issue Warning Component when noteable is confidential but not locked renders information about confidential issue 1`] = `
+<span>
+
+ This is a confidential issue.
+ People without permission will never get a notification.
+
+ <gl-link-stub
+ href="confidential-path"
+ target="_blank"
+ >
+ Learn more
+ </gl-link-stub>
+</span>
+`;
+
+exports[`Issue Warning Component when noteable is locked and confidential renders information about locked and confidential noteable 1`] = `
+<span>
+ <span>
+ This issue is
+ <a
+ href=""
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ confidential
+ </a>
+ and
+ <a
+ href=""
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ locked
+ </a>
+ .
+ </span>
+
+ People without permission will never get a notification and won't be able to comment.
+
+</span>
+`;
diff --git a/spec/frontend/vue_shared/components/notes/noteable_warning_spec.js b/spec/frontend/vue_shared/components/notes/noteable_warning_spec.js
new file mode 100644
index 00000000000..ae8c9a0928e
--- /dev/null
+++ b/spec/frontend/vue_shared/components/notes/noteable_warning_spec.js
@@ -0,0 +1,196 @@
+import { shallowMount } from '@vue/test-utils';
+import NoteableWarning from '~/vue_shared/components/notes/noteable_warning.vue';
+import Icon from '~/vue_shared/components/icon.vue';
+
+describe('Issue Warning Component', () => {
+ let wrapper;
+
+ const findIcon = (w = wrapper) => w.find(Icon);
+ const findLockedBlock = (w = wrapper) => w.find({ ref: 'locked' });
+ const findConfidentialBlock = (w = wrapper) => w.find({ ref: 'confidential' });
+ const findLockedAndConfidentialBlock = (w = wrapper) => w.find({ ref: 'lockedAndConfidential' });
+
+ const createComponent = props =>
+ shallowMount(NoteableWarning, {
+ propsData: {
+ ...props,
+ },
+ });
+
+ afterEach(() => {
+ if (wrapper) {
+ wrapper.destroy();
+ wrapper = null;
+ }
+ });
+
+ describe('when issue is locked but not confidential', () => {
+ beforeEach(() => {
+ wrapper = createComponent({
+ isLocked: true,
+ lockedNoteableDocsPath: 'locked-path',
+ isConfidential: false,
+ });
+ });
+
+ it('renders information about locked issue', () => {
+ expect(findLockedBlock().exists()).toBe(true);
+ expect(findLockedBlock().element).toMatchSnapshot();
+ });
+
+ it('renders warning icon', () => {
+ expect(findIcon().exists()).toBe(true);
+ });
+
+ it('does not render information about locked and confidential issue', () => {
+ expect(findLockedAndConfidentialBlock().exists()).toBe(false);
+ });
+
+ it('does not render information about confidential issue', () => {
+ expect(findConfidentialBlock().exists()).toBe(false);
+ });
+ });
+
+ describe('when noteable is confidential but not locked', () => {
+ beforeEach(() => {
+ wrapper = createComponent({
+ isLocked: false,
+ isConfidential: true,
+ confidentialNoteableDocsPath: 'confidential-path',
+ });
+ });
+
+ it('renders information about confidential issue', async () => {
+ expect(findConfidentialBlock().exists()).toBe(true);
+ expect(findConfidentialBlock().element).toMatchSnapshot();
+
+ await wrapper.vm.$nextTick();
+ expect(findConfidentialBlock(wrapper).text()).toContain('This is a confidential issue.');
+ });
+
+ it('renders warning icon', () => {
+ expect(wrapper.find(Icon).exists()).toBe(true);
+ });
+
+ it('does not render information about locked noteable', () => {
+ expect(findLockedBlock().exists()).toBe(false);
+ });
+
+ it('does not render information about locked and confidential noteable', () => {
+ expect(findLockedAndConfidentialBlock().exists()).toBe(false);
+ });
+ });
+
+ describe('when noteable is locked and confidential', () => {
+ beforeEach(() => {
+ wrapper = createComponent({
+ isLocked: true,
+ isConfidential: true,
+ });
+ });
+
+ it('renders information about locked and confidential noteable', () => {
+ expect(findLockedAndConfidentialBlock().exists()).toBe(true);
+ expect(findLockedAndConfidentialBlock().element).toMatchSnapshot();
+ });
+
+ it('does not render warning icon', () => {
+ expect(wrapper.find(Icon).exists()).toBe(false);
+ });
+
+ it('does not render information about locked noteable', () => {
+ expect(findLockedBlock().exists()).toBe(false);
+ });
+
+ it('does not render information about confidential noteable', () => {
+ expect(findConfidentialBlock().exists()).toBe(false);
+ });
+ });
+
+ describe('when noteableType prop is defined', () => {
+ let wrapperLocked;
+ let wrapperConfidential;
+ let wrapperLockedAndConfidential;
+
+ beforeEach(() => {
+ wrapperLocked = createComponent({
+ isLocked: true,
+ isConfidential: false,
+ });
+ wrapperConfidential = createComponent({
+ isLocked: false,
+ isConfidential: true,
+ });
+ wrapperLockedAndConfidential = createComponent({
+ isLocked: true,
+ isConfidential: true,
+ });
+ });
+
+ afterEach(() => {
+ wrapperLocked.destroy();
+ wrapperConfidential.destroy();
+ wrapperLockedAndConfidential.destroy();
+ });
+
+ it('renders confidential & locked messages with noteable "issue"', () => {
+ expect(findLockedBlock(wrapperLocked).text()).toContain('This issue is locked.');
+ expect(findConfidentialBlock(wrapperConfidential).text()).toContain(
+ 'This is a confidential issue.',
+ );
+ expect(findLockedAndConfidentialBlock(wrapperLockedAndConfidential).text()).toContain(
+ 'This issue is confidential and locked.',
+ );
+ });
+
+ it('renders confidential & locked messages with noteable "epic"', async () => {
+ wrapperLocked.setProps({
+ noteableType: 'Epic',
+ });
+ wrapperConfidential.setProps({
+ noteableType: 'Epic',
+ });
+ wrapperLockedAndConfidential.setProps({
+ noteableType: 'Epic',
+ });
+
+ await wrapperLocked.vm.$nextTick();
+ expect(findLockedBlock(wrapperLocked).text()).toContain('This epic is locked.');
+
+ await wrapperConfidential.vm.$nextTick();
+ expect(findConfidentialBlock(wrapperConfidential).text()).toContain(
+ 'This is a confidential epic.',
+ );
+
+ await wrapperLockedAndConfidential.vm.$nextTick();
+ expect(findLockedAndConfidentialBlock(wrapperLockedAndConfidential).text()).toContain(
+ 'This epic is confidential and locked.',
+ );
+ });
+
+ it('renders confidential & locked messages with noteable "merge request"', async () => {
+ wrapperLocked.setProps({
+ noteableType: 'MergeRequest',
+ });
+ wrapperConfidential.setProps({
+ noteableType: 'MergeRequest',
+ });
+ wrapperLockedAndConfidential.setProps({
+ noteableType: 'MergeRequest',
+ });
+
+ await wrapperLocked.vm.$nextTick();
+ expect(findLockedBlock(wrapperLocked).text()).toContain('This merge request is locked.');
+
+ await wrapperConfidential.vm.$nextTick();
+ expect(findConfidentialBlock(wrapperConfidential).text()).toContain(
+ 'This is a confidential merge request.',
+ );
+
+ await wrapperLockedAndConfidential.vm.$nextTick();
+ expect(findLockedAndConfidentialBlock(wrapperLockedAndConfidential).text()).toContain(
+ 'This merge request is confidential and locked.',
+ );
+ });
+ });
+});