refs #1690 Add ConfigService integration to EnvVars and Roles components and fixed tests.
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
parent
294e85508b
commit
40385bc73c
|
@ -13,12 +13,17 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ToastrModule, ToastrService } from 'ngx-toastr';
|
import { ToastrModule, ToastrService } from 'ngx-toastr';
|
||||||
import { DataService } from '../users/users/data.service';
|
import { DataService } from '../users/users/data.service';
|
||||||
import { MatTableModule } from '@angular/material/table';
|
import { MatTableModule } from '@angular/material/table';
|
||||||
|
import { ConfigService } from '../../../services/config.service';
|
||||||
|
|
||||||
describe('EnvVarsComponent', () => {
|
describe('EnvVarsComponent', () => {
|
||||||
let component: EnvVarsComponent;
|
let component: EnvVarsComponent;
|
||||||
let fixture: ComponentFixture<EnvVarsComponent>;
|
let fixture: ComponentFixture<EnvVarsComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const mockConfigService = {
|
||||||
|
apiUrl: 'http://mock-api-url'
|
||||||
|
};
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [EnvVarsComponent],
|
declarations: [EnvVarsComponent],
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -47,6 +52,10 @@ describe('EnvVarsComponent', () => {
|
||||||
{
|
{
|
||||||
provide: MAT_DIALOG_DATA,
|
provide: MAT_DIALOG_DATA,
|
||||||
useValue: {}
|
useValue: {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: ConfigService,
|
||||||
|
useValue: mockConfigService
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { ToastrService } from "ngx-toastr";
|
import { ToastrService } from "ngx-toastr";
|
||||||
|
import { ConfigService } from "../../../services/config.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-env-vars',
|
selector: 'app-env-vars',
|
||||||
|
@ -11,13 +12,15 @@ export class EnvVarsComponent {
|
||||||
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
||||||
envVars: { name: string; value: string }[] = [];
|
envVars: { name: string; value: string }[] = [];
|
||||||
displayedColumns: string[] = ['name', 'value'];
|
displayedColumns: string[] = ['name', 'value'];
|
||||||
|
private apiUrl: string;
|
||||||
private apiUrl = `${this.baseUrl}/env-vars`;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private toastService: ToastrService,
|
private toastService: ToastrService,
|
||||||
) {}
|
private configService: ConfigService
|
||||||
|
) {
|
||||||
|
this.apiUrl = `${this.configService.apiUrl}/env-vars`;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loadEnvVars();
|
this.loadEnvVars();
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
import { DataService } from './data.service';
|
import { DataService } from './data.service';
|
||||||
import { of } from 'rxjs';
|
import { ConfigService } from '../../../../services/config.service';
|
||||||
import { MatDivider } from '@angular/material/divider';
|
import { MatDivider } from '@angular/material/divider';
|
||||||
import { MatFormField } from '@angular/material/form-field';
|
import { MatFormField } from '@angular/material/form-field';
|
||||||
import { MatLabel } from '@angular/material/form-field';
|
import { MatLabel } from '@angular/material/form-field';
|
||||||
|
@ -20,12 +20,14 @@ describe('RolesComponent', () => {
|
||||||
let mockHttpClient: jasmine.SpyObj<HttpClient>;
|
let mockHttpClient: jasmine.SpyObj<HttpClient>;
|
||||||
let mockToastrService: jasmine.SpyObj<ToastrService>;
|
let mockToastrService: jasmine.SpyObj<ToastrService>;
|
||||||
let mockDataService: jasmine.SpyObj<DataService>;
|
let mockDataService: jasmine.SpyObj<DataService>;
|
||||||
|
let mockConfigService: jasmine.SpyObj<ConfigService>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const matDialogSpy = jasmine.createSpyObj('MatDialog', ['open']);
|
const matDialogSpy = jasmine.createSpyObj('MatDialog', ['open']);
|
||||||
const httpClientSpy = jasmine.createSpyObj('HttpClient', ['get', 'post', 'put', 'delete']);
|
const httpClientSpy = jasmine.createSpyObj('HttpClient', ['get', 'post', 'put', 'delete']);
|
||||||
const toastrServiceSpy = jasmine.createSpyObj('ToastrService', ['success', 'error']);
|
const toastrServiceSpy = jasmine.createSpyObj('ToastrService', ['success', 'error']);
|
||||||
const dataServiceSpy = jasmine.createSpyObj('DataService', ['getRoles']);
|
const dataServiceSpy = jasmine.createSpyObj('DataService', ['getRoles']);
|
||||||
|
const configServiceSpy = jasmine.createSpyObj('ConfigService', [], { apiUrl: 'http://mock-api-url' });
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [RolesComponent, LoadingComponent],
|
declarations: [RolesComponent, LoadingComponent],
|
||||||
|
@ -35,7 +37,8 @@ describe('RolesComponent', () => {
|
||||||
{ provide: MatDialog, useValue: matDialogSpy },
|
{ provide: MatDialog, useValue: matDialogSpy },
|
||||||
{ provide: HttpClient, useValue: httpClientSpy },
|
{ provide: HttpClient, useValue: httpClientSpy },
|
||||||
{ provide: ToastrService, useValue: toastrServiceSpy },
|
{ provide: ToastrService, useValue: toastrServiceSpy },
|
||||||
{ provide: DataService, useValue: dataServiceSpy }
|
{ provide: DataService, useValue: dataServiceSpy },
|
||||||
|
{ provide: ConfigService, useValue: configServiceSpy }
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
@ -47,6 +50,7 @@ describe('RolesComponent', () => {
|
||||||
mockHttpClient = TestBed.inject(HttpClient) as jasmine.SpyObj<HttpClient>;
|
mockHttpClient = TestBed.inject(HttpClient) as jasmine.SpyObj<HttpClient>;
|
||||||
mockToastrService = TestBed.inject(ToastrService) as jasmine.SpyObj<ToastrService>;
|
mockToastrService = TestBed.inject(ToastrService) as jasmine.SpyObj<ToastrService>;
|
||||||
mockDataService = TestBed.inject(DataService) as jasmine.SpyObj<DataService>;
|
mockDataService = TestBed.inject(DataService) as jasmine.SpyObj<DataService>;
|
||||||
|
mockConfigService = TestBed.inject(ConfigService) as jasmine.SpyObj<ConfigService>;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { DataService } from "./data.service";
|
||||||
import { PageEvent } from "@angular/material/paginator";
|
import { PageEvent } from "@angular/material/paginator";
|
||||||
import { DeleteModalComponent } from '../../../../shared/delete_modal/delete-modal/delete-modal.component';
|
import { DeleteModalComponent } from '../../../../shared/delete_modal/delete-modal/delete-modal.component';
|
||||||
import { AddRoleModalComponent } from './add-role-modal/add-role-modal.component';
|
import { AddRoleModalComponent } from './add-role-modal/add-role-modal.component';
|
||||||
|
import { ConfigService } from '../../../../services/config.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-roles',
|
selector: 'app-roles',
|
||||||
|
@ -14,7 +15,7 @@ import { AddRoleModalComponent } from './add-role-modal/add-role-modal.component
|
||||||
styleUrls: ['./roles.component.css']
|
styleUrls: ['./roles.component.css']
|
||||||
})
|
})
|
||||||
export class RolesComponent implements OnInit {
|
export class RolesComponent implements OnInit {
|
||||||
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
baseUrl: string = this.configService.apiUrl;
|
||||||
dataSource = new MatTableDataSource<any>();
|
dataSource = new MatTableDataSource<any>();
|
||||||
filters: { [key: string]: string } = {};
|
filters: { [key: string]: string } = {};
|
||||||
loading: boolean = false;
|
loading: boolean = false;
|
||||||
|
@ -48,7 +49,8 @@ export class RolesComponent implements OnInit {
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
private toastService: ToastrService
|
private toastService: ToastrService,
|
||||||
|
private configService: ConfigService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
|
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { ToastrModule } from 'ngx-toastr';
|
||||||
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ConvertImageComponent } from './convert-image.component';
|
import { ConvertImageComponent } from './convert-image.component';
|
||||||
|
|
||||||
describe('ConvertImageComponent', () => {
|
describe('ConvertImageComponent', () => {
|
||||||
|
@ -8,7 +14,20 @@ describe('ConvertImageComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ConvertImageComponent]
|
declarations: [ConvertImageComponent],
|
||||||
|
imports: [
|
||||||
|
HttpClientTestingModule,
|
||||||
|
MatDialogModule,
|
||||||
|
ToastrModule.forRoot(),
|
||||||
|
MatFormFieldModule,
|
||||||
|
MatInputModule,
|
||||||
|
FormsModule,
|
||||||
|
BrowserAnimationsModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: MatDialogRef, useValue: {} },
|
||||||
|
{ provide: MAT_DIALOG_DATA, useValue: {} }
|
||||||
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { ImportImageComponent } from './import-image.component';
|
import { ImportImageComponent } from './import-image.component';
|
||||||
import {FormBuilder, ReactiveFormsModule} from "@angular/forms";
|
import { FormBuilder, FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
import { ToastrModule, ToastrService } from "ngx-toastr";
|
import { ToastrModule, ToastrService } from "ngx-toastr";
|
||||||
import {DataService} from "../../calendar/data.service";
|
|
||||||
import { provideHttpClient } from "@angular/common/http";
|
import { provideHttpClient } from "@angular/common/http";
|
||||||
import { provideHttpClientTesting } from "@angular/common/http/testing";
|
import { provideHttpClientTesting } from "@angular/common/http/testing";
|
||||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from "@angular/material/dialog";
|
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from "@angular/material/dialog";
|
||||||
|
@ -22,6 +21,7 @@ describe('ImportImageComponent', () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ImportImageComponent],
|
declarations: [ImportImageComponent],
|
||||||
imports: [
|
imports: [
|
||||||
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
|
|
Loading…
Reference in New Issue