From 72f9a8d2c25cd53527414460ba243eb5e17807f3 Mon Sep 17 00:00:00 2001 From: Vladyslava <71496479+Vladyslava95@users.noreply.github.com> Date: Fri, 7 Nov 2025 16:30:20 +0200 Subject: [PATCH] Update auth.test.ts --- tests/api/auth.test.ts | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) 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'); +// });