diff --git a/tests/api/auth.test.ts b/tests/api/auth.test.ts index fb76220..28a3db6 100644 --- a/tests/api/auth.test.ts +++ b/tests/api/auth.test.ts @@ -1,13 +1,25 @@ -import { test, expect } from '@playwright/test'; +import { test } from './fixtures/base'; +import { expect } from '@playwright/test'; +import { randomUUID } from 'node:crypto'; +// TO DO: investigate how run test with auth and without it -test.fixme('should return success response if the Autorization header is right', async () => { - // const response = await fetchListOfReports(env.API_TOKEN as string); - // expect(response.status).toBe(200); - // expect(await response.text()).not.toBe('Unauthorized'); -}); +// test ('should return success response if the Autorization header is right', async ({request}) => { +// const token = process.env.API_TOKEN; +// const response = await request.get('/api/result/list', { +// headers: { +// Authorization: `${token}`, +// }, +// }); +// expect(response.status()).toBe(200); +// expect(await response.text()).not.toBe('Unauthorized'); +// }); -test.fixme('should return unauthorised if the Autorization header is wrong', async () => { - // const response = await fetchListOfReports(randomUUID()); - // expect(response.status).toBe(401); - // expect(await response.text()).toBe('Unauthorized'); -}); +// test ('should return unauthorised if the Autorization header is wrong', async ({request}) => { +// const response = await request.get('/api/report/list', { +// headers: { +// Authorization: `Bearer ${randomUUID()}`, +// }, +// }); +// expect(response.status()).toBe(401); +// expect(await response.text()).toBe('Unauthorized'); +// });