Skip to content

Commit 5bbf4b8

Browse files
nsemetsNazar690dinlvkdnrrromchIkvolodyayakubovskyy
authored
Fix/develop conflicts (#332)
* Fix/improvements (#319) * fix(meetings): fixed meetings small issues * fix(tooltips): added tooltips * fix(table): updated sorting * fix(settings): fixed update project * fix(bookmarks): updated bookmarks * fix(my-registrations): fixed my registrations * fix(developer-apps): fixed developer apps * fix(settings): updated tokens and notifications * fix(translation): removed dot * fix(info-icon): updated info icon translate * fix(profile-settings): fixed profile settings * fix(test): updated tests * fix(settings): updated settings * fix(user-emails): updated adding emails to user account * fix(tests): updated tests * fix(clean-up): clean up * fix(models): updated models * fix(models): updated region and license models * fix(styles): moved styles from assets * fix(test): fixed institution loading and test for view only link * fix(analytics): added check if is public * fix(analytics): updated analytics feature * fix(analytics): show message when data loaded * fix(view-only-links): updated view only links * fix(view only links): added shared components * fix(tests): fixed tests * fix(unit-tests): updated jest config * fix(view-only-links): update view only links for components * fix(create-view-link): added logic for uncheck --------- Co-authored-by: Nazar Semets <nazar690@gmail.com> * Test/387 settings page tokens (#318) * test(tokens): added new tests * test(tokens): added new unit tests * test(tokens): fixed tests and jest.config * test(tokens): fixed pr comments * Fix - Search (#286) * feat(search): added generic search component * feat(search): improved search for institutions * feat(search): remove unused files * feat(search): fixed some issues * fix(search): removed comments * fix(profile): renamed it to profile * fix(updates): updates * fix(branding): Minor fixed regarding provider hero for preprints and registry * refactor(search-results-container): Encapsulated some logic, reduced duplication * refactor(search-results-container): Encapsulated tabs logic * refactor(search): Refactored partly search section for preprints and profile * refactor(search): Refactored search logic for global, institutions page, registrations page search * refactor(search): Refactored search logic for global, institutions page, registrations page search * refactor(search): Refactored search logic for profile * feat(profile): Implemented my-profile and user/:id pages * refactor(preprint-provider-discover): Removed search section that uses old approach * refactor(search): Create shared component that encapsulates search logic and reused across the app * refactor(shared-search): Extracted state model. Reduced duplications. Fixed IndexValueSearch filters * refactor(search): Using ResourceType instead of ResourceTab. Fixed params for index-value-search * refactor(search-models): Cleaned up models - renamed files, moved models to appropriate locations * refactor(index-card-search): Refactored models * fix(resource-card): Fixed resource-card component * fix(resource-card-secondary-metadata): Fixed resource-card component * fix(search): Fixed PR comments and conflicts after merge * refactor(search): Renamed OsfSearch- to GlobalSearch- * fix(unit-tests): fixed unit tests --------- Co-authored-by: volodyayakubovskyy <vyakubovskyy477@gmail.com> Co-authored-by: nsemets <nsemets@exoft.net> * Fix/557 missing tooltip (#320) * fix(tooltip): added tooltip to next button * fix(emails): fixed emails bug * chore(test-env): added test env (#321) * Chore/test docs added more docs and updated docs in the ever expanding evolution. (#309) * chore(testing-docs): incremental update to the testing docs * chore(diagram): updated the ngx application diagram * chore(indexes): added indexes to all files * docs(updates): added new docs and explanations * chore(pr-updates): updated the files based on pr feedback * Fix/registrations (#326) * fix(settings): updated settings routes * fix(registry-links): updated registry links * fix(registration): updated components, resource and links * fix(wiki): updated wiki * fix(redirect-link): removed it (#327) * [ENG-8505] Finished adding the GFP to the files page (#325) * feat(eng-8505): Added the initial google drive button * feat(eng-8505): add the accountid with tests * feat(more-tests): updated tests * feat(eng-8505): updates for tests * feat(eng-8505): finishing updates for the google file picker * chore(test fixes): updates to broken tests * chore(pr updates): add updates based on pr feedback and more docs --------- Co-authored-by: Nazar Semets <nazar690@gmail.com> Co-authored-by: dinlvkdn <104976612+dinlvkdn@users.noreply.github.com> Co-authored-by: rrromchIk <90086332+rrromchIk@users.noreply.github.com> Co-authored-by: volodyayakubovskyy <vyakubovskyy477@gmail.com> Co-authored-by: Lord Business <113387478+bp-cos@users.noreply.github.com>
1 parent 0fed748 commit 5bbf4b8

File tree

70 files changed

+1132
-456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1132
-456
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module.exports = tseslint.config(
112112
},
113113
},
114114
{
115-
files: ['**/*.spec.ts'],
115+
files: ['**/*.spec.ts', 'src/testing/**/*.ts'],
116116
rules: {
117117
'@typescript-eslint/no-explicit-any': 'off',
118118
'@typescript-eslint/no-empty-function': 'off',

jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ module.exports = {
6666
'<rootDir>/src/app/features/project/addons/components/connect-configured-addon/',
6767
'<rootDir>/src/app/features/project/addons/components/disconnect-addon-modal/',
6868
'<rootDir>/src/app/features/project/addons/components/confirm-account-connection-modal/',
69-
'<rootDir>/src/app/features/files/',
69+
'<rootDir>/src/app/features/files/components',
70+
'<rootDir>/src/app/features/files/pages/community-metadata',
71+
'<rootDir>/src/app/features/files/pages/file-detail',
7072
'<rootDir>/src/app/features/my-projects/',
7173
'<rootDir>/src/app/features/project/analytics/',
7274
'<rootDir>/src/app/features/project/contributors/',

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { GetEmails, UserEmailsSelectors } from '@core/store/user-emails';
1515
import { ConfirmEmailComponent } from '@shared/components';
1616

1717
import { FullScreenLoaderComponent, ToastComponent } from './shared/components';
18-
import { MetaTagsService } from './shared/services/meta-tags.service';
18+
import { MetaTagsService } from './shared/services';
1919

2020
@Component({
2121
selector: 'osf-root',

src/app/core/constants/nav-items.constant.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,15 @@ export const MENU_ITEMS: MenuItem[] = [
353353
visible: false,
354354
items: [
355355
{
356-
id: 'settings-profile-settings',
357-
routerLink: '/settings/profile-settings',
356+
id: 'settings-profile',
357+
routerLink: '/settings/profile',
358358
label: 'navigation.profileSettings',
359359
visible: true,
360360
routerLinkActiveOptions: { exact: true },
361361
},
362362
{
363-
id: 'settings-account-settings',
364-
routerLink: '/settings/account-settings',
363+
id: 'settings-account',
364+
routerLink: '/settings/account',
365365
label: 'navigation.accountSettings',
366366
visible: true,
367367
routerLinkActiveOptions: { exact: true },

src/app/features/files/pages/files/files.component.html

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
<div class="flex flex-column align-items-center w-full gap-2 sm:flex-row md:w-max">
5050
<p-button
51-
[disabled]="fileIsUploading() || isFilesLoading()"
51+
[disabled]="isButtonDisabled()"
5252
outlined
5353
raised
5454
(onClick)="downloadFolder()"
@@ -61,7 +61,7 @@
6161

6262
@if (!isViewOnly() && !hasViewOnly()) {
6363
<p-button
64-
[disabled]="fileIsUploading() || isFilesLoading()"
64+
[disabled]="isButtonDisabled()"
6565
outlined
6666
raised
6767
severity="success"
@@ -72,7 +72,7 @@
7272
</p-button>
7373

7474
<p-button
75-
[disabled]="fileIsUploading() || isFilesLoading()"
75+
[disabled]="isButtonDisabled()"
7676
outlined
7777
raised
7878
severity="success"
@@ -81,6 +81,25 @@
8181
(onClick)="fileInput.click()"
8282
>
8383
</p-button>
84+
85+
@if (isGoogleDrive()) {
86+
<p-button
87+
[disabled]="isButtonDisabled()"
88+
outlined
89+
raised
90+
severity="success"
91+
[icon]="'fa-brands fa-google-plus-g'"
92+
[label]="'files.actions.addFromDrive' | translate"
93+
(onClick)="googleFilePickerComponent()?.createPicker()"
94+
>
95+
</p-button>
96+
<osf-google-file-picker
97+
[rootFolder]="selectedRootFolder()"
98+
[accountId]="accountId()"
99+
[isFolderPicker]="false"
100+
[handleFolderSelection]="updateFilesList"
101+
></osf-google-file-picker>
102+
}
84103
}
85104
<input #fileInput type="file" class="hidden" (change)="onFileSelected($event)" />
86105
</div>
Lines changed: 167 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,186 @@
1-
import { MockComponent } from 'ng-mocks';
1+
import { Store } from '@ngxs/store';
22

3+
import { TranslatePipe } from '@ngx-translate/core';
4+
import { MockProvider } from 'ng-mocks';
5+
6+
import { Button } from 'primeng/button';
7+
import { Dialog } from 'primeng/dialog';
8+
import { DialogService } from 'primeng/dynamicdialog';
9+
import { TableModule } from 'primeng/table';
10+
11+
import { signal } from '@angular/core';
312
import { ComponentFixture, TestBed } from '@angular/core/testing';
13+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
14+
import { ActivatedRoute } from '@angular/router';
415

5-
import { SubHeaderComponent } from '@osf/shared/components';
16+
import {
17+
FilesTreeComponent,
18+
FormSelectComponent,
19+
LoadingSpinnerComponent,
20+
SearchInputComponent,
21+
SubHeaderComponent,
22+
ViewOnlyLinkMessageComponent,
23+
} from '@osf/shared/components';
24+
import { GoogleFilePickerComponent } from '@osf/shared/components/addons/folder-selector/google-file-picker/google-file-picker.component';
25+
import { OsfFile } from '@osf/shared/models';
26+
import { CustomConfirmationService, FilesService } from '@osf/shared/services';
27+
28+
import { FilesSelectors } from '../../store';
629

730
import { FilesComponent } from './files.component';
831

9-
describe('FilesComponent', () => {
32+
import { getConfiguredAddonsMappedData } from '@testing/data/addons/addons.configured.data';
33+
import { getNodeFilesMappedData } from '@testing/data/files/node.data';
34+
import { OSFTestingModule } from '@testing/osf.testing.module';
35+
import { MockComponentWithSignal } from '@testing/providers/component-provider.mock';
36+
import { provideMockStore } from '@testing/providers/store-provider.mock';
37+
38+
describe('Component: Files', () => {
1039
let component: FilesComponent;
1140
let fixture: ComponentFixture<FilesComponent>;
41+
const currentFolderSignal = signal(getNodeFilesMappedData(0));
1242

1343
beforeEach(async () => {
44+
jest.clearAllMocks();
1445
await TestBed.configureTestingModule({
15-
imports: [FilesComponent, MockComponent(SubHeaderComponent)],
16-
}).compileComponents();
46+
imports: [
47+
OSFTestingModule,
48+
FilesComponent,
49+
Button,
50+
Dialog,
51+
FormSelectComponent,
52+
FormsModule,
53+
GoogleFilePickerComponent,
54+
LoadingSpinnerComponent,
55+
ReactiveFormsModule,
56+
SearchInputComponent,
57+
SubHeaderComponent,
58+
TableModule,
59+
TranslatePipe,
60+
ViewOnlyLinkMessageComponent,
61+
],
62+
providers: [
63+
FilesService,
64+
MockProvider(ActivatedRoute),
65+
MockProvider(CustomConfirmationService),
66+
67+
DialogService,
68+
provideMockStore({
69+
signals: [
70+
{
71+
selector: FilesSelectors.getRootFolders,
72+
value: getNodeFilesMappedData(),
73+
},
74+
{
75+
selector: FilesSelectors.getCurrentFolder,
76+
value: currentFolderSignal(),
77+
},
78+
{
79+
selector: FilesSelectors.getConfiguredStorageAddons,
80+
value: getConfiguredAddonsMappedData(),
81+
},
82+
],
83+
}),
84+
],
85+
})
86+
.overrideComponent(FilesComponent, {
87+
remove: {
88+
imports: [FilesTreeComponent],
89+
},
90+
add: {
91+
imports: [
92+
MockComponentWithSignal('osf-files-tree', [
93+
'files',
94+
'currentFolder',
95+
'isLoading',
96+
'actions',
97+
'viewOnly',
98+
'viewOnlyDownloadable',
99+
'resourceId',
100+
'provider',
101+
]),
102+
],
103+
},
104+
})
105+
.compileComponents();
17106

18107
fixture = TestBed.createComponent(FilesComponent);
19108
component = fixture.componentInstance;
20109
fixture.detectChanges();
21110
});
22111

23-
it('should create', () => {
24-
expect(component).toBeTruthy();
112+
describe('CurrentRootFolder effect', () => {
113+
it('should handle the initial effects', () => {
114+
expect(component.currentRootFolder()?.folder.name).toBe('osfstorage');
115+
expect(component.isGoogleDrive()).toBeFalsy();
116+
expect(component.accountId()).toBeFalsy();
117+
expect(component.selectedRootFolder()).toEqual(Object({}));
118+
});
119+
120+
it('should handle changing the folder to googledrive', () => {
121+
component.currentRootFolder.set(
122+
Object({
123+
label: 'label',
124+
folder: Object({
125+
name: 'Google Drive',
126+
provider: 'googledrive',
127+
}),
128+
})
129+
);
130+
131+
fixture.detectChanges();
132+
133+
expect(component.currentRootFolder()?.folder.name).toBe('Google Drive');
134+
expect(component.isGoogleDrive()).toBeTruthy();
135+
expect(component.accountId()).toBe('62ed6dd7-f7b7-4003-b7b4-855789c1f991');
136+
expect(component.selectedRootFolder()).toEqual(
137+
Object({
138+
itemId: '0AIl0aR4C9JAFUk9PVA',
139+
})
140+
);
141+
});
142+
});
143+
144+
describe('updateFilesList', () => {
145+
it('should handle the updateFilesList with a filesLink', () => {
146+
let results!: string;
147+
const store = TestBed.inject(Store);
148+
const dispatchSpy = jest.spyOn(store, 'dispatch');
149+
dispatchSpy.mockClear();
150+
jest.spyOn(component.filesTreeActions, 'setFilesIsLoading');
151+
component.updateFilesList().subscribe({
152+
next: (result) => {
153+
results = result as any;
154+
},
155+
});
156+
157+
expect(results).toBeTruthy();
158+
159+
expect(component.filesTreeActions.setFilesIsLoading).toHaveBeenCalledWith(true);
160+
expect(dispatchSpy).toHaveBeenCalledWith({
161+
filesLink: 'https://api.staging4.osf.io/v2/nodes/xgrm4/files/osfstorage/',
162+
});
163+
});
164+
165+
it('should handle the updateFilesList without a filesLink', () => {
166+
let results!: string;
167+
const currentFolder = currentFolderSignal() as OsfFile;
168+
currentFolder.relationships.filesLink = '';
169+
currentFolderSignal.set(currentFolder);
170+
const store = TestBed.inject(Store);
171+
const dispatchSpy = jest.spyOn(store, 'dispatch');
172+
dispatchSpy.mockClear();
173+
jest.spyOn(component.filesTreeActions, 'setFilesIsLoading');
174+
component.updateFilesList().subscribe({
175+
next: (result) => {
176+
results = result as any;
177+
},
178+
});
179+
180+
expect(results).toBeUndefined();
181+
182+
expect(component.filesTreeActions.setFilesIsLoading).not.toHaveBeenCalled();
183+
expect(dispatchSpy).not.toHaveBeenCalled();
184+
});
25185
});
26186
});

0 commit comments

Comments
 (0)