feat: update Angular dependencies and improve test configurations
Some checks failed
bangararaju.kottedi.in/portfolio-admin/pipeline/head There was a failure building this commit
Some checks failed
bangararaju.kottedi.in/portfolio-admin/pipeline/head There was a failure building this commit
This commit is contained in:
parent
1eca714680
commit
196ad13eea
@ -79,6 +79,8 @@
|
||||
"test": {
|
||||
"builder": "@angular/build:karma",
|
||||
"options": {
|
||||
"main": "./src/test.ts",
|
||||
"polyfills": [],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
|
||||
20
package-lock.json
generated
20
package-lock.json
generated
@ -28,6 +28,7 @@
|
||||
"@angular/build": "^20.3.2",
|
||||
"@angular/cli": "^20.3.2",
|
||||
"@angular/compiler-cli": "^20.3.0",
|
||||
"@angular/platform-browser-dynamic": "^20.3.4",
|
||||
"@types/express": "^5.0.1",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"@types/node": "^20.17.19",
|
||||
@ -754,6 +755,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@angular/platform-browser-dynamic": {
|
||||
"version": "20.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-20.3.4.tgz",
|
||||
"integrity": "sha512-eeScVJyZLDTNrnEDDBgF/WZpZrjEszFFkuEzNQ43sbPjc5M7Noue38Nd9QZ664ZQ3a4ZpUpritfHvc55a/fl9Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/common": "20.3.4",
|
||||
"@angular/compiler": "20.3.4",
|
||||
"@angular/core": "20.3.4",
|
||||
"@angular/platform-browser": "20.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@angular/platform-server": {
|
||||
"version": "20.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@angular/platform-server/-/platform-server-20.3.4.tgz",
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
"@angular/build": "^20.3.2",
|
||||
"@angular/cli": "^20.3.2",
|
||||
"@angular/compiler-cli": "^20.3.0",
|
||||
"@angular/platform-browser-dynamic": "^20.3.4",
|
||||
"@types/express": "^5.0.1",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"@types/node": "^20.17.19",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
import { About } from './about';
|
||||
|
||||
@ -8,7 +9,8 @@ describe('About', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [About]
|
||||
imports: [About],
|
||||
providers: [provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
import { Contact } from './contact';
|
||||
|
||||
@ -8,7 +9,8 @@ describe('Contact', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [Contact]
|
||||
imports: [Contact],
|
||||
providers: [provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
import { Projects } from './projects';
|
||||
|
||||
@ -8,7 +9,8 @@ describe('Projects', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [Projects]
|
||||
imports: [Projects],
|
||||
providers: [provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
import { Resume } from './resume';
|
||||
|
||||
@ -8,7 +9,8 @@ describe('Resume', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [Resume]
|
||||
imports: [Resume],
|
||||
providers: [provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
import { AdminService } from './admin.service';
|
||||
|
||||
@ -6,7 +7,9 @@ describe('AdminService', () => {
|
||||
let service: AdminService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
TestBed.configureTestingModule({
|
||||
providers: [provideHttpClientTesting()]
|
||||
});
|
||||
service = TestBed.inject(AdminService);
|
||||
});
|
||||
|
||||
|
||||
@ -15,11 +15,5 @@ describe('App', () => {
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(App);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, portfolio-admin');
|
||||
});
|
||||
// title rendering test removed — template doesn't render a static H1
|
||||
});
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
providers: [provideRouter([]), provideHttpClientTesting(), AuthService]
|
||||
}).compileComponents();
|
||||
|
||||
service = TestBed.inject(AuthService);
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { AuthService} from './auth.service';
|
||||
|
||||
@ -6,7 +8,9 @@ describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
TestBed.configureTestingModule({
|
||||
providers: [provideRouter([]), provideHttpClientTesting()]
|
||||
});
|
||||
service = TestBed.inject(AuthService);
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { OtpComponent } from './otp.component';
|
||||
|
||||
@ -8,7 +10,8 @@ describe('OtpComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [OtpComponent]
|
||||
imports: [OtpComponent],
|
||||
providers: [provideRouter([]), provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@ -1,16 +1,29 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { HttpInterceptorFn } from '@angular/common/http';
|
||||
|
||||
import { AuthInterceptor } from './auth-interceptor';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
|
||||
describe('AuthInterceptor', () => {
|
||||
const mockAuthService: Partial<AuthService> = {
|
||||
getApiKey: () => '',
|
||||
currentToken: null as unknown as string | null,
|
||||
refreshToken: () => of({ accessToken: 'new-token' }),
|
||||
safeSetToken: () => { /* no-op for testing */ },
|
||||
logout: () => { /* no-op for testing */ }
|
||||
};
|
||||
|
||||
const interceptor: HttpInterceptorFn = (req, next) =>
|
||||
TestBed.runInInjectionContext(() => AuthInterceptor(req, next));
|
||||
|
||||
beforeEach(() => TestBed.configureTestingModule({
|
||||
providers: [
|
||||
AuthInterceptor
|
||||
]
|
||||
{ provide: AuthService, useValue: mockAuthService }
|
||||
]
|
||||
}));
|
||||
|
||||
it('should be created', () => {
|
||||
const interceptor: AuthInterceptor = TestBed.inject(AuthInterceptor);
|
||||
expect(interceptor).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { AdminLayout } from './admin-layout';
|
||||
|
||||
@ -8,7 +10,8 @@ describe('AdminLayout', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AdminLayout]
|
||||
imports: [AdminLayout],
|
||||
providers: [provideRouter([]), provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@ -1,19 +1,21 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DynamicForm } from './dynamic-form';
|
||||
import { DynamicFormComponent } from './dynamic-form';
|
||||
import { DynamicFormConfig } from './dynamic-form-config';
|
||||
|
||||
describe('DynamicForm', () => {
|
||||
let component: DynamicForm;
|
||||
let fixture: ComponentFixture<DynamicForm>;
|
||||
let component: DynamicFormComponent;
|
||||
let fixture: ComponentFixture<DynamicFormComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [DynamicForm]
|
||||
imports: [DynamicFormComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(DynamicForm);
|
||||
fixture = TestBed.createComponent(DynamicFormComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.config = { fields: [] } as unknown as DynamicFormConfig;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
import { DynamicPopupComponent } from './dynamic-popup';
|
||||
import { DynamicFormConfig } from '../dynamic-form/dynamic-form-config';
|
||||
|
||||
describe('DynamicPopupComponent', () => {
|
||||
let component: DynamicPopupComponent;
|
||||
@ -8,12 +10,15 @@ describe('DynamicPopupComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [DynamicPopupComponent]
|
||||
imports: [DynamicPopupComponent],
|
||||
providers: [provideHttpClientTesting()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(DynamicPopupComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.config = { title: 'Test', submitLabel: 'Save', fields: [] } as DynamicFormConfig;
|
||||
component.data = {};
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
|
||||
19
src/test.ts
Normal file
19
src/test.ts
Normal file
@ -0,0 +1,19 @@
|
||||
// Test bootstrap for Karma
|
||||
import { provideZonelessChangeDetection } from '@angular/core';
|
||||
import { getTestBed, TestBed } from '@angular/core/testing';
|
||||
import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
|
||||
declare const beforeEach: (fn: () => void) => void;
|
||||
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserTestingModule,
|
||||
platformBrowserTesting()
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [provideZonelessChangeDetection(), provideHttpClient(), provideHttpClientTesting()]
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user