@@ -434,6 +434,49 @@ describe('LlmoController', () => {
434434 expect ( result . status ) . to . equal ( 200 ) ;
435435 expect ( await result . json ( ) ) . to . deep . equal ( { data : 'test-data' } ) ;
436436 } ) ;
437+
438+ it ( 'should handle week parameter in URL construction' , async ( ) => {
439+ const mockResponse = createMockResponse ( { data : 'weekly-data' } ) ;
440+ tracingFetchStub . resolves ( mockResponse ) ;
441+ mockContext . params . sheetType = 'analytics' ;
442+ mockContext . params . week = 'w01' ;
443+
444+ await controller . getLlmoSheetData ( mockContext ) ;
445+
446+ expect ( tracingFetchStub ) . to . have . been . calledWith (
447+ `${ EXTERNAL_API_BASE_URL } /${ TEST_FOLDER } /analytics/w01/test-data.json` ,
448+ sinon . match . object ,
449+ ) ;
450+ } ) ;
451+
452+ it ( 'should handle week parameter with query params' , async ( ) => {
453+ const mockResponse = createMockResponse ( { data : 'weekly-data' } ) ;
454+ tracingFetchStub . resolves ( mockResponse ) ;
455+ mockContext . params . sheetType = 'analytics' ;
456+ mockContext . params . week = 'w02' ;
457+ mockContext . data = { limit : '50' , offset : '10' } ;
458+
459+ await controller . getLlmoSheetData ( mockContext ) ;
460+
461+ expect ( tracingFetchStub ) . to . have . been . calledWith (
462+ `${ EXTERNAL_API_BASE_URL } /${ TEST_FOLDER } /analytics/w02/test-data.json?limit=50&offset=10` ,
463+ sinon . match . object ,
464+ ) ;
465+ } ) ;
466+
467+ it ( 'should ignore week parameter when sheetType is not provided' , async ( ) => {
468+ const mockResponse = createMockResponse ( { data : 'test-data' } ) ;
469+ tracingFetchStub . resolves ( mockResponse ) ;
470+ mockContext . params . week = 'w01' ;
471+ delete mockContext . params . sheetType ;
472+
473+ await controller . getLlmoSheetData ( mockContext ) ;
474+
475+ expect ( tracingFetchStub ) . to . have . been . calledWith (
476+ `${ EXTERNAL_API_BASE_URL } /${ TEST_FOLDER } /test-data.json` ,
477+ sinon . match . object ,
478+ ) ;
479+ } ) ;
437480 } ) ;
438481
439482 describe ( 'getLlmoGlobalSheetData' , ( ) => {
@@ -895,6 +938,68 @@ describe('LlmoController', () => {
895938 sinon . match . object ,
896939 ) ;
897940 } ) ;
941+
942+ it ( 'should handle week parameter in URL construction' , async ( ) => {
943+ tracingFetchStub . resolves ( createMockResponse ( { ':type' : 'sheet' , data : [ ] } ) ) ;
944+ mockContext . params . sheetType = 'analytics' ;
945+ mockContext . params . week = 'w01' ;
946+ mockContext . data = null ;
947+
948+ const result = await controller . queryLlmoSheetData ( mockContext ) ;
949+
950+ expect ( result . status ) . to . equal ( 200 ) ;
951+ expect ( tracingFetchStub ) . to . have . been . calledWith (
952+ `${ EXTERNAL_API_BASE_URL } /${ TEST_FOLDER } /analytics/w01/test-data.json?limit=1000000` ,
953+ sinon . match . object ,
954+ ) ;
955+ } ) ;
956+
957+ it ( 'should handle week parameter with filters and grouping' , async ( ) => {
958+ const mockResponseData = {
959+ ':type' : 'sheet' ,
960+ data : [
961+ {
962+ id : 1 , status : 'active' , week : 'w01' , value : 100 ,
963+ } ,
964+ {
965+ id : 2 , status : 'inactive' , week : 'w01' , value : 200 ,
966+ } ,
967+ ] ,
968+ } ;
969+ tracingFetchStub . resolves ( createMockResponse ( mockResponseData ) ) ;
970+ mockContext . params . sheetType = 'analytics' ;
971+ mockContext . params . week = 'w01' ;
972+ mockContext . data = {
973+ filters : { status : 'active' } ,
974+ groupBy : [ 'status' ] ,
975+ } ;
976+
977+ const result = await controller . queryLlmoSheetData ( mockContext ) ;
978+
979+ expect ( result . status ) . to . equal ( 200 ) ;
980+ expect ( tracingFetchStub ) . to . have . been . calledWith (
981+ `${ EXTERNAL_API_BASE_URL } /${ TEST_FOLDER } /analytics/w01/test-data.json?limit=1000000` ,
982+ sinon . match . object ,
983+ ) ;
984+ const responseBody = await result . json ( ) ;
985+ expect ( responseBody . data ) . to . have . length ( 1 ) ;
986+ expect ( responseBody . data [ 0 ] . status ) . to . equal ( 'active' ) ;
987+ } ) ;
988+
989+ it ( 'should ignore week parameter when sheetType is not provided' , async ( ) => {
990+ tracingFetchStub . resolves ( createMockResponse ( { ':type' : 'sheet' , data : [ ] } ) ) ;
991+ mockContext . params . week = 'w01' ;
992+ delete mockContext . params . sheetType ;
993+ mockContext . data = null ;
994+
995+ const result = await controller . queryLlmoSheetData ( mockContext ) ;
996+
997+ expect ( result . status ) . to . equal ( 200 ) ;
998+ expect ( tracingFetchStub ) . to . have . been . calledWith (
999+ `${ EXTERNAL_API_BASE_URL } /${ TEST_FOLDER } /test-data.json?limit=1000000` ,
1000+ sinon . match . object ,
1001+ ) ;
1002+ } ) ;
8981003 } ) ;
8991004
9001005 describe ( 'getLlmoConfig' , ( ) => {
0 commit comments