fix(auth): send login token in POST body

This commit is contained in:
Orvanix
2026-03-12 17:15:07 +00:00
parent b20673e7ea
commit 81712ad3ce
4 changed files with 20 additions and 15 deletions
+10 -10
View File
@@ -19,7 +19,7 @@ vi.mock('@/lib/utils/jwt', () => ({
generateRefreshToken: generateRefreshTokenMock,
}));
describe('GET /api/auth/token/login', () => {
describe('POST /api/auth/token/login', () => {
beforeEach(() => {
vi.clearAllMocks();
generateAccessTokenMock.mockReturnValue('access-token');
@@ -37,9 +37,9 @@ describe('GET /api/auth/token/login', () => {
});
prismaMock.user.update.mockResolvedValueOnce({});
const { GET } = await import('@/app/api/auth/token/login/route');
const request = { nextUrl: { searchParams: new URLSearchParams('token=rmab_valid_token') } };
const response = await GET(request as any);
const { POST } = await import('@/app/api/auth/token/login/route');
const request = { json: vi.fn().mockResolvedValue({ token: 'rmab_valid_token' }) };
const response = await POST(request as any);
const payload = await response.json();
expect(response.status).toBe(200);
@@ -50,9 +50,9 @@ describe('GET /api/auth/token/login', () => {
});
it('returns 400 when token parameter is missing', async () => {
const { GET } = await import('@/app/api/auth/token/login/route');
const request = { nextUrl: { searchParams: new URLSearchParams() } };
const response = await GET(request as any);
const { POST } = await import('@/app/api/auth/token/login/route');
const request = { json: vi.fn().mockResolvedValue({}) };
const response = await POST(request as any);
const payload = await response.json();
expect(response.status).toBe(400);
@@ -62,9 +62,9 @@ describe('GET /api/auth/token/login', () => {
it('returns 401 when token is invalid or user not found', async () => {
prismaMock.user.findFirst.mockResolvedValueOnce(null);
const { GET } = await import('@/app/api/auth/token/login/route');
const request = { nextUrl: { searchParams: new URLSearchParams('token=rmab_invalid') } };
const response = await GET(request as any);
const { POST } = await import('@/app/api/auth/token/login/route');
const request = { json: vi.fn().mockResolvedValue({ token: 'rmab_invalid' }) };
const response = await POST(request as any);
const payload = await response.json();
expect(response.status).toBe(401);