@@ -11,14 +11,12 @@ import {
1111 ListUsersResponse ,
1212 ConsistencyPreference ,
1313 ErrorCode ,
14- BatchCheckRequest ,
1514 ClientWriteRequestOnDuplicateWrites ,
1615 ClientWriteRequestOnMissingDeletes ,
1716} from "../index" ;
1817import { baseConfig , defaultConfiguration , getNocks } from "./helpers" ;
1918
2019const nocks = getNocks ( nock ) ;
21- nock . disableNetConnect ( ) ;
2220
2321describe ( "OpenFGA Client" , ( ) => {
2422
@@ -1875,7 +1873,8 @@ describe("OpenFGA Client", () => {
18751873 const scope0 = nocks . check ( defaultConfiguration . storeId ! , tuples [ 0 ] , defaultConfiguration . getBasePath ( ) , { allowed : true } ) . matchHeader ( "X-OpenFGA-Client-Method" , "ListRelations" ) ;
18761874 const scope1 = nocks . check ( defaultConfiguration . storeId ! , tuples [ 1 ] , defaultConfiguration . getBasePath ( ) , { allowed : false } ) . matchHeader ( "X-OpenFGA-Client-Method" , "ListRelations" ) ;
18771875 const scope2 = nocks . check ( defaultConfiguration . storeId ! , tuples [ 2 ] , defaultConfiguration . getBasePath ( ) , { allowed : true } ) . matchHeader ( "X-OpenFGA-Client-Method" , "ListRelations" ) ;
1878- const scope3 = nocks . check ( defaultConfiguration . storeId ! , tuples [ 3 ] , defaultConfiguration . getBasePath ( ) , "" as any , 500 ) . matchHeader ( "X-OpenFGA-Client-Method" , "ListRelations" ) ;
1876+ // Mock all default retries+1 to exhaust them all and trigger actual failure.
1877+ const scope3 = Array . from ( { length : 4 } , ( ) => nocks . check ( defaultConfiguration . storeId ! , tuples [ 3 ] , defaultConfiguration . getBasePath ( ) , "" as any , 500 ) . matchHeader ( "X-OpenFGA-Client-Method" , "ListRelations" ) ) ;
18791878 const scope4 = nocks . check ( defaultConfiguration . storeId ! , tuples [ 4 ] , defaultConfiguration . getBasePath ( ) , {
18801879 "code" : "validation_error" ,
18811880 "message" : "relation 'workspace#can_read' not found"
@@ -1890,12 +1889,12 @@ describe("OpenFGA Client", () => {
18901889 expect ( scope0 . isDone ( ) ) . toBe ( false ) ;
18911890 expect ( scope1 . isDone ( ) ) . toBe ( false ) ;
18921891 expect ( scope2 . isDone ( ) ) . toBe ( false ) ;
1893- expect ( scope3 . isDone ( ) ) . toBe ( false ) ;
1892+ expect ( scope3 . every ( scope => scope . isDone ( ) ) ) . toBe ( false ) ;
18941893 expect ( scope4 . isDone ( ) ) . toBe ( false ) ;
18951894 expect ( scope5 . isDone ( ) ) . toBe ( false ) ;
18961895
18971896 try {
1898- const response = await fgaClient . listRelations ( {
1897+ await fgaClient . listRelations ( {
18991898 user : "user:81684243-9356-4421-8fbf-a4f8d36aa31b" ,
19001899 object : "workspace:1" ,
19011900 relations : [ "admin" , "guest" , "reader" , "viewer" ] ,
@@ -1904,7 +1903,7 @@ describe("OpenFGA Client", () => {
19041903 expect ( scope0 . isDone ( ) ) . toBe ( true ) ;
19051904 expect ( scope1 . isDone ( ) ) . toBe ( true ) ;
19061905 expect ( scope2 . isDone ( ) ) . toBe ( true ) ;
1907- expect ( scope3 . isDone ( ) ) . toBe ( true ) ;
1906+ expect ( scope3 . every ( scope => scope . isDone ( ) ) ) . toBe ( true ) ;
19081907 expect ( scope4 . isDone ( ) ) . toBe ( false ) ;
19091908 expect ( scope5 . isDone ( ) ) . toBe ( false ) ;
19101909 expect ( err ) . toBeInstanceOf ( FgaApiError ) ;
0 commit comments