Compare commits

..

No commits in common. "4989ff9883945a4d6b0e93fd966cc4f74a2783aa" and "094cac3b9264084631650f5c8fb1646ced07c1cb" have entirely different histories.

18 changed files with 124 additions and 257 deletions

66
Jenkinsfile vendored
View File

@ -9,13 +9,9 @@ pipeline {
stages {
stage('Build & Test') {
stage('Build') {
agent { label getAgentLabel() }
environment {
CHROME_BIN = "${getChromeBin()}"
}
stages {
stage('Cleanup Workspace') {
@ -31,14 +27,6 @@ pipeline {
}
stage('Inject Environment File') {
when {
not {
anyOf {
branch pattern: "feature/.*", comparator: "REGEXP"
branch pattern: "bug/.*", comparator: "REGEXP"
}
}
}
steps {
configFileProvider(
[configFile(
@ -52,43 +40,18 @@ pipeline {
}
}
stage('Install Dependencies') {
steps {
sh 'npm ci'
}
}
stage('Run Tests') {
when {
anyOf {
branch pattern: "feature/.*", comparator: "REGEXP"
branch pattern: "bug/.*", comparator: "REGEXP"
branch 'develop'
branch 'prod'
}
}
steps {
sh 'npm run test -- --watch=false --browsers=ChromeHeadless'
}
}
stage('Build Angular App') {
when {
anyOf {
branch 'develop'
branch 'prod'
}
}
stage('Install & Build') {
steps {
sh '''
npm ci
ng build --configuration production --base-href /admin/
'''
}
}
}
}
// 🚨 Production Approval Gate
stage('Production Approval') {
when {
branch 'prod'
@ -99,14 +62,6 @@ pipeline {
}
stage('Deploy & Verify') {
when {
anyOf {
branch 'develop'
branch 'prod'
}
}
agent { label getAgentLabel() }
stages {
@ -135,12 +90,13 @@ pipeline {
post {
success {
echo "Deployment successful for ${env.BRANCH_NAME}"
echo "Deployment successful for ${env.BRANCH_NAME}"
}
failure {
echo "Deployment failed for ${env.BRANCH_NAME}"
echo "Deployment failed for ${env.BRANCH_NAME}"
}
}
}
//
@ -178,11 +134,3 @@ def getHealthUrl() {
return "https://bangararaju-uat.kottedi.in/admin"
}
}
def getChromeBin() {
if (env.BRANCH_NAME == 'prod') {
return "/snap/bin/chromium"
} else {
return "/usr/bin/chromium"
}
}

View File

@ -79,8 +79,6 @@
"test": {
"builder": "@angular/build:karma",
"options": {
"main": "./src/test.ts",
"polyfills": [],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [

20
package-lock.json generated
View File

@ -28,7 +28,6 @@
"@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",
@ -755,25 +754,6 @@
}
}
},
"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",

View File

@ -44,7 +44,6 @@
"@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",

View File

@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { About } from './about';
@ -9,8 +8,7 @@ describe('About', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [About],
providers: [provideHttpClientTesting()]
imports: [About]
})
.compileComponents();

View File

@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Contact } from './contact';
@ -9,8 +8,7 @@ describe('Contact', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Contact],
providers: [provideHttpClientTesting()]
imports: [Contact]
})
.compileComponents();

View File

@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Projects } from './projects';
@ -9,8 +8,7 @@ describe('Projects', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Projects],
providers: [provideHttpClientTesting()]
imports: [Projects]
})
.compileComponents();

View File

@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Resume } from './resume';
@ -9,8 +8,7 @@ describe('Resume', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Resume],
providers: [provideHttpClientTesting()]
imports: [Resume]
})
.compileComponents();

View File

@ -1,5 +1,4 @@
import { TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { AdminService } from './admin.service';
@ -7,9 +6,7 @@ describe('AdminService', () => {
let service: AdminService;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideHttpClientTesting()]
});
TestBed.configureTestingModule({});
service = TestBed.inject(AdminService);
});

View File

@ -15,5 +15,11 @@ describe('App', () => {
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
// title rendering test removed — template doesn't render a static H1
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');
});
});

View File

@ -1,16 +1,12 @@
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(async () => {
await TestBed.configureTestingModule({
providers: [provideRouter([]), provideHttpClientTesting(), AuthService]
}).compileComponents();
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AuthService);
});

View File

@ -1,6 +1,4 @@
import { TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideRouter } from '@angular/router';
import { AuthService} from './auth.service';
@ -8,9 +6,7 @@ describe('AuthService', () => {
let service: AuthService;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideRouter([]), provideHttpClientTesting()]
});
TestBed.configureTestingModule({});
service = TestBed.inject(AuthService);
});

View File

@ -1,6 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideRouter } from '@angular/router';
import { OtpComponent } from './otp.component';
@ -10,8 +8,7 @@ describe('OtpComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [OtpComponent],
providers: [provideRouter([]), provideHttpClientTesting()]
imports: [OtpComponent]
})
.compileComponents();

View File

@ -1,29 +1,16 @@
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: [
{ provide: AuthService, useValue: mockAuthService }
AuthInterceptor
]
}));
it('should be created', () => {
const interceptor: AuthInterceptor = TestBed.inject(AuthInterceptor);
expect(interceptor).toBeTruthy();
});
});

View File

@ -1,6 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideRouter } from '@angular/router';
import { AdminLayout } from './admin-layout';
@ -10,8 +8,7 @@ describe('AdminLayout', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AdminLayout],
providers: [provideRouter([]), provideHttpClientTesting()]
imports: [AdminLayout]
})
.compileComponents();

View File

@ -1,21 +1,19 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DynamicFormComponent } from './dynamic-form';
import { DynamicFormConfig } from './dynamic-form-config';
import { DynamicForm } from './dynamic-form';
describe('DynamicForm', () => {
let component: DynamicFormComponent;
let fixture: ComponentFixture<DynamicFormComponent>;
let component: DynamicForm;
let fixture: ComponentFixture<DynamicForm>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DynamicFormComponent]
imports: [DynamicForm]
})
.compileComponents();
fixture = TestBed.createComponent(DynamicFormComponent);
fixture = TestBed.createComponent(DynamicForm);
component = fixture.componentInstance;
component.config = { fields: [] } as unknown as DynamicFormConfig;
fixture.detectChanges();
});

View File

@ -1,8 +1,6 @@
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;
@ -10,15 +8,12 @@ describe('DynamicPopupComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DynamicPopupComponent],
providers: [provideHttpClientTesting()]
imports: [DynamicPopupComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DynamicPopupComponent);
component = fixture.componentInstance;
component.config = { title: 'Test', submitLabel: 'Save', fields: [] } as DynamicFormConfig;
component.data = {};
fixture.detectChanges();
});

View File

@ -1,19 +0,0 @@
// 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()]
});
});