Commit b705f103 authored by Hannah Stepanek's avatar Hannah Stepanek

Use scopes.enforced to determine selectability

Previously, isScopedToUri took into account enforcement but now
it does not. Thus, isSelectable logic based on scopes.enforced
and isScopedToUri was added to the group-list-section controller
to determine whether a group should be out of scope/not selectable.
parent aebce2f1
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
function GroupListSectionController() { function GroupListSectionController() {
this.isSelectable = function(groupId) { this.isSelectable = function(groupId) {
const group = this.sectionGroups.find(g => g.id === groupId); const group = this.sectionGroups.find(g => g.id === groupId);
return !this.disableOosGroupSelection || group.isScopedToUri; return (
!this.disableOosGroupSelection ||
!group.scopes.enforced ||
group.isScopedToUri
);
}; };
} }
......
...@@ -31,26 +31,49 @@ describe('groupListSection', () => { ...@@ -31,26 +31,49 @@ describe('groupListSection', () => {
{ {
description: 'always returns true if disableOosGroupSelection is false', description: 'always returns true if disableOosGroupSelection is false',
fakeDisableOosGroupSelection: false, fakeDisableOosGroupSelection: false,
scopesEnforced: true,
expectedIsSelectable: [true, true], expectedIsSelectable: [true, true],
}, },
{ {
description: description:
'always returns true if disableOosGroupSelection is undefined', 'always returns true if disableOosGroupSelection is undefined',
fakeDisableOosGroupSelection: undefined, fakeDisableOosGroupSelection: undefined,
scopesEnforced: true,
expectedIsSelectable: [true, true], expectedIsSelectable: [true, true],
}, },
{ {
description: description:
'returns false if disableOosGroupSelection is true and group is out of scope', 'returns false if disableOosGroupSelection is true and group is out of scope',
fakeDisableOosGroupSelection: true, fakeDisableOosGroupSelection: true,
scopesEnforced: true,
expectedIsSelectable: [true, false], expectedIsSelectable: [true, false],
}, },
{
description:
'returns true if disableOosGroupSelection is true and group is out of scope but not enforced',
fakeDisableOosGroupSelection: true,
scopesEnforced: false,
expectedIsSelectable: [true, true],
},
].forEach( ].forEach(
({ description, fakeDisableOosGroupSelection, expectedIsSelectable }) => { ({
description,
fakeDisableOosGroupSelection,
scopesEnforced,
expectedIsSelectable,
}) => {
it(description, () => { it(description, () => {
const fakeSectionGroups = [ const fakeSectionGroups = [
{ isScopedToUri: true, id: 0 }, {
{ isScopedToUri: false, id: 1 }, isScopedToUri: true,
scopes: { enforced: scopesEnforced },
id: 0,
},
{
isScopedToUri: false,
scopes: { enforced: scopesEnforced },
id: 1,
},
]; ];
const element = createGroupListSection( const element = createGroupListSection(
......
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