-
Notifications
You must be signed in to change notification settings - Fork 16
[ENG-8505] Finished adding the GFP to the files page #325
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
7 commits
Select commit
Hold shift + click to select a range
e8abedb
feat(eng-8505): Added the initial google drive button
bp-cos 1a454f5
feat(eng-8505): add the accountid with tests
bp-cos 2cd0e2b
feat(more-tests): updated tests
bp-cos 037768e
feat(eng-8505): updates for tests
bp-cos 724016f
feat(eng-8505): finishing updates for the google file picker
bp-cos 93519a1
chore(test fixes): updates to broken tests
bp-cos 7fb5a84
chore(pr updates): add updates based on pr feedback and more docs
bp-cos 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
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
174 changes: 167 additions & 7 deletions
174
src/app/features/files/pages/files/files.component.spec.ts
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,26 +1,186 @@ | ||
import { MockComponent } from 'ng-mocks'; | ||
import { Store } from '@ngxs/store'; | ||
|
||
import { TranslatePipe } from '@ngx-translate/core'; | ||
import { MockProvider } from 'ng-mocks'; | ||
|
||
import { Button } from 'primeng/button'; | ||
import { Dialog } from 'primeng/dialog'; | ||
import { DialogService } from 'primeng/dynamicdialog'; | ||
import { TableModule } from 'primeng/table'; | ||
|
||
import { signal } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { SubHeaderComponent } from '@osf/shared/components'; | ||
import { | ||
FilesTreeComponent, | ||
FormSelectComponent, | ||
LoadingSpinnerComponent, | ||
SearchInputComponent, | ||
SubHeaderComponent, | ||
ViewOnlyLinkMessageComponent, | ||
} from '@osf/shared/components'; | ||
import { GoogleFilePickerComponent } from '@osf/shared/components/addons/folder-selector/google-file-picker/google-file-picker.component'; | ||
import { OsfFile } from '@osf/shared/models'; | ||
import { CustomConfirmationService, FilesService } from '@osf/shared/services'; | ||
|
||
import { FilesSelectors } from '../../store'; | ||
|
||
import { FilesComponent } from './files.component'; | ||
|
||
describe('FilesComponent', () => { | ||
import { getConfiguredAddonsMappedData } from '@testing/data/addons/addons.configured.data'; | ||
import { getNodeFilesMappedData } from '@testing/data/files/node.data'; | ||
import { OSFTestingModule } from '@testing/osf.testing.module'; | ||
import { MockComponentWithSignal } from '@testing/providers/component-provider.mock'; | ||
import { provideMockStore } from '@testing/providers/store-provider.mock'; | ||
|
||
describe('Component: Files', () => { | ||
let component: FilesComponent; | ||
let fixture: ComponentFixture<FilesComponent>; | ||
const currentFolderSignal = signal(getNodeFilesMappedData(0)); | ||
|
||
beforeEach(async () => { | ||
jest.clearAllMocks(); | ||
await TestBed.configureTestingModule({ | ||
imports: [FilesComponent, MockComponent(SubHeaderComponent)], | ||
}).compileComponents(); | ||
imports: [ | ||
OSFTestingModule, | ||
FilesComponent, | ||
Button, | ||
Dialog, | ||
FormSelectComponent, | ||
FormsModule, | ||
GoogleFilePickerComponent, | ||
LoadingSpinnerComponent, | ||
ReactiveFormsModule, | ||
SearchInputComponent, | ||
SubHeaderComponent, | ||
TableModule, | ||
TranslatePipe, | ||
ViewOnlyLinkMessageComponent, | ||
], | ||
providers: [ | ||
FilesService, | ||
MockProvider(ActivatedRoute), | ||
MockProvider(CustomConfirmationService), | ||
|
||
DialogService, | ||
provideMockStore({ | ||
signals: [ | ||
{ | ||
selector: FilesSelectors.getRootFolders, | ||
value: getNodeFilesMappedData(), | ||
}, | ||
{ | ||
selector: FilesSelectors.getCurrentFolder, | ||
value: currentFolderSignal(), | ||
}, | ||
{ | ||
selector: FilesSelectors.getConfiguredStorageAddons, | ||
value: getConfiguredAddonsMappedData(), | ||
}, | ||
], | ||
}), | ||
], | ||
}) | ||
.overrideComponent(FilesComponent, { | ||
remove: { | ||
imports: [FilesTreeComponent], | ||
}, | ||
add: { | ||
imports: [ | ||
MockComponentWithSignal('osf-files-tree', [ | ||
'files', | ||
'currentFolder', | ||
'isLoading', | ||
'actions', | ||
'viewOnly', | ||
'viewOnlyDownloadable', | ||
'resourceId', | ||
'provider', | ||
]), | ||
], | ||
}, | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(FilesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
describe('CurrentRootFolder effect', () => { | ||
it('should handle the initial effects', () => { | ||
expect(component.currentRootFolder()?.folder.name).toBe('osfstorage'); | ||
expect(component.isGoogleDrive()).toBeFalsy(); | ||
expect(component.accountId()).toBeFalsy(); | ||
expect(component.selectedRootFolder()).toEqual(Object({})); | ||
}); | ||
|
||
it('should handle changing the folder to googledrive', () => { | ||
component.currentRootFolder.set( | ||
Object({ | ||
label: 'label', | ||
folder: Object({ | ||
name: 'Google Drive', | ||
provider: 'googledrive', | ||
}), | ||
}) | ||
); | ||
|
||
fixture.detectChanges(); | ||
|
||
expect(component.currentRootFolder()?.folder.name).toBe('Google Drive'); | ||
expect(component.isGoogleDrive()).toBeTruthy(); | ||
expect(component.accountId()).toBe('62ed6dd7-f7b7-4003-b7b4-855789c1f991'); | ||
expect(component.selectedRootFolder()).toEqual( | ||
Object({ | ||
itemId: '0AIl0aR4C9JAFUk9PVA', | ||
}) | ||
); | ||
}); | ||
}); | ||
|
||
describe('updateFilesList', () => { | ||
it('should handle the updateFilesList with a filesLink', () => { | ||
let results!: string; | ||
const store = TestBed.inject(Store); | ||
const dispatchSpy = jest.spyOn(store, 'dispatch'); | ||
dispatchSpy.mockClear(); | ||
jest.spyOn(component.filesTreeActions, 'setFilesIsLoading'); | ||
component.updateFilesList().subscribe({ | ||
next: (result) => { | ||
results = result as any; | ||
}, | ||
}); | ||
|
||
expect(results).toBeTruthy(); | ||
|
||
expect(component.filesTreeActions.setFilesIsLoading).toHaveBeenCalledWith(true); | ||
expect(dispatchSpy).toHaveBeenCalledWith({ | ||
filesLink: 'https://api.staging4.osf.io/v2/nodes/xgrm4/files/osfstorage/', | ||
}); | ||
}); | ||
|
||
it('should handle the updateFilesList without a filesLink', () => { | ||
let results!: string; | ||
const currentFolder = currentFolderSignal() as OsfFile; | ||
currentFolder.relationships.filesLink = ''; | ||
currentFolderSignal.set(currentFolder); | ||
const store = TestBed.inject(Store); | ||
const dispatchSpy = jest.spyOn(store, 'dispatch'); | ||
dispatchSpy.mockClear(); | ||
jest.spyOn(component.filesTreeActions, 'setFilesIsLoading'); | ||
component.updateFilesList().subscribe({ | ||
next: (result) => { | ||
results = result as any; | ||
}, | ||
}); | ||
|
||
expect(results).toBeUndefined(); | ||
|
||
expect(component.filesTreeActions.setFilesIsLoading).not.toHaveBeenCalled(); | ||
expect(dispatchSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
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.