mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
code cleanup (#3210)
* code cleanup * rollback changes * remove dead code * remove debug app config * cleanup unused locales * no-unused-vars rule * test fixes and cleanup * remove unnecessary translate modules
This commit is contained in:
@@ -23,14 +23,12 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { OpenInAppComponent } from './open-in-app.component';
|
||||
import { initialState, LibTestingModule } from '../../testing/lib-testing-module';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { SharedModule } from '@alfresco/aca-shared';
|
||||
|
||||
describe('OpenInAppComponent', () => {
|
||||
@@ -44,7 +42,7 @@ describe('OpenInAppComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [LibTestingModule, TranslateModule, SharedModule.forRoot(), MatIconModule, MatIconTestingModule],
|
||||
imports: [LibTestingModule, SharedModule.forRoot(), MatIconTestingModule],
|
||||
providers: [
|
||||
provideMockStore({ initialState }),
|
||||
{ provide: MAT_DIALOG_DATA, useValue: { redirectUrl: 'mockRedirectUrl' } },
|
||||
@@ -59,14 +57,13 @@ describe('OpenInAppComponent', () => {
|
||||
|
||||
it('should redirect to app when click on `Open in App` button` ', async () => {
|
||||
let currentLocation: string | string[];
|
||||
const windowStub: Window & typeof globalThis = {
|
||||
component.window = {
|
||||
location: {
|
||||
set href(value: string | string[]) {
|
||||
currentLocation = value;
|
||||
}
|
||||
}
|
||||
} as Window & typeof globalThis;
|
||||
component.window = windowStub;
|
||||
const saveButton = fixture.debugElement.query(By.css('[data-automation-id="open-in-app-button"]')).nativeElement;
|
||||
saveButton.dispatchEvent(new Event('click'));
|
||||
fixture.detectChanges();
|
||||
|
@@ -35,7 +35,7 @@ export interface OpenInAppDialogOptions {
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class OpenInAppComponent {
|
||||
private redirectUrl: string;
|
||||
private readonly redirectUrl: string;
|
||||
public window: Window & typeof globalThis = window;
|
||||
|
||||
constructor(
|
||||
|
@@ -27,7 +27,6 @@ import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { UserPreferencesService, AppConfigService, PaginationComponent, PaginationModel, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { initialState, LibTestingModule } from '../testing/lib-testing-module';
|
||||
import { SharedDirectivesModule } from './shared.directives.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
|
||||
describe('PaginationDirective', () => {
|
||||
@@ -39,7 +38,7 @@ describe('PaginationDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), LibTestingModule, SharedDirectivesModule, CoreTestingModule],
|
||||
imports: [LibTestingModule, SharedDirectivesModule, CoreTestingModule],
|
||||
providers: [provideMockStore({ initialState })]
|
||||
});
|
||||
|
||||
|
@@ -33,7 +33,7 @@ describe('AppSharedRuleGuard', () => {
|
||||
const guard = new AppSharedRuleGuard(store);
|
||||
const emittedSpy = jasmine.createSpy('emitted');
|
||||
|
||||
guard.canActivate({} as any).subscribe(emittedSpy);
|
||||
guard.canActivate().subscribe(emittedSpy);
|
||||
expect(emittedSpy).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('AppSharedRuleGuard', () => {
|
||||
const guard = new AppSharedRuleGuard(store);
|
||||
const emittedSpy = jasmine.createSpy('emitted');
|
||||
|
||||
guard.canActivateChild({} as any).subscribe(emittedSpy);
|
||||
guard.canActivateChild().subscribe(emittedSpy);
|
||||
expect(emittedSpy).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
|
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanActivate, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { CanActivate } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore, isQuickShareEnabled } from '@alfresco/aca-shared/store';
|
||||
@@ -38,11 +38,11 @@ export class AppSharedRuleGuard implements CanActivate {
|
||||
this.isQuickShareEnabled$ = store.select(isQuickShareEnabled);
|
||||
}
|
||||
|
||||
canActivate(_: ActivatedRouteSnapshot): Observable<boolean> {
|
||||
canActivate(): Observable<boolean> {
|
||||
return this.isQuickShareEnabled$;
|
||||
}
|
||||
|
||||
canActivateChild(route: ActivatedRouteSnapshot): Observable<boolean> {
|
||||
return this.canActivate(route);
|
||||
canActivateChild(): Observable<boolean> {
|
||||
return this.canActivate();
|
||||
}
|
||||
}
|
||||
|
@@ -142,11 +142,9 @@ export class AppService implements OnDestroy {
|
||||
|
||||
const { router } = this;
|
||||
|
||||
this.router.events
|
||||
.pipe(filter((event) => event instanceof ActivationEnd && event.snapshot.children.length === 0))
|
||||
.subscribe((_event: ActivationEnd) => {
|
||||
this.store.dispatch(new SetCurrentUrlAction(router.url));
|
||||
});
|
||||
this.router.events.pipe(filter((event) => event instanceof ActivationEnd && event.snapshot.children.length === 0)).subscribe(() => {
|
||||
this.store.dispatch(new SetCurrentUrlAction(router.url));
|
||||
});
|
||||
|
||||
this.router.events.pipe(filter((event) => event instanceof NavigationStart)).subscribe(() => {
|
||||
this.store.dispatch(new ResetSelectionAction());
|
||||
|
@@ -87,6 +87,7 @@ export const initialState = {
|
||||
}),
|
||||
PipeModule
|
||||
],
|
||||
exports: [TranslateModule],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: TranslationService, useClass: TranslationMock }
|
||||
|
Reference in New Issue
Block a user