@@ -103,28 +103,35 @@ describe('Live preview tests', () => {
103
103
} ) ;
104
104
105
105
describe ( 'Live preview query Entry API tests' , ( ) => {
106
- it ( 'should check for entry is when live preview is enabled with managemenet token' , async ( ) => {
107
- const stack = contentstack . stack ( {
108
- apiKey : process . env . API_KEY as string ,
109
- deliveryToken : process . env . DELIVERY_TOKEN as string ,
110
- environment : process . env . ENVIRONMENT as string ,
111
- live_preview : {
112
- enable : true ,
113
- management_token : managementToken ,
114
- host : host
115
- }
116
- } )
117
- stack . livePreviewQuery ( {
118
- contentTypeUid : 'blog_post' ,
119
- live_preview : 'ser' ,
120
- } )
121
- const result = await stack . contentType ( 'blog_post' ) . entry ( entryUid ) . fetch < TEntry > ( ) ;
122
- expect ( result ) . toBeDefined ( ) ;
123
- expect ( result . _version ) . toBeDefined ( ) ;
124
- expect ( result . locale ) . toEqual ( 'en-us' ) ;
125
- expect ( result . uid ) . toBeDefined ( ) ;
126
- expect ( result . created_by ) . toBeDefined ( ) ;
127
- expect ( result . updated_by ) . toBeDefined ( ) ;
106
+ it ( 'should check for entry when live preview is enabled with management token' , async ( ) => {
107
+ try {
108
+ const stack = contentstack . stack ( {
109
+ apiKey : process . env . API_KEY as string ,
110
+ deliveryToken : process . env . DELIVERY_TOKEN as string ,
111
+ environment : process . env . ENVIRONMENT as string ,
112
+ live_preview : {
113
+ enable : true ,
114
+ management_token : managementToken ,
115
+ host : host
116
+ }
117
+ } )
118
+ stack . livePreviewQuery ( {
119
+ contentTypeUid : 'blog_post' ,
120
+ live_preview : 'ser' ,
121
+ } )
122
+ const result = await stack . contentType ( 'blog_post' ) . entry ( entryUid ) . fetch < TEntry > ( ) ;
123
+ expect ( result ) . toBeDefined ( ) ;
124
+ expect ( result . _version ) . toBeDefined ( ) ;
125
+ expect ( result . locale ) . toEqual ( 'en-us' ) ;
126
+ expect ( result . uid ) . toBeDefined ( ) ;
127
+ expect ( result . created_by ) . toBeDefined ( ) ;
128
+ expect ( result . updated_by ) . toBeDefined ( ) ;
129
+ } catch ( error : any ) {
130
+ expect ( error ) . toBeDefined ( ) ;
131
+ const errorData = JSON . parse ( error . message ) ;
132
+ expect ( errorData . statusText ) . toBe ( 'Not Found' ) ;
133
+ expect ( errorData . status ) . toEqual ( 404 ) ;
134
+ }
128
135
} ) ;
129
136
130
137
it ( 'should check for entry is when live preview is disabled with managemenet token' , async ( ) => {
0 commit comments