Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Component: Scheduled Banner', () => {
expect(showBanner()).toBeTruthy();
const parent = fixture.nativeElement.querySelector('[data-test-banner-parent]');
const link = fixture.nativeElement.querySelector('[data-test-banner-href]');
expect(parent.style.backgroundColor).toBe('rgb(18, 52, 86)'); // hex to rgb
expect(parent.style.backgroundColor).toBe('rgb(18, 52, 86)');
expect(link.getAttribute('href')).toBe('');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function initializeApplication() {
dsn,
environment: environment.production ? 'production' : 'development',
maxBreadcrumbs: 50,
sampleRate: 1.0, // error sample rate
sampleRate: 1.0,
integrations: [],
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AuthService {
window.location.href = loginUrl;
}

navigateToOrcidSingIn(): void {
navigateToOrcidSignIn(): void {
const loginUrl = `${this.casUrl}/login?${urlParam({
redirectOrcid: 'true',
service: `${this.webUrl}/login/?next=${encodeURIComponent(this.webUrl)}`,
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/auth/pages/sign-up/sign-up.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h2 class="text-center">{{ 'auth.signUp.title' | translate }}</h2>
[label]="'auth.signUp.social.orcid' | translate"
variant="text"
raised
(onClick)="navigateToOrcidSingIn()"
(onClick)="navigateToOrcidSignIn()"
>
<img ngSrc="assets/icons/colored/orcid.svg" alt="Orcid icon" height="20" width="20" />
</p-button>
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/auth/pages/sign-up/sign-up.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export class SignUpComponent implements OnInit {
});
}

navigateToOrcidSingIn(): void {
this.authService.navigateToOrcidSingIn();
navigateToOrcidSignIn(): void {
this.authService.navigateToOrcidSignIn();
}

navigateToInstitutionSingIn(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class CreateFolderDialogComponent {
validators: [
CustomValidators.requiredTrimmed(),
CustomValidators.forbiddenCharactersValidator(forbiddenFileNameCharacters),
CustomValidators.noPeriodAtEnd(),
],
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class RenameFileDialogComponent {
validators: [
CustomValidators.requiredTrimmed(),
CustomValidators.forbiddenCharactersValidator(forbiddenFileNameCharacters),
CustomValidators.noPeriodAtEnd(),
],
}),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Dependencies
import { Store } from '@ngxs/store';

import { TranslatePipe, TranslateService } from '@ngx-translate/core';
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/preprints/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { AdditionalInfoComponent } from './preprint-details/additional-info/addi
export { GeneralInformationComponent } from './preprint-details/general-information/general-information.component';
export { ModerationStatusBannerComponent } from './preprint-details/moderation-status-banner/moderation-status-banner.component';
export { PreprintFileSectionComponent } from './preprint-details/preprint-file-section/preprint-file-section.component';
export { ShareAndDownloadComponent } from './preprint-details/share-and-downlaod/share-and-download.component';
export { ShareAndDownloadComponent } from './preprint-details/share-and-download/share-and-download.component';
export { StatusBannerComponent } from './preprint-details/status-banner/status-banner.component';
export { PreprintProviderFooterComponent } from './preprint-provider-footer/preprint-provider-footer.component';
export { PreprintProviderHeroComponent } from './preprint-provider-hero/preprint-provider-hero.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
templateUrl: './preprint-warning-banner.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PreprintWarningBannerComponent {
//
}
export class PreprintWarningBannerComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AdditionalInfoComponent } from '@osf/features/preprints/components/prep
import { GeneralInformationComponent } from '@osf/features/preprints/components/preprint-details/general-information/general-information.component';
import { PreprintFileSectionComponent } from '@osf/features/preprints/components/preprint-details/preprint-file-section/preprint-file-section.component';
import { PreprintWarningBannerComponent } from '@osf/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component';
import { ShareAndDownloadComponent } from '@osf/features/preprints/components/preprint-details/share-and-downlaod/share-and-download.component';
import { ShareAndDownloadComponent } from '@osf/features/preprints/components/preprint-details/share-and-download/share-and-download.component';
import { ReviewsState } from '@osf/features/preprints/enums';
import { PreprintSelectors } from '@osf/features/preprints/store/preprint';
import { PreprintProvidersSelectors } from '@osf/features/preprints/store/preprint-providers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ describe.skip('Component: Configure Addon', () => {
},
paramMap: of(new Map()),
queryParamMap: of(new Map()),
// ... if you use `route.root`, add a dummy root too
root: {},
};

describe('addon present', () => {
beforeEach(async () => {
const mockRouter = {
url: '/project/abc123/addons/configure', // mock the actual URL used in your component
url: '/project/abc123/addons/configure',
navigate: jest.fn(),
getCurrentNavigation: jest.fn().mockReturnValue({
extras: {
Expand Down Expand Up @@ -141,7 +140,7 @@ describe.skip('Component: Configure Addon', () => {
describe('addon not-present', () => {
beforeEach(async () => {
const mockRouter = {
url: '/project/abc123/addons/configure', // mock the actual URL used in your component
url: '/project/abc123/addons/configure',
navigate: jest.fn(),
getCurrentNavigation: jest.fn().mockReturnValue({
extras: {
Expand Down
16 changes: 16 additions & 0 deletions src/app/shared/helpers/custom-form-validators.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,20 @@ export class CustomValidators {
return hasForbiddenCharacters ? { forbiddenCharacters: true } : null;
};
}

static noPeriodAtEnd(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const value = control.value;
if (!value || typeof value !== 'string') {
return null;
}

const trimmedValue = value.trim();
if (trimmedValue.endsWith('.')) {
return { periodAtEnd: true };
}

return null;
};
}
}
4 changes: 1 addition & 3 deletions src/app/shared/helpers/state-error.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { throwError } from 'rxjs';
import * as Sentry from '@sentry/angular';

export function handleSectionError<T>(ctx: StateContext<T>, section: keyof T, error: Error) {
// Report error to Sentry
Sentry.captureException(error, {
tags: {
'state.section': section.toString(),
feature: `state error section: ${section.toString()}`,
},
});

// Patch the state to update loading/submitting flags and set the error message
ctx.patchState({
[section]: {
...ctx.getState()[section],
Expand All @@ -22,6 +20,6 @@ export function handleSectionError<T>(ctx: StateContext<T>, section: keyof T, er
error: error.message,
},
} as Partial<T>);
// Rethrow the error as an observable

return throwError(() => error);
}
4 changes: 0 additions & 4 deletions src/app/shared/services/datacite/datacite.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ describe('DataciteService', () => {

service.logFileView(targetId, targetType).subscribe();

// First request: GET identifiers
const reqGet = httpMock.expectOne(`${apiDomainUrl}/v2/${targetType}/${targetId}/identifiers`);
expect(reqGet.request.method).toBe('GET');
reqGet.flush({
Expand All @@ -156,7 +155,6 @@ describe('DataciteService', () => {
],
});

// Second request: POST to datacite tracker
assertSuccess(httpMock, dataciteTrackerAddress, dataciteTrackerRepoId, doi, DataciteEvent.VIEW);
});

Expand All @@ -167,7 +165,6 @@ describe('DataciteService', () => {

service.logFileDownload(targetId, targetType).subscribe();

// First request: GET identifiers
const reqGet = httpMock.expectOne(`${apiDomainUrl}/v2/${targetType}/${targetId}/identifiers`);
expect(reqGet.request.method).toBe('GET');
reqGet.flush({
Expand All @@ -180,7 +177,6 @@ describe('DataciteService', () => {
],
});

// Second request: POST to datacite tracker
assertSuccess(httpMock, dataciteTrackerAddress, dataciteTrackerRepoId, doi, DataciteEvent.DOWNLOAD);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ describe('Service: Google File Picker Download', () => {
it('should emit error when script fails to load', (done) => {
const mockScriptElement: Partial<HTMLScriptElement> = {};

// Mock document
const mockDocument = {
createElement: jest.fn(() => mockScriptElement),
body: {
appendChild: jest.fn(() => {
// Simulate async error after appendChild
setTimeout(() => {
mockScriptElement.onerror?.(new Event('error'));
}, 0);
Expand All @@ -75,7 +73,6 @@ describe('Service: Google File Picker Download', () => {
querySelector: jest.fn(() => null),
};

// Re-instantiate service with mocked document
const service = new GoogleFilePickerDownloadService(mockDocument as unknown as Document);

service.loadScript().subscribe({
Expand All @@ -89,7 +86,6 @@ describe('Service: Google File Picker Download', () => {

describe('loadGapiModules', () => {
beforeEach(() => {
// Mock window.gapi
(globalThis as any).gapi = {
load: jest.fn(),
};
Expand Down Expand Up @@ -118,7 +114,7 @@ describe('Service: Google File Picker Download', () => {
});

const config = (globalThis.gapi.load as jest.Mock).mock.calls[0][1];
config.callback(); // simulate success
config.callback();
});

it('should emit error when GAPI fails to load', (done) => {
Expand All @@ -131,7 +127,7 @@ describe('Service: Google File Picker Download', () => {
});

const config = (globalThis.gapi.load as jest.Mock).mock.calls[0][1];
config.onerror(); // simulate failure
config.onerror();
});

it('should emit error on GAPI timeout', (done) => {
Expand All @@ -144,7 +140,7 @@ describe('Service: Google File Picker Download', () => {
});

const config = (globalThis.gapi.load as jest.Mock).mock.calls[0][1];
config.ontimeout(); // simulate timeout
config.ontimeout();
});
});
});
26 changes: 11 additions & 15 deletions src/app/shared/services/meta-tags.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export class MetaTagsService {

private readonly metaTagClass = 'osf-dynamic-meta';

// data from all active routed components that set meta tags
private metaTagStack: { metaTagsData: MetaTagsData; componentDestroyRef: DestroyRef }[] = [];

constructor(
Expand Down Expand Up @@ -83,12 +82,10 @@ export class MetaTagsService {
}

private metaTagStackWithout(destroyRefToRemove: DestroyRef) {
// get a copy of `this.metaTagStack` minus any entries with the given destroyRef
return this.metaTagStack.filter(({ componentDestroyRef }) => componentDestroyRef !== destroyRefToRemove);
}

private applyNearestMetaTags() {
// apply the meta tags for the nearest active route that called `updateMetaTags` (if any)
const nearest = this.metaTagStack.at(-1);
if (nearest) {
this.applyMetaTagsData(nearest.metaTagsData);
Expand All @@ -102,18 +99,17 @@ export class MetaTagsService {
const headTags = this.getHeadTags(combinedData);
of(metaTagsData.osfGuid)
.pipe(
switchMap(
(osfid) =>
osfid // with an osf id, try getting schema.org json-ld from backend
? this.getSchemaDotOrgJsonLdHeadTag(osfid).pipe(
tap((jsonLdHeadTag) => {
if (jsonLdHeadTag) {
headTags.push(jsonLdHeadTag);
}
}),
catchError(() => of(null)) // if it doesn't work, ignore and continue with given head tags
)
: of(null) // without osfid, continue with only given head tags
switchMap((osfid) =>
osfid
? this.getSchemaDotOrgJsonLdHeadTag(osfid).pipe(
tap((jsonLdHeadTag) => {
if (jsonLdHeadTag) {
headTags.push(jsonLdHeadTag);
}
}),
catchError(() => of(null))
)
: of(null)
),
tap(() => this.applyHeadTags(headTags)),
tap(() => this.dispatchZoteroEvent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe.skip('State: ActivityLogs', () => {
(httpMock: HttpTestingController) => {
store.dispatch(new GetRegistrationActivityLogs('reg500', 1, 10)).subscribe();

// loading true
expect(store.selectSnapshot((s: any) => s.activityLogs.activityLogs.isLoading)).toBe(true);

const req = httpMock.expectOne(buildRegistrationLogsUrl('reg500', 1, 10, environment.useValue.apiDomainUrl));
Expand Down
Loading