import { test, expect } from '../fixtures';

test.describe('POST /auth/refresh', () => {
  test('refreshes tokens with valid refresh token', async ({ request, testTokens }) => {
    const res = await request.post('auth/refresh', {
      data: { refreshToken: testTokens.refreshToken },
    });

    expect([200, 201]).toContain(res.status());
    const body = await res.json();
    expect(body).toHaveProperty('accessToken');
    expect(body).toHaveProperty('refreshToken');
  });

  test('rejects invalid refresh token', async ({ request }) => {
    const res = await request.post('auth/refresh', {
      data: { refreshToken: 'invalid-refresh-token' },
    });

    expect(res.ok()).toBeFalsy();
  });
});
