@@ -7,7 +7,7 @@ const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
77test ( 'no runtime running' , async ( t ) => {
88 const server = await getServer ( t )
99 const res = await server . inject ( {
10- url : '/runtimes'
10+ url : '/runtimes?includeAdmin=true '
1111 } )
1212 assert . strictEqual ( res . statusCode , 200 )
1313 assert . deepStrictEqual ( res . json ( ) , [ ] , 'with no runtime running' )
@@ -23,13 +23,12 @@ test('runtime is running', async (t) => {
2323 await startWatt ( t )
2424 const server = await getServer ( t )
2525 const res = await server . inject ( {
26- url : '/runtimes'
26+ url : '/runtimes?includeAdmin=true '
2727 } )
2828 assert . strictEqual ( res . statusCode , 200 , 'runtimes endpoint' )
2929 const [ runtime ] = res . json ( )
3030 const runtimePid = runtime . pid
31- assert . strictEqual ( runtime . packageName , 'backend' )
32- assert . strictEqual ( typeof runtime . packageName , 'string' )
31+ assert . strictEqual ( runtime . packageName , 'watt-admin' )
3332 assert . strictEqual ( typeof runtimePid , 'number' )
3433 assert . strictEqual ( runtime . packageVersion , null )
3534
@@ -45,8 +44,8 @@ test('runtime is running', async (t) => {
4544 assert . strictEqual ( services . statusCode , 200 , 'services endpoint' )
4645 const servicesJson = services . json ( )
4746 assert . strictEqual ( servicesJson . production , true )
48- assert . strictEqual ( servicesJson . entrypoint , 'backend ' )
49- assert . strictEqual ( typeof servicesJson . services [ 0 ] . url , 'string' )
47+ assert . strictEqual ( servicesJson . entrypoint , 'composer ' )
48+ assert . strictEqual ( typeof servicesJson . services [ 0 ] . localUrl , 'string' )
5049 assert . strictEqual ( typeof servicesJson . services [ 0 ] . entrypoint , 'boolean' )
5150
5251 // Wait for the interval to be run
@@ -101,25 +100,6 @@ test('runtime is running', async (t) => {
101100 responses : { 200 : { description : 'Default Response' } } ,
102101 } ,
103102 } )
104- assert . deepEqual ( json . paths [ '/runtimes/{pid}/reload' ] , {
105- post : {
106- parameters : [
107- {
108- schema : {
109- type : 'number' ,
110- } ,
111- in : 'path' ,
112- name : 'pid' ,
113- required : true ,
114- } ,
115- ] ,
116- responses : {
117- 200 : {
118- description : 'Default Response' ,
119- } ,
120- } ,
121- } ,
122- } )
123103
124104 const serviceInvalidOpenapi = await server . inject ( {
125105 url : `/runtimes/${ runtimePid } /openapi/fantozzi`
@@ -132,18 +112,18 @@ test('runtime is running', async (t) => {
132112 } )
133113 assert . strictEqual ( logs . statusCode , 200 )
134114
135- const [ starting , listening , started , platformatic ] = logs . body . trim ( ) . split ( '\n' )
136- assert . ok ( starting . includes ( 'Starting the service' ) )
137- assert . ok ( listening . includes ( 'Server listening at http://127.0.0.1 ' ) )
138- assert . ok ( started . includes ( 'Started the service' ) )
139- assert . ok ( platformatic . includes ( 'Platformatic is now listening at http://127.0.0.1 ' ) )
115+ const [ starting , listening , started , platformatic ] = logs . body . trim ( ) . split ( '\n' ) . filter ( val => ! val . includes ( 'Loading envfile' ) )
116+ assert . ok ( starting . includes ( 'Starting the service \\"backend\\" ' ) )
117+ assert . ok ( listening . includes ( 'Started the service \\"backend\\" ' ) )
118+ assert . ok ( started . includes ( 'Starting the service \\"frontend\\" ' ) )
119+ assert . ok ( platformatic . includes ( 'Started the service \\"frontend\\" ' ) )
140120} )
141121
142- test ( 'runtime start & stop ' , async ( t ) => {
122+ test ( 'runtime restart ' , async ( t ) => {
143123 await startWatt ( t )
144124 const server = await getServer ( t )
145125 const res = await server . inject ( {
146- url : '/runtimes'
126+ url : '/runtimes?includeAdmin=true '
147127 } )
148128 const [ { pid } ] = res . json ( )
149129 assert . ok ( pid > 0 )
@@ -153,6 +133,16 @@ test('runtime start & stop', async (t) => {
153133 url : `/runtimes/${ pid } /restart`
154134 } )
155135 assert . strictEqual ( restart . statusCode , 200 )
136+ } )
137+
138+ test ( 'runtime stop' , async ( t ) => {
139+ await startWatt ( t )
140+ const server = await getServer ( t )
141+ const res = await server . inject ( {
142+ url : '/runtimes?includeAdmin=true'
143+ } )
144+ const [ { pid } ] = res . json ( )
145+ assert . ok ( pid > 0 )
156146
157147 const { statusCode } = await server . inject ( {
158148 method : 'POST' ,
@@ -167,7 +157,7 @@ test('runtime start & stop', async (t) => {
167157 assert . strictEqual ( stop . statusCode , 500 , 'trying to run stop command to a closed runtime' )
168158
169159 const runtimes = await server . inject ( {
170- url : '/runtimes'
160+ url : '/runtimes?includeAdmin=true '
171161 } )
172162 assert . deepEqual ( runtimes . json ( ) , [ ] , 'no runtime running' )
173163} )
0 commit comments