1- /**
2- * Copyright 2024-2025 NetCracker Technology Corporation
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-
171/* eslint-disable no-empty-pattern */
182import { type Page , test as base } from '@playwright/test'
19- import { getAuthDataFromStorageStateFile } from '@services/auth'
20- import { SS_SYSADMIN_PATH , SS_USER1_PATH } from '@services/storage-state'
21- import { createRest , type Rest } from '@services/rest'
22- import {
23- type AgentTestDataManager ,
24- type ApihubTestDataManager ,
25- createAgentTDM ,
26- createApihubTDM ,
27- createUsersTDM ,
28- type UsersTestDataManager ,
29- } from '@services/test-data-manager'
30- import { BASE_ORIGIN } from '@test-setup'
3+ import { createRestWithCredentials , type Rest } from '@services/rest'
4+ import { type AgentTestDataManager , type ApihubTestDataManager , createAgentTDM , createApihubTDM , createUsersTDM , type UsersTestDataManager } from '@services/test-data-manager'
5+ import { BASE_URL } from '@test-setup'
6+ import { SYSADMIN , TEST_USER_1 } from '@test-data'
7+ import { createUserStorageStateWithAuthCookieFromApi } from '@services/storage-state/save'
318
329export type Fixtures = {
3310
@@ -45,23 +22,22 @@ export type Fixtures = {
4522export const test = base . extend < Fixtures > ( {
4623
4724 restApihub : async ( { } , use ) => {
48- const authData = await getAuthDataFromStorageStateFile ( SS_SYSADMIN_PATH )
49- const rest = await createRest ( BASE_ORIGIN , authData . token )
25+ const rest = await createRestWithCredentials ( BASE_URL , SYSADMIN )
5026 await use ( rest )
5127 } ,
5228
5329 usersTDM : async ( { } , use ) => {
54- const creator = await createUsersTDM ( SS_SYSADMIN_PATH )
30+ const creator = await createUsersTDM ( SYSADMIN )
5531 await use ( creator )
5632 } ,
5733
5834 apihubTDM : async ( { } , use ) => {
59- const creator = await createApihubTDM ( SS_SYSADMIN_PATH )
35+ const creator = await createApihubTDM ( SYSADMIN )
6036 await use ( creator )
6137 } ,
6238
6339 apihubTdmLongTimeout : async ( { } , use ) => {
64- const creator = await createApihubTDM ( SS_SYSADMIN_PATH , 600000 )
40+ const creator = await createApihubTDM ( SYSADMIN , 600000 )
6541 await use ( creator )
6642 } ,
6743
@@ -71,14 +47,14 @@ export const test = base.extend<Fixtures>({
7147 } ,
7248
7349 sysadminPage : async ( { browser } , use ) => {
74- const context = await browser . newContext ( { storageState : SS_SYSADMIN_PATH } )
50+ const context = await browser . newContext ( { storageState : await createUserStorageStateWithAuthCookieFromApi ( SYSADMIN ) } )
7551 const page = await context . newPage ( )
7652 await use ( page )
7753 await context . close ( )
7854 } ,
7955
8056 user1Page : async ( { browser } , use ) => {
81- const context = await browser . newContext ( { storageState : SS_USER1_PATH } )
57+ const context = await browser . newContext ( { storageState : await createUserStorageStateWithAuthCookieFromApi ( TEST_USER_1 ) } )
8258 const page = await context . newPage ( )
8359 await use ( page )
8460 await context . close ( )
0 commit comments