Skip to content

Commit

Permalink
fix: displaying not owned organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidgil authored Jan 28, 2022
1 parent 4029c61 commit eb6bd9b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/app/state/governance/organization/organization.effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,42 @@ describe('OrganizationEffects', () => {
});
})
);
it(
'should filter not owned organizations',
waitForAsync(() => {
actions$.next(
OrganizationActions.setHistory({
element: { namespace: 'test' } as any,
})
);
organizationServiceSpy.getHistory.and.returnValue(
of({
namespace: 'test',
owner: '123',
subOrgs: [
{ namespace: 'suborg', owner: '123' },
{ namespace: 'suborg2', owner: '321' },
],
})
);

effects.updateHistory$.subscribe((resultAction) => {
expect(resultAction).toEqual(
OrganizationActions.setHistorySuccess({
history: [{ namespace: 'suborg', owner: '123' } as any],
element: {
namespace: 'test',
owner: '123',
subOrgs: [
{ namespace: 'suborg', owner: '123' },
{ namespace: 'suborg2', owner: '321' },
],
} as any,
})
);
});
})
);

it(
'should dispatch failure action',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class OrganizationEffects {
map((org) => {
if (org.subOrgs && org.subOrgs.length) {
return OrganizationActions.setHistorySuccess({
history: org.subOrgs as OrganizationProvider[],
history: org.subOrgs.filter(
(item) => item.owner === org.owner
) as OrganizationProvider[],
element: org as OrganizationProvider,
});
} else {
Expand Down

0 comments on commit eb6bd9b

Please sign in to comment.