Commit 7df7ecc3 authored by 🤖 GitLab Bot 🤖's avatar 🤖 GitLab Bot 🤖

Merge branch 'ce-to-ee-2018-12-11' into 'master'

CE upstream - 2018-12-11 08:21 UTC

See merge request gitlab-org/gitlab-ee!8782
parents cab246ad 253d9814
...@@ -246,7 +246,7 @@ export default { ...@@ -246,7 +246,7 @@ export default {
discussion => discussion =>
!discussion.individual_note && !discussion.individual_note &&
discussion.resolvable && discussion.resolvable &&
discussion.notes.some(note => !note.resolved), discussion.notes.some(note => note.resolvable && !note.resolved),
).length; ).length;
state.hasUnresolvedDiscussions = state.unresolvedDiscussionsCount > 1; state.hasUnresolvedDiscussions = state.unresolvedDiscussionsCount > 1;
}, },
......
---
title: Fix MR resolved discussion counts being too low
merge_request: 23710
author:
type: fixed
...@@ -9,6 +9,11 @@ import { ...@@ -9,6 +9,11 @@ import {
individualNote, individualNote,
} from '../mock_data'; } from '../mock_data';
const RESOLVED_NOTE = { resolvable: true, resolved: true };
const UNRESOLVED_NOTE = { resolvable: true, resolved: false };
const SYSTEM_NOTE = { resolvable: false, resolved: false };
const WEIRD_NOTE = { resolvable: false, resolved: true };
describe('Notes Store mutations', () => { describe('Notes Store mutations', () => {
describe('ADD_NEW_NOTE', () => { describe('ADD_NEW_NOTE', () => {
let state; let state;
...@@ -449,49 +454,61 @@ describe('Notes Store mutations', () => { ...@@ -449,49 +454,61 @@ describe('Notes Store mutations', () => {
}); });
describe('UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS', () => { describe('UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS', () => {
it('updates resolvableDiscussionsCount', () => { it('with unresolvable discussions, updates state', () => {
const state = {
discussions: [
{ individual_note: false, resolvable: true, notes: [] },
{ individual_note: true, resolvable: true, notes: [] },
{ individual_note: false, resolvable: false, notes: [] },
],
resolvableDiscussionsCount: 0,
};
mutations.UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS(state);
expect(state.resolvableDiscussionsCount).toBe(1);
});
it('updates unresolvedDiscussionsCount', () => {
const state = { const state = {
discussions: [ discussions: [
{ individual_note: false, resolvable: true, notes: [{ resolved: false }] }, { individual_note: false, resolvable: true, notes: [UNRESOLVED_NOTE] },
{ individual_note: true, resolvable: true, notes: [{ resolved: false }] }, { individual_note: true, resolvable: true, notes: [UNRESOLVED_NOTE] },
{ individual_note: false, resolvable: false, notes: [{ resolved: false }] }, { individual_note: false, resolvable: false, notes: [UNRESOLVED_NOTE] },
], ],
unresolvedDiscussionsCount: 0,
}; };
mutations.UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS(state); mutations.UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS(state);
expect(state.unresolvedDiscussionsCount).toBe(1); expect(state).toEqual(
jasmine.objectContaining({
resolvableDiscussionsCount: 1,
unresolvedDiscussionsCount: 1,
hasUnresolvedDiscussions: false,
}),
);
}); });
it('updates hasUnresolvedDiscussions', () => { it('with resolvable discussions, updates state', () => {
const state = { const state = {
discussions: [ discussions: [
{ individual_note: false, resolvable: true, notes: [{ resolved: false }] }, {
{ individual_note: false, resolvable: true, notes: [{ resolved: false }] }, individual_note: false,
{ individual_note: false, resolvable: false, notes: [{ resolved: false }] }, resolvable: true,
notes: [RESOLVED_NOTE, SYSTEM_NOTE, RESOLVED_NOTE],
},
{
individual_note: false,
resolvable: true,
notes: [RESOLVED_NOTE, SYSTEM_NOTE, WEIRD_NOTE],
},
{
individual_note: false,
resolvable: true,
notes: [SYSTEM_NOTE, RESOLVED_NOTE, WEIRD_NOTE, UNRESOLVED_NOTE],
},
{
individual_note: false,
resolvable: true,
notes: [UNRESOLVED_NOTE],
},
], ],
hasUnresolvedDiscussions: 0,
}; };
mutations.UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS(state); mutations.UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS(state);
expect(state.hasUnresolvedDiscussions).toBe(true); expect(state).toEqual(
jasmine.objectContaining({
resolvableDiscussionsCount: 4,
unresolvedDiscussionsCount: 2,
hasUnresolvedDiscussions: true,
}),
);
}); });
}); });
}); });
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