-
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.
NXP-32573: added unit tests, refactored code, fixed warning box focus…
… issue & added .npmrc
- Loading branch information
1 parent
a6fcc68
commit e3a2704
Showing
122 changed files
with
963 additions
and
476 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@hylandsoftware:registry=https://npm.pkg.github.com | ||
//npm.pkg.github.com/:_authToken=ghp_your_authenticated_token | ||
registry=https://registry.npmjs.org/ |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# nuxeo-admin-console-ui | ||
Nuxeo Admin console UI is a standard base web application for Nuxeo admin useres. | ||
Nuxeo Admin console UI is a standard base web application for Nuxeo admin users. | ||
|
||
# Note | ||
Replace ghp_your_authenticated_token in .npmrc file with your Github token. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = function(config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-coverage-istanbul-reporter'), | ||
require('@angular-devkit/build-angular/plugins/karma') | ||
], | ||
client: { | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
coverageIstanbulReporter: { | ||
dir: require('path').join(__dirname, './coverage/admin-console'), | ||
reports: ['html', 'lcovonly', 'text-summary'], | ||
fixWebpackSourcePaths: true | ||
}, | ||
reporters: ['progress', 'coverage-istanbul'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: false, | ||
restartOnFileChange: true | ||
}); | ||
}; |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<base-layout *ngIf="loadApp"></base-layout> |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { MatDialogModule } from "@angular/material/dialog"; | ||
import { BaseLayoutComponent } from "./layouts/base-layout/components/base-layout.component"; | ||
import { AppComponent } from "./app.component"; | ||
import { | ||
ComponentFixture, | ||
ComponentFixtureAutoDetect, | ||
TestBed, | ||
} from "@angular/core/testing"; | ||
import { CommonModule } from "@angular/common"; | ||
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"; | ||
|
||
describe("AppComponent", () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent>; | ||
class persistenceServiceStub { | ||
get() { | ||
return null; | ||
} | ||
set() {} | ||
} | ||
|
||
class adminCommonServiceStub { | ||
loadApp = new EventEmitter<Boolean>(); | ||
} | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [AppComponent, BaseLayoutComponent], | ||
imports: [CommonModule, MatDialogModule], | ||
providers: [ | ||
{ provide: ComponentFixtureAutoDetect, useValue: true }, | ||
{ provide: PersistenceService, useClass: persistenceServiceStub }, | ||
{ provide: CommonService, useClass: adminCommonServiceStub }, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AppComponent); | ||
component = fixture.componentInstance; | ||
}); | ||
|
||
it("should test if component is created", () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
describe("test warning preference", () => { | ||
beforeEach(() => { | ||
spyOn(component.dialogService, "open"); | ||
}); | ||
it("should open the warning dialog if warning preference is not set", () => { | ||
spyOn(component.persistenceService, "get").and.returnValue(null); | ||
let loadAppSubscriptionSpy = spyOn( | ||
component.adminCommonService.loadApp, | ||
"subscribe" | ||
).and.callThrough(); | ||
component.ngOnInit(); | ||
expect(component.persistenceService.get).toHaveBeenCalled(); | ||
expect(component.dialogService.open).toHaveBeenCalledWith( | ||
WarningComponent, | ||
{ | ||
disableClose: true, | ||
} | ||
); | ||
expect(loadAppSubscriptionSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should not open the warning dialog if warning preference is set", () => { | ||
spyOn(component.persistenceService, "get").and.returnValue("true"); | ||
component.ngOnInit(); | ||
expect(component.persistenceService.get).toHaveBeenCalled(); | ||
expect(component.dialogService.open).not.toHaveBeenCalled(); | ||
expect(component.loadApp).toEqual(true); | ||
}); | ||
}); | ||
|
||
it("should set loadApp to true or false based on the value received from the service subscription", () => { | ||
component.ngOnInit(); | ||
component.adminCommonService.loadApp.emit(true); | ||
expect(component.loadApp).toBe(true); | ||
component.ngOnInit(); | ||
component.adminCommonService.loadApp.emit(false); | ||
expect(component.loadApp).toBe(false); | ||
}); | ||
|
||
it("should remove theloadAppSubscription when component is destroyed", () => { | ||
spyOn(component.loadAppSubscription, "unsubscribe"); | ||
component.ngOnDestroy(); | ||
expect(component.loadAppSubscription.unsubscribe).toHaveBeenCalled(); | ||
}); | ||
}); |
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.