Skip to content

Commit 745480b

Browse files
Add tests for the edge cases around SHARER.
Filter out participants from the sharing table if they are only included by type and don't have SHARER.
1 parent 2be53a5 commit 745480b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/web/components/SharingPermission/SharingPermissionsTable.spec.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,15 @@ describe('SharingPermissionsTable', () => {
2929

3030
expect(screen.getByText(/Delete Permissions/i)).toBeInTheDocument();
3131
});
32+
33+
it('shows participants included by site ID even if they are not a valid sharing target', async () => {
34+
render(<SharedWithParticipants />);
35+
expect(await screen.findByText('No SHARER and explicitly included')).toBeInTheDocument();
36+
});
37+
38+
it('does not show participants that are included by group if they are not a valid sharing target', async () => {
39+
render(<SharedWithParticipants />);
40+
await screen.findByText('Site 1');
41+
expect(screen.queryByText('No SHARER and not explicitly included')).not.toBeInTheDocument();
42+
});
3243
});

src/web/components/SharingPermission/SharingPermissionsTable.stories.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ const response: SharingSiteDTO[] = [
4646
id: 15,
4747
canBeSharedWith: true,
4848
},
49+
{
50+
name: 'No SHARER and not explicitly included',
51+
clientTypes: ['DATA_PROVIDER'],
52+
id: 16,
53+
canBeSharedWith: false,
54+
},
55+
{
56+
name: 'No SHARER and explicitly included',
57+
clientTypes: ['DATA_PROVIDER'],
58+
id: 17,
59+
canBeSharedWith: false,
60+
},
4961
];
5062
const Template: ComponentStory<typeof SharingPermissionsTable> = (args) => (
5163
<TestAllSitesListProvider response={response}>
@@ -55,7 +67,7 @@ const Template: ComponentStory<typeof SharingPermissionsTable> = (args) => (
5567

5668
export const SharedWithParticipants = Template.bind({});
5769
SharedWithParticipants.args = {
58-
sharedSiteIds: [10, 11, 12, 14, 15],
70+
sharedSiteIds: [10, 11, 12, 14, 15, 17],
5971
sharedTypes: ['DSP', 'DATA_PROVIDER'],
6072
onDeleteSharingPermission: () => Promise.resolve(),
6173
};

src/web/components/SharingPermission/SharingPermissionsTable.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export function SharingPermissionsTable({
230230
const { sites, isLoading } = useAllSitesList();
231231
const getSharingParticipants: () => SharingSiteWithSource[] = () => {
232232
return sites!
233+
.filter((p) => p.canBeSharedWith || sharedSiteIds.includes(p.id))
233234
.map((p) => {
234235
const maybeManualArray: (typeof MANUALLY_ADDED)[] = sharedSiteIds.includes(p.id)
235236
? [MANUALLY_ADDED]

0 commit comments

Comments
 (0)