diff options
author | Paul Slaughter <pslaughter@gitlab.com> | 2018-12-11 01:41:22 +0300 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2018-12-11 01:44:35 +0300 |
commit | 958aaebdde3255df1cfd45e1e75c7a0c19700a6c (patch) | |
tree | cdfd1055507869715afcda8b829617bafb0d0f3d /spec | |
parent | bea8e0626ddd18ad9a2059c65e9005632fb48921 (diff) |
Fix MR discussion counts being off
**What was the issue?**
Notes can be unresolved, but not resolvable. Without this, the
unresolvedDiscussionsCount was inflated.
**References**
https://gitlab.com/gitlab-org/gitlab-ce/issues/55138
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/notes/stores/mutation_spec.js | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/spec/javascripts/notes/stores/mutation_spec.js b/spec/javascripts/notes/stores/mutation_spec.js index 52cdc16353a..3fbae82f16c 100644 --- a/spec/javascripts/notes/stores/mutation_spec.js +++ b/spec/javascripts/notes/stores/mutation_spec.js @@ -9,6 +9,11 @@ import { individualNote, } 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('ADD_NEW_NOTE', () => { let state; @@ -449,49 +454,61 @@ describe('Notes Store mutations', () => { }); describe('UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS', () => { - it('updates resolvableDiscussionsCount', () => { - 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', () => { + it('with unresolvable discussions, updates state', () => { const state = { discussions: [ - { individual_note: false, resolvable: true, notes: [{ resolved: false }] }, - { individual_note: true, resolvable: true, notes: [{ resolved: false }] }, - { individual_note: false, resolvable: false, notes: [{ resolved: false }] }, + { individual_note: false, resolvable: true, notes: [UNRESOLVED_NOTE] }, + { individual_note: true, resolvable: true, notes: [UNRESOLVED_NOTE] }, + { individual_note: false, resolvable: false, notes: [UNRESOLVED_NOTE] }, ], - unresolvedDiscussionsCount: 0, }; 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 = { discussions: [ - { individual_note: false, resolvable: true, notes: [{ resolved: false }] }, - { individual_note: false, resolvable: true, notes: [{ resolved: false }] }, - { individual_note: false, resolvable: false, notes: [{ resolved: false }] }, + { + individual_note: 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); - expect(state.hasUnresolvedDiscussions).toBe(true); + expect(state).toEqual( + jasmine.objectContaining({ + resolvableDiscussionsCount: 4, + unresolvedDiscussionsCount: 2, + hasUnresolvedDiscussions: true, + }), + ); }); }); }); |