1- // __tests__/sse-contract.test.js
21const request = require ( 'supertest' ) ;
3- const app = require ( '.. /src/app' ) ;
2+ const app = require ( './src/app' ) ;
43
54describe ( 'v3.1 LensEnforcer Smoke Test' , ( ) => {
65 const routes = [
@@ -9,18 +8,15 @@ describe('v3.1 LensEnforcer Smoke Test', () => {
98 ] ;
109
1110 routes . forEach ( route => {
12- it ( `ensures ${ route } returns lens metadata + labeled sentences (JSON or SSE) ` , async ( ) => {
11+ it ( `ensures ${ route } returns lens metadata + labeled sentences (JSON) or valid SSE headers ` , async ( ) => {
1312 const res = await request ( app )
1413 . post ( route )
1514 . set ( 'Accept' , 'application/json' )
1615 . send ( { text : 'Test input for v3.1 smoke test' } ) ;
1716
18- expect ( res . status ) . toBe ( 200 ) ;
17+ const ctype = ( res . headers [ 'content-type' ] || '' ) . toLowerCase ( ) ;
1918
20- const contentType = ( res . headers [ 'content-type' ] || '' ) . toLowerCase ( ) ;
21-
22- if ( contentType . includes ( 'application/json' ) ) {
23- // Parse JSON body safely
19+ if ( ctype . includes ( 'application/json' ) ) {
2420 const body = res . body ?? ( res . text ? JSON . parse ( res . text ) : undefined ) ;
2521 expect ( body ) . toBeDefined ( ) ;
2622 expect ( body . meta ) . toBeDefined ( ) ;
@@ -30,18 +26,17 @@ describe('v3.1 LensEnforcer Smoke Test', () => {
3026 const sentences = body . sentences || [ ] ;
3127 expect ( sentences . length ) . toBeGreaterThan ( 0 ) ;
3228
33- const allowedTags = [ 'fact' , 'intuition' , 'metaphor' ] ;
29+ const allowed = [ 'fact' , 'intuition' , 'metaphor' ] ;
3430 sentences . forEach ( s => {
3531 expect ( Array . isArray ( s . tags ) ) . toBe ( true ) ;
3632 expect ( s . tags . length ) . toBeGreaterThan ( 0 ) ;
37- const hasAllowed = s . tags . some ( t => allowedTags . includes ( t . type ) ) ;
38- expect ( hasAllowed ) . toBe ( true ) ;
33+ expect ( s . tags . some ( t => allowed . includes ( t . type ) ) ) . toBe ( true ) ;
3934 } ) ;
40- } else {
41- // If not JSON, expect valid SSE stream headers
42- expect ( contentType ) . toContain ( 'text/event-stream' ) ;
35+ return ;
4336 }
37+
38+ // SSE: we don't parse body in CI; just assert correct headers
39+ expect ( ctype ) . toContain ( 'text/event-stream' ) ;
4440 } ) ;
4541 } ) ;
4642} ) ;
47-
0 commit comments