1+ async function processItem ( item , basePath ) {
2+ const helperPath = '../../helper/request.helper' ;
3+ const mainpagesPath = './main.pages'
4+
5+ if ( item . hasOwnProperty ( 'item' ) ) {
6+ const testPath = 'tests/scenarios/' + item . name
7+ const testRelativePath = '../tests/scenarios/' + item . name
8+ const pagesPath = 'tests/pages/' + item . name
9+ const pagesPathRelativePath = '../../pages/' + item . name
10+ const jsonSchemaPath = 'tests/schema/' + item . name
11+ const jsonSchemaRelativePath = '../../schema/' + item . name
12+ let runPath = item . hasOwnProperty ( 'item' ) ? 'runner/' + item . name : 'runner'
13+
14+ fs . mkdirSync ( testPath , { recursive : true } )
15+ fs . mkdirSync ( pagesPath , { recursive : true } )
16+ fs . mkdirSync ( jsonSchemaPath , { recursive : true } )
17+ fs . mkdirSync ( runPath , { recursive : true } )
18+ writeRunner ( item , testRelativePath , runPath )
19+
20+ asyncForEach ( item . item , async ( data ) => {
21+ if ( data . hasOwnProperty ( 'item' ) ) {
22+ for ( const innerItem of data . item ) {
23+ console . log ( innerItem ) ;
24+ await processItem ( innerItem , 'tests/' + innerItem . name ) ;
25+ }
26+ } else {
27+ writeTest ( data , testPath , pagesPathRelativePath )
28+ writePages ( data , pagesPath , jsonSchemaRelativePath , helperPath , mainpagesPath )
29+ writeJsonSchema ( data , jsonSchemaPath )
30+ await waitFor ( 10 )
31+ }
32+ } )
33+ } else {
34+ const testPath = 'tests/scenarios/'
35+ const testRelativePath = '../tests/scenarios'
36+ const pagesPath = 'tests/pages'
37+ const pagesPathRelativePath = '../pages'
38+ const jsonSchemaPath = 'tests/schema'
39+ const jsonSchemaRelativePath = '../schema'
40+ const runPath = 'runner'
41+
42+ fs . mkdirSync ( testPath , { recursive : true } )
43+ fs . mkdirSync ( pagesPath , { recursive : true } )
44+ fs . mkdirSync ( jsonSchemaPath , { recursive : true } )
45+ fs . mkdirSync ( runPath , { recursive : true } )
46+
47+ writeRunner ( item , testRelativePath , runPath )
48+ writeTest ( item , testPath , pagesPathRelativePath )
49+ writePages ( item , pagesPath , jsonSchemaRelativePath , helperPath , mainpagesPath )
50+ writeJsonSchema ( item , jsonSchemaPath )
51+ await waitFor ( 10 )
52+ }
53+ }
54+
55+ asyncForEach ( items , async ( element ) => {
56+ // Recursively process inner items
57+ const basePath = 'tests' ;
58+ await processItem ( element , basePath ) ;
59+ // }
60+ } )
0 commit comments