Commit 1f6c33f2 authored by Hannah Stepanek's avatar Hannah Stepanek

Fix bug where direct linked group is duplicated

Do not add the direct-linked group to featuredGroups if it is already
present. This happens when a group is direct-linked to but the group
is already scoped to the page so the direct-linked group shows up twice.
parent e25c5101
...@@ -213,9 +213,11 @@ function groups( ...@@ -213,9 +213,11 @@ function groups(
} }
return Promise.all(groupApiRequests).then( return Promise.all(groupApiRequests).then(
([myGroups, featuredGroups, token, selectedGroup]) => [ ([myGroups, featuredGroups, token, selectedGroup]) => [
// Don't add the selectedGroup if it's already in the featuredGroups.
combineGroups( combineGroups(
myGroups, myGroups,
selectedGroup !== undefined selectedGroup !== undefined &&
!featuredGroups.some(g => g.id === selectedGroup.id)
? featuredGroups.concat([selectedGroup]) ? featuredGroups.concat([selectedGroup])
: featuredGroups, : featuredGroups,
documentUri documentUri
......
...@@ -230,6 +230,25 @@ describe('groups', function() { ...@@ -230,6 +230,25 @@ describe('groups', function() {
}); });
}); });
// TODO: Add a de-dup test for the direct-linked annotation.
it('does not duplicate groups if the direct-linked group is also a featured group', () => {
const svc = service();
// Set the direct-linked group to dummyGroups[0].
fakeSettings.group = dummyGroups[0].id;
fakeApi.group.read.returns(Promise.resolve(dummyGroups[0]));
// Include the dummyGroups[0] in the featured groups.
fakeApi.profile.groups.read.returns(Promise.resolve([]));
fakeApi.groups.list.returns(Promise.resolve([dummyGroups[0]]));
return svc.load().then(groups => {
const groupIds = groups.map(g => g.id);
assert.deepEqual(groupIds, [fakeSettings.group]);
});
});
it('combines groups from all 3 endpoints if there is a selectedGroup', () => { it('combines groups from all 3 endpoints if there is a selectedGroup', () => {
const svc = service(); const svc = service();
......
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