File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import ProductService from '@/api/ProductService' ;
2+ import AppConfig from '@/config/AppConfig' ;
3+ import { test } from '@/fixtures/fixtures' ;
4+ import { readCsvFile , readFile , writeToFile } from '@/utils/FileIOUtils' ;
5+
6+ test ( 'import data' , async ( { request } ) => {
7+ // eslint-disable-next-line playwright/no-conditional-in-test
8+ const data = readFile ( AppConfig . TEST_DATA_FILE_PATH ) || { } ;
9+
10+ // PRODUCTS
11+ const productService = new ProductService ( request ) ;
12+
13+ const productsData = readCsvFile ( AppConfig . PRODUCTS_IMPORT_FILE_PATH ) ;
14+
15+ await test . step ( `importing ${ productsData . length } products` , async ( ) => {
16+ const importedData = await productService . importProducts ( productsData ) ;
17+ importedData . data . forEach ( ( product ) => {
18+ data . products [ product . productCode ] = product . id ;
19+ } )
20+ } )
21+
22+ writeToFile ( AppConfig . TEST_DATA_FILE_PATH , data ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments