@@ -55,9 +55,7 @@ describe('qnamaker:build cli parameters test', () => {
5555} )
5656
5757describe ( 'qnamaker:build create a new knowledge base successfully' , ( ) => {
58- before ( async function ( ) {
59- await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
60-
58+ before ( function ( ) {
6159 nock ( 'https://westus.api.cognitive.microsoft.com' )
6260 . get ( uri => uri . includes ( 'qnamaker' ) )
6361 . reply ( 200 , {
@@ -100,29 +98,32 @@ describe('qnamaker:build create a new knowledge base successfully', () => {
10098 nock ( 'https://westus.api.cognitive.microsoft.com' )
10199 . put ( uri => uri . includes ( 'alterations' ) )
102100 . reply ( 204 )
103- } )
104101
105- after ( async function ( ) {
106- await fs . remove ( path . join ( __dirname , './../../../results/' ) )
102+ nock ( 'https://westus.api.cognitive.microsoft.com' )
103+ . get ( uri => uri . includes ( 'endpointkeys' ) )
104+ . reply ( 200 , {
105+ primaryEndpointKey : 'xxxx' ,
106+ secondaryEndpointKey : 'yyyy'
107+ } )
107108 } )
108109
109110 test
110111 . stdout ( )
111- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--out' , './results' ] )
112+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' ] )
112113 . it ( 'should create a new knowledge base successfully' , ctx => {
113114 expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
114115 expect ( ctx . stdout ) . to . contain ( 'Creating qnamaker KB: test(development).en-us.qna...' )
115116 expect ( ctx . stdout ) . to . contain ( 'Creating finished' )
116117 expect ( ctx . stdout ) . to . contain ( 'Publishing kb' )
117118 expect ( ctx . stdout ) . to . contain ( 'Publishing finished' )
118119 expect ( ctx . stdout ) . to . contain ( 'Replacing alterations...' )
120+ expect ( ctx . stdout ) . to . contain ( 'xxxx' )
121+ expect ( ctx . stdout ) . to . contain ( 'yyyy' )
119122 } )
120123} )
121124
122125describe ( 'qnamaker:build update knowledge base succeed when qa changed' , ( ) => {
123- before ( async function ( ) {
124- await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
125-
126+ before ( function ( ) {
126127 nock ( 'https://westus.api.cognitive.microsoft.com' )
127128 . get ( uri => uri . includes ( 'qnamaker' ) )
128129 . reply ( 200 , {
@@ -153,15 +154,18 @@ describe('qnamaker:build update knowledge base succeed when qa changed', () => {
153154 nock ( 'https://westus.api.cognitive.microsoft.com' )
154155 . post ( uri => uri . includes ( 'knowledgebases' ) )
155156 . reply ( 204 )
156- } )
157-
158- after ( async function ( ) {
159- await fs . remove ( path . join ( __dirname , './../../../results/' ) )
157+
158+ nock ( 'https://westus.api.cognitive.microsoft.com' )
159+ . get ( uri => uri . includes ( 'endpointkeys' ) )
160+ . reply ( 200 , {
161+ primaryEndpointKey : 'xxxx' ,
162+ secondaryEndpointKey : 'yyyy'
163+ } )
160164 } )
161165
162166 test
163167 . stdout ( )
164- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--out' , './results' ] )
168+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' ] )
165169 . it ( 'should update a knowledge base when qa list changed' , ctx => {
166170 expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
167171 expect ( ctx . stdout ) . to . contain ( 'Updating to new version for kb test(development).en-us.qna' )
@@ -172,8 +176,6 @@ describe('qnamaker:build update knowledge base succeed when qa changed', () => {
172176
173177describe ( 'qnamaker:build not update knowledge if no changes' , ( ) => {
174178 before ( async function ( ) {
175- await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
176-
177179 nock ( 'https://westus.api.cognitive.microsoft.com' )
178180 . get ( uri => uri . includes ( 'qnamaker' ) )
179181 . reply ( 200 , {
@@ -196,15 +198,18 @@ describe('qnamaker:build not update knowledge if no changes', () => {
196198 metadata : [ ]
197199 } ]
198200 } )
199- } )
200201
201- after ( async function ( ) {
202- await fs . remove ( path . join ( __dirname , './../../../results/' ) )
202+ nock ( 'https://westus.api.cognitive.microsoft.com' )
203+ . get ( uri => uri . includes ( 'endpointkeys' ) )
204+ . reply ( 200 , {
205+ primaryEndpointKey : 'xxxx' ,
206+ secondaryEndpointKey : 'yyyy'
207+ } )
203208 } )
204209
205210 test
206211 . stdout ( )
207- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--out' , './results' ] )
212+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' ] )
208213 . it ( 'should not update a knowledge base when no changes' , ctx => {
209214 expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
210215 expect ( ctx . stdout ) . to . contain ( 'no changes' )
@@ -237,6 +242,13 @@ describe('qnamaker:build write dialog assets successfully if --dialog set to mul
237242 metadata : [ ]
238243 } ]
239244 } )
245+
246+ nock ( 'https://westus.api.cognitive.microsoft.com' )
247+ . get ( uri => uri . includes ( 'endpointkeys' ) )
248+ . reply ( 200 , {
249+ primaryEndpointKey : 'xxxx' ,
250+ secondaryEndpointKey : 'yyyy'
251+ } )
240252 } )
241253
242254 after ( async function ( ) {
@@ -245,8 +257,11 @@ describe('qnamaker:build write dialog assets successfully if --dialog set to mul
245257
246258 test
247259 . stdout ( )
248- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--dialog' , 'multiLanguage' , '-- out', './results' , '--log' , '--suffix' , 'development' ] )
260+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--out' , './results' , '--log' , '--suffix' , 'development' ] )
249261 . it ( 'should write dialog assets successfully when --dialog set to multiLanguage' , async ctx => {
262+ expect ( ctx . stdout ) . to . contain ( 'xxxx' )
263+ expect ( ctx . stdout ) . to . contain ( 'yyyy' )
264+
250265 expect ( await compareFiles ( './../../../results/qnamaker.settings.development.westus.json' , './../../fixtures/testcases/qnabuild/sandwich/config/qnamaker.settings.development.westus.json' ) ) . to . be . true
251266 expect ( await compareFiles ( './../../../results/test.en-us.qna.dialog' , './../../fixtures/testcases/qnabuild/sandwich/dialogs/test.en-us.qna.dialog' ) ) . to . be . true
252267 expect ( await compareFiles ( './../../../results/test.qna.dialog' , './../../fixtures/testcases/qnabuild/sandwich/dialogs/test.qna.dialog' ) ) . to . be . true
@@ -279,6 +294,13 @@ describe('qnamaker:build write dialog assets successfully if --dialog set to cro
279294 metadata : [ ]
280295 } ]
281296 } )
297+
298+ nock ( 'https://westus.api.cognitive.microsoft.com' )
299+ . get ( uri => uri . includes ( 'endpointkeys' ) )
300+ . reply ( 200 , {
301+ primaryEndpointKey : 'xxxx' ,
302+ secondaryEndpointKey : 'yyyy'
303+ } )
282304 } )
283305
284306 after ( async function ( ) {
@@ -345,6 +367,13 @@ describe('qnamaker:build write dialog assets successfully with multi locales', (
345367 metadata : [ ]
346368 } ]
347369 } )
370+
371+ nock ( 'https://westus.api.cognitive.microsoft.com' )
372+ . get ( uri => uri . includes ( 'endpointkeys' ) )
373+ . reply ( 200 , {
374+ primaryEndpointKey : 'xxxx' ,
375+ secondaryEndpointKey : 'yyyy'
376+ } )
348377 } )
349378
350379 after ( async function ( ) {
@@ -363,9 +392,7 @@ describe('qnamaker:build write dialog assets successfully with multi locales', (
363392} )
364393
365394describe ( 'qnamaker:build not update knowledge base if only cases are changed' , ( ) => {
366- before ( async function ( ) {
367- await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
368-
395+ before ( function ( ) {
369396 nock ( 'https://westus.api.cognitive.microsoft.com' )
370397 . get ( uri => uri . includes ( 'qnamaker' ) )
371398 . reply ( 200 , {
@@ -388,25 +415,26 @@ describe('qnamaker:build not update knowledge base if only cases are changed', (
388415 metadata : [ ]
389416 } ]
390417 } )
391- } )
392418
393- after ( async function ( ) {
394- await fs . remove ( path . join ( __dirname , './../../../results/' ) )
419+ nock ( 'https://westus.api.cognitive.microsoft.com' )
420+ . get ( uri => uri . includes ( 'endpointkeys' ) )
421+ . reply ( 200 , {
422+ primaryEndpointKey : 'xxxx' ,
423+ secondaryEndpointKey : 'yyyy'
424+ } )
395425 } )
396426
397427 test
398428 . stdout ( )
399- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--out' , './results' ] )
429+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/sandwich/qnafiles/sandwich2.en-us.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' ] )
400430 . it ( 'should not update a knowledge base when only cases changed' , ctx => {
401431 expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
402432 expect ( ctx . stdout ) . to . contain ( 'no changes' )
403433 } )
404434} )
405435
406436describe ( 'qnamaker:build create a new knowledge base with multiturn qna successfully' , ( ) => {
407- before ( async function ( ) {
408- await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
409-
437+ before ( function ( ) {
410438 nock ( 'https://westus.api.cognitive.microsoft.com' )
411439 . get ( uri => uri . includes ( 'qnamaker' ) )
412440 . reply ( 200 , {
@@ -445,15 +473,18 @@ describe('qnamaker:build create a new knowledge base with multiturn qna successf
445473 id : 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
446474 hostName : 'https://myqnamakerbot.azurewebsites.net'
447475 } )
448- } )
449476
450- after ( async function ( ) {
451- await fs . remove ( path . join ( __dirname , './../../../results/' ) )
477+ nock ( 'https://westus.api.cognitive.microsoft.com' )
478+ . get ( uri => uri . includes ( 'endpointkeys' ) )
479+ . reply ( 200 , {
480+ primaryEndpointKey : 'xxxx' ,
481+ secondaryEndpointKey : 'yyyy'
482+ } )
452483 } )
453484
454485 test
455486 . stdout ( )
456- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/multiturn/multiturn.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--out' , './results' ] )
487+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/multiturn/multiturn.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' ] )
457488 . it ( 'should create a new knowledge base with multiturn qna successfully' , ctx => {
458489 expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
459490 expect ( ctx . stdout ) . to . contain ( 'Creating qnamaker KB: test(development).en-us.qna...' )
@@ -464,9 +495,7 @@ describe('qnamaker:build create a new knowledge base with multiturn qna successf
464495} )
465496
466497describe ( 'qnamaker:build update knowledge base with multiturn successfully when qa changed' , ( ) => {
467- before ( async function ( ) {
468- await fs . ensureDir ( path . join ( __dirname , './../../../results/' ) )
469-
498+ before ( function ( ) {
470499 nock ( 'https://westus.api.cognitive.microsoft.com' )
471500 . get ( uri => uri . includes ( 'qnamaker' ) )
472501 . reply ( 200 , {
@@ -497,15 +526,18 @@ describe('qnamaker:build update knowledge base with multiturn successfully when
497526 nock ( 'https://westus.api.cognitive.microsoft.com' )
498527 . post ( uri => uri . includes ( 'knowledgebases' ) )
499528 . reply ( 204 )
500- } )
501529
502- after ( async function ( ) {
503- await fs . remove ( path . join ( __dirname , './../../../results/' ) )
530+ nock ( 'https://westus.api.cognitive.microsoft.com' )
531+ . get ( uri => uri . includes ( 'endpointkeys' ) )
532+ . reply ( 200 , {
533+ primaryEndpointKey : 'xxxx' ,
534+ secondaryEndpointKey : 'yyyy'
535+ } )
504536 } )
505537
506538 test
507539 . stdout ( )
508- . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/multiturn/multiturn.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' , '--out' , './results' ] )
540+ . command ( [ 'qnamaker:build' , '--in' , './test/fixtures/testcases/qnabuild/multiturn/multiturn.qna' , '--subscriptionKey' , uuidv1 ( ) , '--botName' , 'test' , '--log' , '--suffix' , 'development' ] )
509541 . it ( 'should update a knowledge base with multiturn when qa list changed' , ctx => {
510542 expect ( ctx . stdout ) . to . contain ( 'Handling qnamaker knowledge bases...' )
511543 expect ( ctx . stdout ) . to . contain ( 'Updating to new version' )
0 commit comments