-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat-NAC-317-use-angular-material-instead-of-hyland-ui-…
…elements' of https://github.com/nuxeo/nuxeo-admin-console-ui into feat-NAC-317-use-angular-material-instead-of-hyland-ui-elements
- Loading branch information
Showing
47 changed files
with
280 additions
and
409 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -6,47 +6,48 @@ import { PersistenceService } from "./shared/services/persistence.service"; | |
import { WarningComponent } from "./features/warning/warning.component"; | ||
import { CommonService } from "./shared/services/common.service"; | ||
import { EventEmitter } from "@angular/core"; | ||
import { provideMockStore, MockStore } from '@ngrx/store/testing'; | ||
import { AuthStateInterface } from './auth/types/authState.interface'; | ||
import { UserInterface } from './shared/types/user.interface'; | ||
import { APP_CONSTANTS } from './app.constants'; | ||
import { By } from '@angular/platform-browser'; | ||
import { authActions } from './auth/store/actions'; | ||
import { ActivatedRoute, RouterModule } from '@angular/router'; | ||
import { provideMockStore, MockStore } from "@ngrx/store/testing"; | ||
import { AuthStateInterface } from "./auth/types/authState.interface"; | ||
import { UserInterface } from "./shared/types/user.interface"; | ||
import { APP_CONSTANTS } from "./app.constants"; | ||
import { By } from "@angular/platform-browser"; | ||
import { authActions } from "./auth/store/actions"; | ||
import { ActivatedRoute, RouterModule } from "@angular/router"; | ||
import { BaseLayoutModule } from "./layouts/base-layout/base-layout.module"; | ||
import { BaseLayoutComponent } from "./layouts/base-layout/components/base-layout.component" | ||
import { BaseLayoutComponent } from "./layouts/base-layout/components/base-layout.component"; | ||
import { HeaderBarComponent } from "./layouts/header-bar/header-bar.component"; | ||
import { MenuBarComponent } from "./layouts/menu-bar/menu-bar.component"; | ||
import { MatListModule } from '@angular/material/list'; | ||
import { MatSidenavModule } from '@angular/material/sidenav'; | ||
import { MatToolbarModule } from '@angular/material/toolbar'; | ||
import { MatListModule } from "@angular/material/list"; | ||
import { MatSidenavModule } from "@angular/material/sidenav"; | ||
import { MatToolbarModule } from "@angular/material/toolbar"; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
|
||
describe("AppComponent", () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent>; | ||
const mockActivatedRoute = { | ||
snapshot: { | ||
paramMap: { | ||
get: () => 'Administrator' | ||
} | ||
} | ||
get: () => "Administrator", | ||
}, | ||
}, | ||
}; | ||
|
||
let store: MockStore<{ auth: AuthStateInterface }>; | ||
const initialAuthState: AuthStateInterface = { | ||
isSubmitting: false, | ||
currentUser: { | ||
id: 'Administrator', | ||
id: "Administrator", | ||
isAdministrator: true, | ||
properties: { | ||
firstName: "nco", | ||
lastName: "admin", | ||
email: "[email protected]", | ||
username: "Administrator" | ||
} | ||
username: "Administrator", | ||
}, | ||
} as UserInterface, | ||
isLoading: false, | ||
validationErrors: null | ||
validationErrors: null, | ||
}; | ||
|
||
class persistenceServiceStub { | ||
|
@@ -63,11 +64,24 @@ describe("AppComponent", () => { | |
loadApp = new EventEmitter<boolean>(); | ||
} | ||
|
||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [AppComponent, BaseLayoutComponent, HeaderBarComponent, MenuBarComponent], | ||
imports: [CommonModule, MatDialogModule, BaseLayoutModule, RouterModule, MatToolbarModule, MatListModule, MatSidenavModule], | ||
declarations: [ | ||
AppComponent, | ||
BaseLayoutComponent, | ||
HeaderBarComponent, | ||
MenuBarComponent, | ||
], | ||
imports: [ | ||
CommonModule, | ||
MatDialogModule, | ||
BaseLayoutModule, | ||
RouterModule, | ||
MatToolbarModule, | ||
MatListModule, | ||
MatSidenavModule, | ||
MatIconModule, | ||
], | ||
providers: [ | ||
{ provide: PersistenceService, useClass: persistenceServiceStub }, | ||
{ provide: CommonService, useClass: commonServiceStub }, | ||
|
@@ -87,10 +101,12 @@ describe("AppComponent", () => { | |
|
||
describe("ngOnInit", () => { | ||
it("should initiate JS client and subscribe to currentUser$", () => { | ||
spyOn(component['nuxeoJsClientService'], 'initiateJSClient'); | ||
spyOn(component.currentUser$, 'subscribe').and.callThrough(); | ||
spyOn(component["nuxeoJsClientService"], "initiateJSClient"); | ||
spyOn(component.currentUser$, "subscribe").and.callThrough(); | ||
component.ngOnInit(); | ||
expect(component['nuxeoJsClientService'].initiateJSClient).toHaveBeenCalledWith(component.baseUrl); | ||
expect( | ||
component["nuxeoJsClientService"].initiateJSClient | ||
).toHaveBeenCalledWith(component.baseUrl); | ||
expect(component.currentUser$.subscribe).toHaveBeenCalled(); | ||
}); | ||
|
||
|
@@ -99,7 +115,10 @@ describe("AppComponent", () => { | |
spyOn(component.persistenceService, "get").and.returnValue(null); | ||
component.ngOnInit(); | ||
expect(component.persistenceService.get).toHaveBeenCalled(); | ||
expect(component.dialogService.open).toHaveBeenCalledWith(WarningComponent, { disableClose: true }); | ||
expect(component.dialogService.open).toHaveBeenCalledWith( | ||
WarningComponent, | ||
{ disableClose: true, hasBackdrop: true } | ||
); | ||
}); | ||
|
||
it("should not open the warning dialog if warning preference is set", () => { | ||
|
@@ -139,33 +158,39 @@ describe("AppComponent", () => { | |
expect(store.dispatch).toHaveBeenCalledWith(authActions.signOut()); | ||
}); | ||
}); | ||
|
||
|
||
describe("DOM", () => { | ||
it("should display unauthorized message if currentUser is not administrator", () => { | ||
store.setState({ | ||
auth: { | ||
...initialAuthState, currentUser: { | ||
id: 'Administrator', isAdministrator: false, properties: { | ||
...initialAuthState, | ||
currentUser: { | ||
id: "Administrator", | ||
isAdministrator: false, | ||
properties: { | ||
firstName: "nco", | ||
lastName: "admin", | ||
email: "[email protected]", | ||
username: "Administrator" | ||
} | ||
} | ||
} | ||
username: "Administrator", | ||
}, | ||
}, | ||
}, | ||
}); | ||
fixture.detectChanges(); | ||
const unauthorizedMessage = fixture.debugElement.query(By.css('.unauthorized')); | ||
const unauthorizedMessage = fixture.debugElement.query( | ||
By.css(".unauthorized") | ||
); | ||
expect(unauthorizedMessage).toBeTruthy(); | ||
expect(unauthorizedMessage.nativeElement.textContent).toContain(APP_CONSTANTS.UNAUTHORIZED_MESSAGE); | ||
expect(unauthorizedMessage.nativeElement.textContent).toContain( | ||
APP_CONSTANTS.UNAUTHORIZED_MESSAGE | ||
); | ||
}); | ||
|
||
it("should display base-layout if loadApp is true and currentUser is administrator", () => { | ||
component.loadApp = true; | ||
fixture.detectChanges(); | ||
const baseLayout = fixture.debugElement.query(By.css('base-layout')); | ||
const baseLayout = fixture.debugElement.query(By.css("base-layout")); | ||
expect(baseLayout).toBeTruthy(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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
3 changes: 1 addition & 2 deletions
3
...-action-monitoring/bulk-action-monitoring-form/bulk-action-monitoring-form.component.html
This file contains 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 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 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 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 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 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 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 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 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.