AI Implementation feature(842): First-Start Create Admin Modal 1.01 (#4)
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { decideAuthRedirect } from '../../frontend/src/app/core/guards/auth.guard.decision';
|
||||
|
||||
function makeRouter() {
|
||||
return {
|
||||
createUrlTree: jest.fn((cmds: string[]) => ({ __urlTree: true, cmds })),
|
||||
};
|
||||
}
|
||||
|
||||
describe('decideAuthRedirect (race-fix core)', () => {
|
||||
it('redirects to /bootstrap while bootstrap is uninitialized', () => {
|
||||
const router = makeRouter();
|
||||
const result = decideAuthRedirect(
|
||||
{ initialized: false, isAuthenticated: false },
|
||||
router as any,
|
||||
);
|
||||
expect(router.createUrlTree).toHaveBeenCalledWith(['/bootstrap']);
|
||||
expect((result as any).__urlTree).toBe(true);
|
||||
});
|
||||
|
||||
it('redirects to /login when initialized but not authenticated', () => {
|
||||
const router = makeRouter();
|
||||
const result = decideAuthRedirect(
|
||||
{ initialized: true, isAuthenticated: false },
|
||||
router as any,
|
||||
);
|
||||
expect(router.createUrlTree).toHaveBeenCalledWith(['/login']);
|
||||
expect((result as any).__urlTree).toBe(true);
|
||||
});
|
||||
|
||||
it('allows navigation when initialized AND authenticated (no /bootstrap redirect)', () => {
|
||||
const router = makeRouter();
|
||||
const result = decideAuthRedirect(
|
||||
{ initialized: true, isAuthenticated: true },
|
||||
router as any,
|
||||
);
|
||||
expect(result).toBe(true);
|
||||
expect(router.createUrlTree).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user