-
Notifications
You must be signed in to change notification settings - Fork 1
[PER-10357] Add fallback for stela folder calls #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4f84e5c
Add fallback for stela folder calls
aasandei-vsp af2a0b9
Add fallback for stela record calls
aasandei-vsp 26d0060
Disable test is data service test suite
aasandei-vsp ada626c
Add checks for properties that are mapped from stela to VO
aasandei-vsp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,132 @@ | ||
| // This suite doesn't actually have any tests, but for some reason the setup | ||
| // was causing the test bed to get contaminated. | ||
| // For this reason, I comment it out! There are other tests | ||
| // fully commented out, and we will be cleaning them up | ||
|
|
||
| // import { TestBed } from '@angular/core/testing'; | ||
| // import { | ||
| // HttpTestingController, | ||
| // provideHttpClientTesting, | ||
| // } from '@angular/common/http/testing'; | ||
|
|
||
| // import { HttpService } from '@shared/services/http/http.service'; | ||
| // import { FolderRepo } from '@shared/services/api/folder.repo'; | ||
| // import { | ||
| // provideHttpClient, | ||
| // withInterceptorsFromDi, | ||
| // } from '@angular/common/http'; | ||
|
|
||
| // describe('FolderRepo', () => { | ||
| // let repo: FolderRepo; | ||
| // let httpMock: HttpTestingController; | ||
|
|
||
| // beforeEach(() => { | ||
| // TestBed.configureTestingModule({ | ||
| // imports: [], | ||
| // providers: [ | ||
| // HttpService, | ||
| // provideHttpClient(withInterceptorsFromDi()), | ||
| // provideHttpClientTesting(), | ||
| // ], | ||
| // }); | ||
|
|
||
| // httpMock = TestBed.inject(HttpTestingController); | ||
| // }); | ||
|
|
||
| // afterEach(() => { | ||
| // httpMock.verify(); | ||
| // }); | ||
| // }); | ||
cecilia-donnelly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { TestBed } from '@angular/core/testing'; | ||
| import { FolderVO } from '@models/index'; | ||
| import { of } from 'rxjs'; | ||
| import { HttpV2Service } from '../http-v2/http-v2.service'; | ||
| import { HttpService } from '../http/http.service'; | ||
| import { FolderRepo } from './folder.repo'; | ||
|
|
||
| const emptyResponse = { items: [] }; | ||
| const fakeFolderResponse = { | ||
| items: [ | ||
| { | ||
| id: 42, | ||
| name: 'Auth Folder', | ||
| }, | ||
| ], | ||
| }; | ||
| const fakeChildrenResponse = { | ||
| items: [ | ||
| { | ||
| id: 300, | ||
| name: 'Auth Child', | ||
| thumbnailUrls: { 200: 'test' }, | ||
| paths: { names: 'test' }, | ||
| location: { stelaLocation: { id: 13 } }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| describe('Folder repo', () => { | ||
| let folderRepo: FolderRepo; | ||
| let httpSpy: jasmine.SpyObj<HttpService>; | ||
| let httpV2Spy: jasmine.SpyObj<HttpV2Service>; | ||
|
|
||
| beforeEach(() => { | ||
| httpSpy = jasmine.createSpyObj('HttpService', [ | ||
| 'sendRequest', | ||
| 'sendRequestPromise', | ||
| ]); | ||
| httpV2Spy = jasmine.createSpyObj('HttpV2Service', ['get']); | ||
|
|
||
| TestBed.configureTestingModule({ | ||
| providers: [ | ||
| FolderRepo, | ||
| { provide: HttpService, useValue: httpSpy }, | ||
| { provide: HttpV2Service, useValue: httpV2Spy }, | ||
| ], | ||
| }); | ||
|
|
||
| folderRepo = TestBed.inject(FolderRepo); | ||
| }); | ||
|
|
||
| it('should get folder with children using the auth token', async () => { | ||
| const mockFolderVO = { folderId: 42 } as FolderVO; | ||
|
|
||
| httpV2Spy.get.and.returnValues( | ||
| of([fakeFolderResponse]), | ||
| of([fakeChildrenResponse]), | ||
| ); | ||
|
|
||
| const result = await folderRepo.getWithChildren([mockFolderVO]); | ||
|
|
||
| expect(httpV2Spy.get).toHaveBeenCalledWith('v2/folder', { | ||
| folderIds: [42], | ||
| }); | ||
|
|
||
| expect(httpV2Spy.get).toHaveBeenCalledWith('v2/folder/42/children', { | ||
| pageSize: 99999999, | ||
| }); | ||
|
|
||
| expect(result.isSuccessful).toBeTrue(); | ||
| expect(result.Results[0].data[0].FolderVO).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should get folder with children using the share token', async () => { | ||
| const mockFolderVO = { folderId: 42 } as FolderVO; | ||
|
|
||
| httpV2Spy.get.and.returnValues( | ||
| of([fakeFolderResponse]), | ||
| of([fakeChildrenResponse]), | ||
| ); | ||
|
|
||
| const result = await folderRepo.getWithChildren( | ||
| [mockFolderVO], | ||
| 'share-token-123', | ||
| ); | ||
|
|
||
| expect(httpV2Spy.get).toHaveBeenCalledWith( | ||
| 'v2/folder', | ||
| { folderIds: [42] }, | ||
| null, | ||
| { authToken: false, shareToken: 'share-token-123' }, | ||
| ); | ||
|
|
||
| expect(httpV2Spy.get).toHaveBeenCalledWith( | ||
| 'v2/folder/42/children', | ||
| jasmine.anything(), | ||
| null, | ||
| { authToken: false, shareToken: 'share-token-123' }, | ||
| ); | ||
|
|
||
| expect(result.Results[0].data[0].FolderVO).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should get folder with children using fallback to auth token', async () => { | ||
| const mockFolderVO = { folderId: 42 } as FolderVO; | ||
|
|
||
| httpV2Spy.get.and.returnValues( | ||
| of([emptyResponse]), | ||
| of([fakeFolderResponse]), | ||
| of([emptyResponse]), | ||
| of([fakeChildrenResponse]), | ||
| ); | ||
|
|
||
| const result = await folderRepo.getWithChildren( | ||
| [mockFolderVO], | ||
| 'bad-share-token', | ||
| ); | ||
|
|
||
| expect(httpV2Spy.get).toHaveBeenCalledWith( | ||
| 'v2/folder', | ||
| { folderIds: [42] }, | ||
| null, | ||
| { authToken: false, shareToken: 'bad-share-token' }, | ||
| ); | ||
|
|
||
| expect(httpV2Spy.get).toHaveBeenCalledWith('v2/folder', { | ||
| folderIds: [42], | ||
| }); | ||
|
|
||
| expect(result.Results[0].data[0].FolderVO).toBeDefined(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.