@@ -1526,6 +1526,96 @@ should return all found rows with search, pagination: page=1, perPage=2 and DESC
15261526 } ,
15271527) ;
15281528
1529+ test . serial ( `${ currentTest } with search, with pagination, with sorting and with filtering by id
1530+ should return all found rows with search, pagination: page=1, perPage=2 and DESC sorting and with multi filtering` , async ( t ) => {
1531+ try {
1532+ const connectionToTestDB = getTestData ( mockFactory ) . dynamoDBConnection ;
1533+ const firstUserToken = ( await registerUserAndReturnUserInfo ( app ) ) . token ;
1534+ const { testTableName, testTableColumnName, insertedSearchedIds } = await createTestTable ( connectionToTestDB ) ;
1535+
1536+ testTables . push ( testTableName ) ;
1537+
1538+ const createConnectionResponse = await request ( app . getHttpServer ( ) )
1539+ . post ( '/connection' )
1540+ . send ( connectionToTestDB )
1541+ . set ( 'Cookie' , firstUserToken )
1542+ . set ( 'Content-Type' , 'application/json' )
1543+ . set ( 'Accept' , 'application/json' ) ;
1544+ const createConnectionRO = JSON . parse ( createConnectionResponse . text ) ;
1545+ t . is ( createConnectionResponse . status , 201 ) ;
1546+
1547+ const createTableSettingsDTO = mockFactory . generateTableSettings (
1548+ createConnectionRO . id ,
1549+ testTableName ,
1550+ [ ] ,
1551+ undefined ,
1552+ undefined ,
1553+ 3 ,
1554+ QueryOrderingEnum . DESC ,
1555+ 'id' ,
1556+ undefined ,
1557+ undefined ,
1558+ undefined ,
1559+ undefined ,
1560+ undefined ,
1561+ ) ;
1562+
1563+ const createTableSettingsResponse = await request ( app . getHttpServer ( ) )
1564+ . post ( `/settings?connectionId=${ createConnectionRO . id } &tableName=${ testTableName } ` )
1565+ . send ( createTableSettingsDTO )
1566+ . set ( 'Cookie' , firstUserToken )
1567+ . set ( 'Content-Type' , 'application/json' )
1568+ . set ( 'Accept' , 'application/json' ) ;
1569+ t . is ( createTableSettingsResponse . status , 201 ) ;
1570+
1571+ const fieldname = 'age' ;
1572+ const idFieldName = 'id' ;
1573+ const idFieldValue = 21 ;
1574+ const fieldGtvalue = 14 ;
1575+ // const fieldLtvalue = 95;
1576+
1577+ const filters = {
1578+ // [fieldname]: { gt: fieldGtvalue },
1579+ [ idFieldName ] : { eq : idFieldValue } ,
1580+ } ;
1581+
1582+ const getTableRowsResponse = await request ( app . getHttpServer ( ) )
1583+ . post (
1584+ `/table/rows/find/${ createConnectionRO . id } ?tableName=${ testTableName } &page=1&perPage=3` ,
1585+ )
1586+ . send ( { filters } )
1587+ . set ( 'Cookie' , firstUserToken )
1588+ . set ( 'Content-Type' , 'application/json' )
1589+ . set ( 'Accept' , 'application/json' ) ;
1590+ t . is ( getTableRowsResponse . status , 201 ) ;
1591+
1592+ const getTableRowsRO = JSON . parse ( getTableRowsResponse . text ) ;
1593+ console . log ( '🚀 ~ getTableRowsRO:' , getTableRowsRO . rows ) ;
1594+
1595+ t . is ( typeof getTableRowsRO , 'object' ) ;
1596+ t . is ( getTableRowsRO . hasOwnProperty ( 'rows' ) , true ) ;
1597+ t . is ( getTableRowsRO . hasOwnProperty ( 'primaryColumns' ) , true ) ;
1598+ t . is ( getTableRowsRO . hasOwnProperty ( 'pagination' ) , true ) ;
1599+ t . is ( getTableRowsRO . rows . length , 1 ) ;
1600+ t . is ( Object . keys ( getTableRowsRO . rows [ 0 ] ) . length , 11 ) ;
1601+
1602+ const findRowId = 21 ;
1603+
1604+ t . is ( getTableRowsRO . rows [ 0 ] . id , findRowId ) ;
1605+ t . is ( getTableRowsRO . rows [ 0 ] [ testTableColumnName ] , testSearchedUserName ) ;
1606+
1607+ t . is ( getTableRowsRO . pagination . currentPage , 1 ) ;
1608+ t . is ( getTableRowsRO . pagination . perPage , 3 ) ;
1609+
1610+ t . is ( typeof getTableRowsRO . primaryColumns , 'object' ) ;
1611+ t . is ( getTableRowsRO . primaryColumns [ 0 ] . hasOwnProperty ( 'column_name' ) , true ) ;
1612+ t . is ( getTableRowsRO . primaryColumns [ 0 ] . hasOwnProperty ( 'data_type' ) , true ) ;
1613+ } catch ( e ) {
1614+ console . error ( e ) ;
1615+ throw e ;
1616+ }
1617+ } ) ;
1618+
15291619test . serial ( `${ currentTest } should throw an exception when connection id is not passed in request` , async ( t ) => {
15301620 try {
15311621 const connectionToTestDB = getTestData ( mockFactory ) . dynamoDBConnection ;
0 commit comments