witspry-auth-ng-client 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/angular.json +40 -0
- package/jest.config.js +32 -0
- package/karma.conf.js +33 -0
- package/ng-package.json +7 -0
- package/package.json +74 -48
- package/src/lib/components/index.ts +1 -0
- package/src/lib/components/oauth2-callback/oauth2-callback.component.spec.ts +215 -0
- package/src/lib/components/oauth2-callback/oauth2-callback.component.ts +291 -0
- package/src/lib/guards/index.ts +1 -0
- package/src/lib/guards/oauth2-auth.guard.ts +210 -0
- package/src/lib/interceptors/index.ts +1 -0
- package/src/lib/interceptors/oauth2.interceptor.ts +250 -0
- package/src/lib/models/index.ts +3 -0
- package/src/lib/models/oauth2-config.model.ts +74 -0
- package/src/lib/models/oauth2-types.model.ts +143 -0
- package/src/lib/models/witsauth-types.model.ts +8 -0
- package/src/lib/ng-oauth2-pkce.service.ts +66 -0
- package/src/lib/services/index.ts +2 -0
- package/src/lib/services/oauth2-storage.service.ts +212 -0
- package/src/lib/services/oauth2.service.ts +1026 -0
- package/src/lib/tokens/index.ts +1 -0
- package/src/lib/tokens/oauth2-config.token.ts +7 -0
- package/src/public-api.ts +26 -0
- package/src/test-setup.ts +51 -0
- package/tsconfig.json +32 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.spec.json +17 -0
- package/fesm2022/witspry-auth-ng-client.mjs +0 -1716
- package/fesm2022/witspry-auth-ng-client.mjs.map +0 -1
- package/types/witspry-auth-ng-client.d.ts +0 -510
package/README.md
CHANGED
|
@@ -309,5 +309,5 @@ MIT License - see LICENSE file for details.
|
|
|
309
309
|
- Updated Angular dependencies to Angular v21
|
|
310
310
|
|
|
311
311
|
### 1.3.3
|
|
312
|
-
- Fixed issue where on exception, the loading screen
|
|
312
|
+
- Fixed issue where on exception, the loading screen stuck
|
|
313
313
|
- Added user friendly error message
|
package/angular.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"newProjectRoot": "projects",
|
|
5
|
+
"projects": {
|
|
6
|
+
"ng-oauth2-pkce": {
|
|
7
|
+
"projectType": "library",
|
|
8
|
+
"root": "",
|
|
9
|
+
"sourceRoot": "src",
|
|
10
|
+
"prefix": "lib",
|
|
11
|
+
"architect": {
|
|
12
|
+
"build": {
|
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
14
|
+
"options": {
|
|
15
|
+
"project": "ng-package.json"
|
|
16
|
+
},
|
|
17
|
+
"configurations": {
|
|
18
|
+
"production": {
|
|
19
|
+
"tsConfig": "tsconfig.lib.json"
|
|
20
|
+
},
|
|
21
|
+
"development": {
|
|
22
|
+
"tsConfig": "tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"defaultConfiguration": "production"
|
|
26
|
+
},
|
|
27
|
+
"test": {
|
|
28
|
+
"builder": "@angular-devkit/build-angular:karma",
|
|
29
|
+
"options": {
|
|
30
|
+
"tsConfig": "tsconfig.spec.json",
|
|
31
|
+
"polyfills": [
|
|
32
|
+
"zone.js",
|
|
33
|
+
"zone.js/testing"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'jest-preset-angular',
|
|
3
|
+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
|
4
|
+
testMatch: [
|
|
5
|
+
'<rootDir>/src/**/*.spec.ts'
|
|
6
|
+
],
|
|
7
|
+
collectCoverageFrom: [
|
|
8
|
+
'src/lib/**/*.ts',
|
|
9
|
+
'!src/lib/**/*.spec.ts',
|
|
10
|
+
'!src/lib/**/*.d.ts',
|
|
11
|
+
'!src/lib/**/index.ts'
|
|
12
|
+
],
|
|
13
|
+
coverageDirectory: 'coverage',
|
|
14
|
+
coverageReporters: [
|
|
15
|
+
'html',
|
|
16
|
+
'text-summary',
|
|
17
|
+
'lcov'
|
|
18
|
+
],
|
|
19
|
+
coverageThreshold: {
|
|
20
|
+
global: {
|
|
21
|
+
statements: 80,
|
|
22
|
+
branches: 70,
|
|
23
|
+
functions: 80,
|
|
24
|
+
lines: 80
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
moduleNameMapper: {
|
|
28
|
+
'^@/(.*)$': '<rootDir>/src/$1'
|
|
29
|
+
},
|
|
30
|
+
testEnvironment: 'jsdom',
|
|
31
|
+
modulePathIgnorePatterns: ['<rootDir>/dist/']
|
|
32
|
+
};
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Karma configuration file
|
|
2
|
+
module.exports = function (config) {
|
|
3
|
+
config.set({
|
|
4
|
+
basePath: '',
|
|
5
|
+
frameworks: ['jasmine'],
|
|
6
|
+
plugins: [
|
|
7
|
+
require('karma-jasmine'),
|
|
8
|
+
require('karma-chrome-launcher'),
|
|
9
|
+
require('karma-jasmine-html-reporter')
|
|
10
|
+
],
|
|
11
|
+
client: {
|
|
12
|
+
jasmine: {
|
|
13
|
+
random: true
|
|
14
|
+
},
|
|
15
|
+
clearContext: false
|
|
16
|
+
},
|
|
17
|
+
jasmineHtmlReporter: {
|
|
18
|
+
suppressAll: true
|
|
19
|
+
},
|
|
20
|
+
reporters: ['progress', 'kjhtml'],
|
|
21
|
+
port: 9876,
|
|
22
|
+
colors: true,
|
|
23
|
+
logLevel: config.LOG_INFO,
|
|
24
|
+
autoWatch: false,
|
|
25
|
+
browsers: ['ChromeHeadless'],
|
|
26
|
+
singleRun: true,
|
|
27
|
+
restartOnFileChange: false,
|
|
28
|
+
files: [
|
|
29
|
+
// Test files will be added by Angular CLI
|
|
30
|
+
{ pattern: 'src/**/*.spec.ts', type: 'module' }
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
};
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,48 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "witspry-auth-ng-client",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Witspry auth angular library for secure authentication with configurable providers",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"angular",
|
|
7
|
-
"oauth2",
|
|
8
|
-
"pkce",
|
|
9
|
-
"authentication",
|
|
10
|
-
"security",
|
|
11
|
-
"oidc",
|
|
12
|
-
"authorization",
|
|
13
|
-
"jwt",
|
|
14
|
-
"token"
|
|
15
|
-
],
|
|
16
|
-
"author": "Satya Jugran <satya.jugran@gmail.com>",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"homepage": "https://github.com/satya-jugran/witspry-auth-ng-client#readme",
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "https://github.com/satya-jugran/witspry-auth-ng-client.git"
|
|
22
|
-
},
|
|
23
|
-
"bugs": {
|
|
24
|
-
"url": "https://github.com/satya-jugran/witspry-auth-ng-client/issues"
|
|
25
|
-
},
|
|
26
|
-
"peerDependencies": {
|
|
27
|
-
"@angular/common": ">=18.0.0 <22.0.0",
|
|
28
|
-
"@angular/core": ">=18.0.0 <22.0.0",
|
|
29
|
-
"@angular/platform-browser": ">=18.0.0 <22.0.0",
|
|
30
|
-
"@angular/router": ">=18.0.0 <22.0.0",
|
|
31
|
-
"rxjs": "~7.8.0"
|
|
32
|
-
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "witspry-auth-ng-client",
|
|
3
|
+
"version": "1.3.5",
|
|
4
|
+
"description": "Witspry auth angular library for secure authentication with configurable providers",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"oauth2",
|
|
8
|
+
"pkce",
|
|
9
|
+
"authentication",
|
|
10
|
+
"security",
|
|
11
|
+
"oidc",
|
|
12
|
+
"authorization",
|
|
13
|
+
"jwt",
|
|
14
|
+
"token"
|
|
15
|
+
],
|
|
16
|
+
"author": "Satya Jugran <satya.jugran@gmail.com>",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"homepage": "https://github.com/satya-jugran/witspry-auth-ng-client#readme",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/satya-jugran/witspry-auth-ng-client.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/satya-jugran/witspry-auth-ng-client/issues"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@angular/common": ">=18.0.0 <22.0.0",
|
|
28
|
+
"@angular/core": ">=18.0.0 <22.0.0",
|
|
29
|
+
"@angular/platform-browser": ">=18.0.0 <22.0.0",
|
|
30
|
+
"@angular/router": ">=18.0.0 <22.0.0",
|
|
31
|
+
"rxjs": "~7.8.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "ng-packagr -p ng-package.json",
|
|
35
|
+
"build:watch": "ng-packagr -p ng-package.json -w",
|
|
36
|
+
"pack": "npm run build && cd dist/ng-oauth2-pkce && npm pack",
|
|
37
|
+
"test": "jest",
|
|
38
|
+
"test:watch": "jest --watch",
|
|
39
|
+
"test:coverage": "jest --coverage"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@angular/build": "^21.0.1",
|
|
43
|
+
"@angular/animations": "^21.0.2",
|
|
44
|
+
"@angular/cli": "^21.0.1",
|
|
45
|
+
"@angular/common": "^21.0.0",
|
|
46
|
+
"@angular/compiler": "^21.0.0",
|
|
47
|
+
"@angular/compiler-cli": "^21.0.0",
|
|
48
|
+
"@angular/core": "^21.0.0",
|
|
49
|
+
"@angular/platform-browser": "^21.0.0",
|
|
50
|
+
"@angular/platform-browser-dynamic": "^21.0.0",
|
|
51
|
+
"@angular/router": "^21.0.0",
|
|
52
|
+
"@types/jasmine": "^5.1.8",
|
|
53
|
+
"@types/jest": "^29.5.14",
|
|
54
|
+
"@types/node": "^24.10.1",
|
|
55
|
+
"jasmine": "^5.8.0",
|
|
56
|
+
"jest": "^30.2.0",
|
|
57
|
+
"jest-preset-angular": "^16.0.0",
|
|
58
|
+
"karma": "^6.4.4",
|
|
59
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
60
|
+
"karma-coverage": "^2.2.1",
|
|
61
|
+
"karma-jasmine": "^5.1.0",
|
|
62
|
+
"karma-jasmine-html-reporter": "^2.1.0",
|
|
63
|
+
"karma-webpack": "^5.0.1",
|
|
64
|
+
"ng-packagr": "^21.0.0",
|
|
65
|
+
"rxjs": "~7.8.0",
|
|
66
|
+
"ts-loader": "^9.5.2",
|
|
67
|
+
"typescript": "~5.9.2",
|
|
68
|
+
"webpack": "^5.103.0"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"tslib": "^2.3.0"
|
|
72
|
+
},
|
|
73
|
+
"sideEffects": false
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './oauth2-callback/oauth2-callback.component';
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { PLATFORM_ID } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
import { OAuth2CallbackComponent } from './oauth2-callback.component';
|
|
6
|
+
import { OAuth2Service } from '../../services/oauth2.service';
|
|
7
|
+
import { OAuth2Config } from '../../models/oauth2-config.model';
|
|
8
|
+
import { OAUTH2_CONFIG_TOKEN } from '../../tokens/oauth2-config.token';
|
|
9
|
+
|
|
10
|
+
describe('OAuth2CallbackComponent', () => {
|
|
11
|
+
let component: OAuth2CallbackComponent;
|
|
12
|
+
let fixture: ComponentFixture<OAuth2CallbackComponent>;
|
|
13
|
+
let mockOAuth2Service: jest.Mocked<OAuth2Service>;
|
|
14
|
+
let mockRouter: jest.Mocked<Router>;
|
|
15
|
+
|
|
16
|
+
const createMockConfig = (redirectRoute?: string): OAuth2Config => ({
|
|
17
|
+
clientId: 'test-client-id',
|
|
18
|
+
redirectUri: 'http://localhost:4200/oauth2/callback',
|
|
19
|
+
authorizationEndpoint: 'https://auth.example.com/oauth2/authorize',
|
|
20
|
+
tokenEndpoint: 'https://auth.example.com/oauth2/token',
|
|
21
|
+
scope: 'openid profile email',
|
|
22
|
+
redirectRoute
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const setupTestBed = async (config: OAuth2Config, platformId = 'browser') => {
|
|
26
|
+
await TestBed.configureTestingModule({
|
|
27
|
+
imports: [OAuth2CallbackComponent],
|
|
28
|
+
providers: [
|
|
29
|
+
{ provide: OAuth2Service, useValue: mockOAuth2Service },
|
|
30
|
+
{ provide: Router, useValue: mockRouter },
|
|
31
|
+
{ provide: PLATFORM_ID, useValue: platformId },
|
|
32
|
+
{ provide: OAUTH2_CONFIG_TOKEN, useValue: config }
|
|
33
|
+
]
|
|
34
|
+
}).compileComponents();
|
|
35
|
+
|
|
36
|
+
fixture = TestBed.createComponent(OAuth2CallbackComponent);
|
|
37
|
+
component = fixture.componentInstance;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
// Create mocks for dependencies
|
|
42
|
+
mockOAuth2Service = {
|
|
43
|
+
handleCallback: jest.fn(),
|
|
44
|
+
isAuthenticationAvailable: jest.fn(),
|
|
45
|
+
startAuthorization: jest.fn()
|
|
46
|
+
} as any;
|
|
47
|
+
|
|
48
|
+
mockRouter = {
|
|
49
|
+
navigate: jest.fn()
|
|
50
|
+
} as any;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
jest.clearAllMocks();
|
|
55
|
+
TestBed.resetTestingModule();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('Component Initialization', () => {
|
|
59
|
+
beforeEach(async () => {
|
|
60
|
+
await setupTestBed(createMockConfig());
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should create', () => {
|
|
64
|
+
expect(component).toBeTruthy();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should initialize with loading state', () => {
|
|
68
|
+
expect(component.isLoading).toBe(true);
|
|
69
|
+
expect(component.error).toBeNull();
|
|
70
|
+
expect(component.success).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('goHome method', () => {
|
|
75
|
+
it('should navigate to default route when redirectRoute is not configured', async () => {
|
|
76
|
+
await setupTestBed(createMockConfig());
|
|
77
|
+
fixture.detectChanges();
|
|
78
|
+
|
|
79
|
+
component.goHome();
|
|
80
|
+
|
|
81
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/']);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should navigate to custom route when redirectRoute is configured', async () => {
|
|
85
|
+
await setupTestBed(createMockConfig('/dashboard'));
|
|
86
|
+
fixture.detectChanges();
|
|
87
|
+
|
|
88
|
+
component.goHome();
|
|
89
|
+
|
|
90
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/dashboard']);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should navigate to admin route when redirectRoute is configured', async () => {
|
|
94
|
+
await setupTestBed(createMockConfig('/admin'));
|
|
95
|
+
fixture.detectChanges();
|
|
96
|
+
|
|
97
|
+
component.goHome();
|
|
98
|
+
|
|
99
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/admin']);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should navigate to profile route when redirectRoute is configured', async () => {
|
|
103
|
+
await setupTestBed(createMockConfig('/profile'));
|
|
104
|
+
fixture.detectChanges();
|
|
105
|
+
|
|
106
|
+
component.goHome();
|
|
107
|
+
|
|
108
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/profile']);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('retryLogin method', () => {
|
|
113
|
+
beforeEach(async () => {
|
|
114
|
+
await setupTestBed(createMockConfig());
|
|
115
|
+
fixture.detectChanges();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should retry login when authentication is available', () => {
|
|
119
|
+
mockOAuth2Service.isAuthenticationAvailable.mockReturnValue(true);
|
|
120
|
+
mockOAuth2Service.startAuthorization.mockResolvedValue(undefined);
|
|
121
|
+
|
|
122
|
+
component.retryLogin();
|
|
123
|
+
|
|
124
|
+
expect(component.isLoading).toBe(true);
|
|
125
|
+
expect(component.error).toBeNull();
|
|
126
|
+
expect(component.success).toBe(false);
|
|
127
|
+
expect(mockOAuth2Service.startAuthorization).toHaveBeenCalled();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should handle authentication not available', () => {
|
|
131
|
+
mockOAuth2Service.isAuthenticationAvailable.mockReturnValue(false);
|
|
132
|
+
|
|
133
|
+
component.retryLogin();
|
|
134
|
+
|
|
135
|
+
expect(component.error).toBe('Authentication not available in current environment');
|
|
136
|
+
expect(mockOAuth2Service.startAuthorization).not.toHaveBeenCalled();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('ngOnInit - Non-Browser Environment', () => {
|
|
141
|
+
it('should handle non-browser environment', async () => {
|
|
142
|
+
await setupTestBed(createMockConfig(), 'server');
|
|
143
|
+
fixture.detectChanges();
|
|
144
|
+
|
|
145
|
+
expect(component.isLoading).toBe(false);
|
|
146
|
+
expect(component.error).toBeFalsy(); // Error message is commented out in component
|
|
147
|
+
expect(component.success).toBe(false);
|
|
148
|
+
expect(mockOAuth2Service.handleCallback).not.toHaveBeenCalled();
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe('Template Rendering', () => {
|
|
153
|
+
beforeEach(async () => {
|
|
154
|
+
await setupTestBed(createMockConfig());
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should show loading state initially', () => {
|
|
158
|
+
fixture.detectChanges();
|
|
159
|
+
|
|
160
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
|
161
|
+
expect(compiled.querySelector('.loading-section')).toBeTruthy();
|
|
162
|
+
expect(compiled.querySelector('.success-section')).toBeFalsy();
|
|
163
|
+
expect(compiled.querySelector('.error-section')).toBeFalsy();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('Redirect Route Configuration Edge Cases', () => {
|
|
168
|
+
it('should handle empty string redirectRoute', async () => {
|
|
169
|
+
await setupTestBed(createMockConfig(''));
|
|
170
|
+
fixture.detectChanges();
|
|
171
|
+
|
|
172
|
+
component.goHome();
|
|
173
|
+
|
|
174
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/']);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should handle undefined redirectRoute', async () => {
|
|
178
|
+
await setupTestBed(createMockConfig(undefined));
|
|
179
|
+
fixture.detectChanges();
|
|
180
|
+
|
|
181
|
+
component.goHome();
|
|
182
|
+
|
|
183
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/']);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should handle complex route paths', async () => {
|
|
187
|
+
await setupTestBed(createMockConfig('/users/123/dashboard'));
|
|
188
|
+
fixture.detectChanges();
|
|
189
|
+
|
|
190
|
+
component.goHome();
|
|
191
|
+
|
|
192
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(['/users/123/dashboard']);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe('Redirect Route Logic in Success Flow', () => {
|
|
197
|
+
it('should use default route in success redirect logic', async () => {
|
|
198
|
+
await setupTestBed(createMockConfig());
|
|
199
|
+
fixture.detectChanges();
|
|
200
|
+
|
|
201
|
+
// Simulate the redirect logic from ngOnInit success flow
|
|
202
|
+
const redirectRoute = component['config'].redirectRoute || '/';
|
|
203
|
+
expect(redirectRoute).toBe('/');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('should use custom route in success redirect logic', async () => {
|
|
207
|
+
await setupTestBed(createMockConfig('/dashboard'));
|
|
208
|
+
fixture.detectChanges();
|
|
209
|
+
|
|
210
|
+
// Simulate the redirect logic from ngOnInit success flow
|
|
211
|
+
const redirectRoute = component['config'].redirectRoute || '/';
|
|
212
|
+
expect(redirectRoute).toBe('/dashboard');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|