Commit da85d5fe authored by Meina Zhou's avatar Meina Zhou
Browse files

fix harbor portal unit test and set thresholds


Signed-off-by: default avatarMeina Zhou <meinaz@vmware.com>
parent dfa9d61e
......@@ -48,10 +48,10 @@ module.exports = function (config) {
emitWarning: false, // set to `true` to not fail the test command when thresholds are not met
// thresholds for all files
global: {
statements: 10,
lines: 10,
branches: 0,
functions: 10
statements: 47,
branches: 18,
functions: 27,
lines: 47
},
// thresholds per file
each: {
......
......@@ -48,10 +48,10 @@ module.exports = function (config) {
emitWarning: false, // set to `true` to not fail the test command when thresholds are not met
// thresholds for all files
global: {
statements: 10,
lines: 10,
branches: 0,
functions: 10
statements: 37,
branches: 20,
functions: 28,
lines: 36
},
// thresholds per file
each: {
......
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { AccountSettingsModalService } from './account-settings-modal-service.service';
describe('AccountSettingsModalServiceService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
beforeEach(() => TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
],
providers: [
AccountSettingsModalService
]
}));
it('should be created', () => {
const service: AccountSettingsModalService = TestBed.get(AccountSettingsModalService);
......
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, APP_INITIALIZER, LOCALE_ID } from '@angular/core';
import { NgModule, APP_INITIALIZER, LOCALE_ID, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AppComponent } from './app.component';
import { BaseModule } from './base/base.module';
......@@ -88,6 +88,9 @@ export function getCurrentLanguage(translateService: TranslateService) {
},
{provide: LOCALE_ID, useValue: "en-US"}
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
bootstrap: [AppComponent]
})
export class AppModule {}
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { DevCenterComponent } from './dev-center.component';
describe('DevCenterComponent', () => {
......@@ -8,9 +9,16 @@ describe('DevCenterComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DevCenterComponent ]
declarations: [DevCenterComponent],
imports: [
HttpClientTestingModule,
TranslateModule.forRoot()
],
providers: [
TranslateService
],
})
.compileComponents();
.compileComponents();
}));
beforeEach(() => {
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { SessionService } from "../shared/session.service";
import { GcPageComponent } from './gc-page.component';
describe('GcPageComponent', () => {
let component: GcPageComponent;
let fixture: ComponentFixture<GcPageComponent>;
let fakeSessionService = {
getCurrentUser: function () {
return { has_admin_role: true };
}
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ GcPageComponent ]
declarations: [GcPageComponent],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
imports: [
ClarityModule,
TranslateModule.forRoot()
],
providers: [
TranslateService,
{ provide: SessionService, useValue: fakeSessionService }
]
})
.compileComponents();
.compileComponents();
}));
beforeEach(() => {
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { GroupService } from "../group.service";
import { MessageHandlerService } from "./../../shared/message-handler/message-handler.service";
import { SessionService } from "./../../shared/session.service";
import { UserGroup } from "./../group";
import { AppConfigService } from "../../app-config.service";
import { AddGroupModalComponent } from './add-group-modal.component';
describe('AddGroupModalComponent', () => {
let component: AddGroupModalComponent;
let fixture: ComponentFixture<AddGroupModalComponent>;
let fakeSessionService = {
getCurrentUser: function () {
return { has_admin_role: true };
}
};
let fakeGroupService = null;
let fakeAppConfigService = {
isLdapMode: function () {
return true;
},
isHttpAuthMode: function () {
return false;
},
isOidcMode: function () {
return false;
}
};
let fakeMessageHandlerService = null;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddGroupModalComponent ]
declarations: [AddGroupModalComponent],
imports: [
ClarityModule,
FormsModule,
TranslateModule.forRoot()
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
ChangeDetectorRef,
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService },
{ provide: SessionService, useValue: fakeSessionService },
{ provide: AppConfigService, useValue: fakeAppConfigService },
{ provide: GroupService, useValue: fakeGroupService },
]
})
.compileComponents();
.compileComponents();
}));
beforeEach(() => {
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { GroupComponent } from './group.component';
import { ClarityModule } from '@clr/angular';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { OperationService } from "@harbor/ui";
import { SessionService } from "./../shared/session.service";
import { GroupService } from "./group.service";
import { of } from "rxjs";
import { ConfirmationDialogService } from "./../shared/confirmation-dialog/confirmation-dialog.service";
import { MessageHandlerService } from '../shared/message-handler/message-handler.service';
import { AppConfigService } from '../app-config.service';
describe('GroupComponent', () => {
let component: GroupComponent;
let fixture: ComponentFixture<GroupComponent>;
let fakeMessageHandlerService = null;
let fakeOperationService = null;
let fakeGroupService = {
getUserGroups: function () {
return of([{
group_name: ''
}, {
group_name: 'abc'
}]);
}
};
let fakeConfirmationDialogService = {
confirmationConfirm$: of({
state: 1,
source: 2
})
};
let fakeSessionService = {
currentUser: {
has_admin_role: true
}
};
let fakeAppConfigService = {
isLdapMode: function () {
return true;
}
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ GroupComponent ]
declarations: [GroupComponent],
imports: [
ClarityModule,
FormsModule,
TranslateModule.forRoot()
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
TranslateService,
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService },
{ provide: OperationService, useValue: fakeOperationService },
{ provide: GroupService, useValue: fakeGroupService },
{ provide: ConfirmationDialogService, useValue: fakeConfirmationDialogService },
{ provide: SessionService, useValue: fakeSessionService },
{ provide: AppConfigService, useValue: fakeAppConfigService }
]
})
.compileComponents();
.compileComponents();
}));
beforeEach(() => {
......
import { TestBed, inject } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { GroupService } from './group.service';
describe('GroupService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [GroupService]
providers: [GroupService],
imports: [
HttpClientTestingModule
]
});
});
......
......@@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { LicenseComponent } from './license.component';
fdescribe('LicenseComponent', () => {
describe('LicenseComponent', () => {
let component: LicenseComponent;
let fixture: ComponentFixture<LicenseComponent>;
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { OidcOnboardService } from './oidc-onboard.service';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { Router, ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { OidcOnboardComponent } from './oidc-onboard.component';
describe('OidcOnboardComponent', () => {
let component: OidcOnboardComponent;
let fixture: ComponentFixture<OidcOnboardComponent>;
let fakeOidcOnboardService = null;
let fakeRouter = null;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ OidcOnboardComponent ]
})
.compileComponents();
declarations: [OidcOnboardComponent],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
imports: [
ClarityModule,
FormsModule,
ReactiveFormsModule,
TranslateModule.forRoot()
],
providers: [
TranslateService,
{ provide: OidcOnboardService, useValue: fakeOidcOnboardService },
{ provide: Router, useValue: fakeRouter },
{
provide: ActivatedRoute, useValue: {
queryParams: of({
view: 'abc',
objectId: 'ddd',
actionUid: 'ddd',
targets: '',
locale: ''
})
}
}
]
}).compileComponents();
}));
beforeEach(() => {
......
import { TestBed } from '@angular/core/testing';
import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { OidcOnboardService } from './oidc-onboard.service';
describe('OidcOnboardService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
beforeEach(() => TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
],
providers: [
OidcOnboardService
]
}));
it('should be created', () => {
const service: OidcOnboardService = TestBed.get(OidcOnboardService);
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ClarityModule } from '@clr/angular';
import { ActivatedRoute, Router } from "@angular/router";
import { SessionService } from './../../../shared/session.service';
import { of } from 'rxjs';
import { HelmChartDetailComponent } from './chart-detail.component';
describe('ChartDetailComponent', () => {
let component: HelmChartDetailComponent;
let fixture: ComponentFixture<HelmChartDetailComponent>;
let fakeRouter = null;
let fakeSessionService = {
getCurrentUser: function () {
return { has_admin_role: true };
}
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HelmChartDetailComponent ]
})
.compileComponents();
declarations: [HelmChartDetailComponent],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
imports: [
ClarityModule,
TranslateModule.forRoot()
],
providers: [
{
provide: ActivatedRoute, useValue: {
paramMap: of({ get: (key) => 'value' }),
snapshot: {
params: { id: 1, chart: 'chart', version: 1.0 },
data: {
projectResolver: {
role_name: 'admin'
}
}
}
}
},
{ provide: Router, useValue: fakeRouter },
{ provide: SessionService, useValue: fakeSessionService },
TranslateService
]
}).compileComponents();
}));
beforeEach(() => {
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ActivatedRoute } from '@angular/router';
import { Router } from '@angular/router';
import { of } from 'rxjs';
import { SessionService } from './../../../shared/session.service';
import { ListChartVersionsComponent } from './list-chart-versions.component';
describe('ListChartVersionsComponent', () => {
let component: ListChartVersionsComponent;
let fixture: ComponentFixture<ListChartVersionsComponent>;
let fakeSessionService = {
getCurrentUser: function () {
return "admin";
}
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListChartVersionsComponent ]
declarations: [ListChartVersionsComponent],
imports: [
ClarityModule,
TranslateModule.forRoot()
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
TranslateService,
{
provide: ActivatedRoute, useValue: {
snapshot: {
params: {
id: 1,
chart: 'chart'
}
}
}
},
{ provide: Router, useValue: null },
{ provide: SessionService, useValue: fakeSessionService }
]
})
.compileComponents();
.compileComponents();
}));
beforeEach(() => {
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { SessionService } from './../../shared/session.service';
import { ListChartsComponent } from './list-charts.component';
describe('ListChartsComponent', () => {
let component: ListChartsComponent;
let fixture: ComponentFixture<ListChartsComponent>;
let fakeSessionService = {
getCurrentUser: function () {
return "admin";
}
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListChartsComponent ]
})
.compileComponents();
declarations: [ListChartsComponent],
imports: [
ClarityModule,
TranslateModule.forRoot()
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
{
provide: ActivatedRoute, useValue: {
snapshot: {
parent: {
params: {
id: 1,
data: 'chart'
}
}
}
}
},
{ provide: Router, useValue: null },
{ provide: SessionService, useValue: fakeSessionService }
]
}).compileComponents();
}));
beforeEach(() => {
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ClarityModule } from '@clr/angular';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AddGroupComponent } from './add-group.component';
import { OperationService } from "@harbor/ui";
import { GroupService } from "../../../group/group.service";
import { MemberService } from "./../member.service";
import { MessageHandlerService } from '../../../shared/message-handler/message-handler.service';
describe('AddGroupComponent', () => {
let component: AddGroupComponent;
let fixture: ComponentFixture<AddGroupComponent>;
let fakeMessageHandlerService = null;
let fakeOperationService = null;
let fakeGroupService = null;
let fakeMemberService = null;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddGroupComponent ]
})
.compileComponents();
declarations: [AddGroupComponent],
imports: [
ClarityModule,
FormsModule,
TranslateModule.forRoot()
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
TranslateService,
{ provide: MessageHandlerService, useValue: fakeMessageHandlerService },
{ provide: OperationService, useValue: fakeOperationService },