Skip to content

Commit 8ce47af

Browse files
committed
Add checks for properties that are mapped from stela to VO
The properties from stela for record(location, files) and for folder (location, thumbnailUrls, paths) did not have a check for null or undefined and if those properties are not present for some reason in the response, an error is generated that will block the whole flow in the browser. Issue: PER-10357 Fallback for share token
1 parent d36a210 commit 8ce47af

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

src/app/shared/services/api/folder.repo.spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@ import { HttpService } from '../http/http.service';
66
import { FolderRepo } from './folder.repo';
77

88
const emptyResponse = { items: [] };
9-
// The extra properties irrelevant to this test suite need to be there because
10-
// there are some checks missing in convertStelaFolderToFolderVO,
11-
// which will be fixed in the next commit
129
const fakeFolderResponse = {
1310
items: [
1411
{
1512
id: 42,
1613
name: 'Auth Folder',
17-
thumbnailUrls: { 200: 'test' },
18-
paths: { names: 'test' },
19-
location: { stelaLocation: { id: 13 } },
2014
},
2115
],
2216
};

src/app/shared/services/api/folder.repo.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ const convertStelaFolderToFolderVO = (stelaFolder: StelaFolder): FolderVO => {
115115
imageRatio: stelaFolder.imageRatio,
116116
type: stelaFolder.type,
117117
thumbStatus: stelaFolder.status,
118-
thumbURL200: stelaFolder.thumbnailUrls['200'],
119-
thumbURL500: stelaFolder.thumbnailUrls['500'],
120-
thumbURL1000: stelaFolder.thumbnailUrls['1000'],
121-
thumbURL2000: stelaFolder.thumbnailUrls['2000'],
118+
thumbURL200: stelaFolder.thumbnailUrls?.['200'],
119+
thumbURL500: stelaFolder.thumbnailUrls?.['500'],
120+
thumbURL1000: stelaFolder.thumbnailUrls?.['1000'],
121+
thumbURL2000: stelaFolder.thumbnailUrls?.['2000'],
122122
thumbDT: stelaFolder.displayTimestamp,
123-
thumbnail256: stelaFolder.thumbnailUrls['256'],
124-
thumbnail256CloudPath: stelaFolder.thumbnailUrls['256'],
123+
thumbnail256: stelaFolder.thumbnailUrls?.['256'],
124+
thumbnail256CloudPath: stelaFolder.thumbnailUrls?.['256'],
125125
status: stelaFolder.status,
126126
publicDT: stelaFolder.publicAt,
127127
parentFolderId: stelaFolder.parentFolder?.id,
128-
pathAsText: stelaFolder.paths.names,
128+
pathAsText: stelaFolder.paths?.names,
129129
ParentFolderVOs: [new FolderVO({ folderId: stelaFolder.parentFolder?.id })],
130130
ChildFolderVOs: childFolderVOs,
131131
RecordVOs: childRecordVOs,

src/app/shared/services/api/record.repo.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,8 @@ describe('RecordRepo', () => {
4646
// isolating the record.repo service functionality from other
4747
// dependencies would make the tests more reliable
4848
it('should use a V2 request to get records by id', fakeAsync(() => {
49-
// The extra properties irrelevant to this test suite need to be there because
50-
// there are some checks missing in convertStelaRecordToRecordVO, which will be
51-
// fixed in the next commit
5249
const fakeRecordVO = {
5350
recordId: 5,
54-
location: { stelaLocation: { id: 13 } },
55-
files: [],
5651
} as unknown as RecordVO;
5752

5853
const recordPromise = repo.get([fakeRecordVO]);

src/app/shared/services/api/record.repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const convertStelaSharetoShareVO = (stelaShare: StelaShare): ShareVO =>
158158
export const convertStelaLocationToLocnVOData = (
159159
stelaLocation: StelaLocation,
160160
): LocnVOData =>
161-
stelaLocation.id
161+
stelaLocation?.id
162162
? {
163163
...stelaLocation,
164164
locnId: Number.parseInt(stelaLocation.id, 10),
@@ -178,7 +178,7 @@ export const convertStelaRecordToRecordVO = (
178178
folder_linkId: Number.parseInt(stelaRecord.folderLinkId, 10),
179179
folder_linkType: stelaRecord.folderLinkType,
180180
LocnVO: convertStelaLocationToLocnVOData(stelaRecord.location),
181-
FileVOs: stelaRecord.files.map(convertStelaFileToPermanentFile),
181+
FileVOs: stelaRecord.files?.map(convertStelaFileToPermanentFile),
182182
createdDT: stelaRecord.createdAt,
183183
updatedDT: stelaRecord.updatedAt,
184184
locnId: stelaRecord.location?.id || null,

0 commit comments

Comments
 (0)