@@ -2,44 +2,37 @@ const request = require('supertest');
22const app = require ( '../src/app' ) ;
33
44describe ( 'v3.1 LensEnforcer Smoke Test' , ( ) => {
5- const routes = [ '/aurea/consult-sentences' , '/council/consult-sentences' ] ;
5+ const routes = [ '/aurea/consult-sentences' , '/council/consult-sentences' ] ;
66
7- routes . forEach ( route => {
7+ routes . forEach ( ( route ) => {
88 it ( `ensures ${ route } returns lens metadata + labeled sentences (JSON) or valid SSE headers` , async ( ) => {
99 const res = await request ( app )
1010 . post ( route )
11- . set ( 'Content-Type' , 'application/json' )
1211 . set ( 'Accept' , 'application/json' )
13- . send ( { text : 'Test input for v3.1 smoke test' } )
14- . expect ( 200 ) ;
12+ . send ( { text : 'Test input for v3.1 smoke test' } ) ;
1513
16- const ctype = ( res . headers [ 'content-type' ] || '' ) . toLowerCase ( ) ;
14+ expect ( res . status ) . toBe ( 200 ) ;
1715
18- // JSON mode → enforce v3.1 lens rules strictly
16+ const ctype = ( res . headers [ 'content-type' ] || '' ) . toLowerCase ( ) ;
1917 if ( ctype . includes ( 'application/json' ) ) {
2018 const body = res . body ?? ( res . text ? JSON . parse ( res . text ) : undefined ) ;
2119 expect ( body ) . toBeDefined ( ) ;
22-
2320 expect ( body . meta ) . toBeDefined ( ) ;
2421 expect ( body . meta . lens ) . toBeDefined ( ) ;
2522 expect ( Array . isArray ( body . meta . lens . passed ) ) . toBe ( true ) ;
2623
2724 const sentences = body . sentences || [ ] ;
2825 expect ( sentences . length ) . toBeGreaterThan ( 0 ) ;
2926
30- const allowed = [ 'fact' , 'intuition' , 'metaphor' ] ;
31- sentences . forEach ( s => {
27+ const allowed = [ 'fact' , 'intuition' , 'metaphor' ] ;
28+ sentences . forEach ( ( s ) => {
3229 expect ( Array . isArray ( s . tags ) ) . toBe ( true ) ;
3330 expect ( s . tags . length ) . toBeGreaterThan ( 0 ) ;
3431 expect ( s . tags . some ( t => allowed . includes ( t . type ) ) ) . toBe ( true ) ;
3532 } ) ;
36- return ;
33+ } else {
34+ expect ( ctype ) . toContain ( 'text/event-stream' ) ;
3735 }
38-
39- // SSE mode → assert stable, CI-safe contract
40- expect ( ctype ) . toContain ( 'text/event-stream' ) ;
41- // Don’t attempt to parse the stream body here — Supertest’s parser is flaky for SSE.
42- // The presence of 200 + event-stream is our canary; deeper SSE checks live in runtime canaries.
4336 } ) ;
4437 } ) ;
4538} ) ;
0 commit comments