Commit bfd6f3db authored by Paul Slaughter's avatar Paul Slaughter

Merge branch...

Merge branch '32898-remove-coupling-of-alldiscussions-in-the-issues-discussion-tab-counter' into 'master'

Remove coupling of allDiscussions in the issues discussion tab counter

See merge request gitlab-org/gitlab!20899
parents d9dea2e2 64d575f8
<script> <script>
import { __ } from '~/locale';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import { __ } from '~/locale';
import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility'; import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility';
import Flash from '../../flash'; import Flash from '../../flash';
import * as constants from '../constants'; import * as constants from '../constants';
...@@ -71,6 +71,9 @@ export default { ...@@ -71,6 +71,9 @@ export default {
'userCanReply', 'userCanReply',
'discussionTabCounter', 'discussionTabCounter',
]), ]),
discussionTabCounterText() {
return this.isLoading ? '' : this.discussionTabCounter;
},
noteableType() { noteableType() {
return this.noteableData.noteableType; return this.noteableData.noteableType;
}, },
...@@ -95,9 +98,9 @@ export default { ...@@ -95,9 +98,9 @@ export default {
this.fetchNotes(); this.fetchNotes();
} }
}, },
allDiscussions() { discussionTabCounterText(val) {
if (this.discussionsCount && !this.isLoading) { if (this.discussionsCount) {
this.discussionsCount.textContent = this.discussionTabCounter; this.discussionsCount.textContent = val;
} }
}, },
}, },
......
import $ from 'helpers/jquery'; import $ from 'helpers/jquery';
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import Vue from 'vue'; import Vue from 'vue';
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import { setTestTimeout } from 'helpers/timeout';
import axios from '~/lib/utils/axios_utils';
import NotesApp from '~/notes/components/notes_app.vue'; import NotesApp from '~/notes/components/notes_app.vue';
import service from '~/notes/services/notes_service'; import service from '~/notes/services/notes_service';
import createStore from '~/notes/stores'; import createStore from '~/notes/stores';
import '~/behaviors/markdown/render_gfm'; import '~/behaviors/markdown/render_gfm';
import { setTestTimeout } from 'helpers/timeout';
// TODO: use generated fixture (https://gitlab.com/gitlab-org/gitlab-foss/issues/62491) // TODO: use generated fixture (https://gitlab.com/gitlab-org/gitlab-foss/issues/62491)
import * as mockData from '../../notes/mock_data'; import * as mockData from '../../notes/mock_data';
import * as urlUtility from '~/lib/utils/url_utility'; import * as urlUtility from '~/lib/utils/url_utility';
...@@ -77,6 +77,8 @@ describe('note_app', () => { ...@@ -77,6 +77,8 @@ describe('note_app', () => {
describe('set data', () => { describe('set data', () => {
beforeEach(() => { beforeEach(() => {
setFixtures('<div class="js-discussions-count"></div>');
axiosMock.onAny().reply(200, []); axiosMock.onAny().reply(200, []);
wrapper = mountComponent(); wrapper = mountComponent();
return waitForDiscussionsRequest(); return waitForDiscussionsRequest();
...@@ -97,6 +99,10 @@ describe('note_app', () => { ...@@ -97,6 +99,10 @@ describe('note_app', () => {
it('should fetch discussions', () => { it('should fetch discussions', () => {
expect(store.state.discussions).toEqual([]); expect(store.state.discussions).toEqual([]);
}); });
it('updates discussions badge', () => {
expect(document.querySelector('.js-discussions-count').textContent).toEqual('0');
});
}); });
describe('render', () => { describe('render', () => {
...@@ -161,6 +167,7 @@ describe('note_app', () => { ...@@ -161,6 +167,7 @@ describe('note_app', () => {
describe('while fetching data', () => { describe('while fetching data', () => {
beforeEach(() => { beforeEach(() => {
setFixtures('<div class="js-discussions-count"></div>');
axiosMock.onAny().reply(200, []); axiosMock.onAny().reply(200, []);
wrapper = mountComponent(); wrapper = mountComponent();
}); });
...@@ -177,6 +184,10 @@ describe('note_app', () => { ...@@ -177,6 +184,10 @@ describe('note_app', () => {
'Write a comment or drag your files here…', 'Write a comment or drag your files here…',
); );
}); });
it('should not update discussions badge (it should be blank)', () => {
expect(document.querySelector('.js-discussions-count').textContent).toEqual('');
});
}); });
describe('update note', () => { describe('update note', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment