@@ -71,49 +71,47 @@ describe("Cursor usage limits", () => {
7171 } ) ;
7272
7373 it . effect ( "reads the instance's credentials and endpoint even when usage enabled is false" , ( ) =>
74- Effect . gen ( function * ( ) {
75- yield * withNodeServices (
76- Effect . gen ( function * ( ) {
77- const fs = yield * FileSystem . FileSystem ;
78- const path = yield * Path . Path ;
79- const directory = yield * fs . makeTempDirectoryScoped ( ) ;
80- yield * fs . makeDirectory ( path . join ( directory , "cursor" ) ) ;
81- yield * fs . writeFileString (
82- path . join ( directory , "cursor" , "auth.json" ) ,
83- '{"accessToken":"instance-token"}' ,
74+ withNodeServices (
75+ Effect . gen ( function * ( ) {
76+ const fs = yield * FileSystem . FileSystem ;
77+ const path = yield * Path . Path ;
78+ const directory = yield * fs . makeTempDirectoryScoped ( ) ;
79+ yield * fs . makeDirectory ( path . join ( directory , "cursor" ) ) ;
80+ yield * fs . writeFileString (
81+ path . join ( directory , "cursor" , "auth.json" ) ,
82+ '{"accessToken":"instance-token"}' ,
83+ ) ;
84+ const client = HttpClient . make ( ( request ) => {
85+ expect ( request . url ) . toBe (
86+ "https://cursor.example/aiserver.v1.DashboardService/GetCurrentPeriodUsage" ,
8487 ) ;
85- const client = HttpClient . make ( ( request ) => {
86- expect ( request . url ) . toBe (
87- "https://cursor.example/aiserver.v1.DashboardService/GetCurrentPeriodUsage" ,
88- ) ;
89- expect ( request . method ) . toBe ( "POST" ) ;
90- expect ( request . headers . authorization ) . toBe ( "Bearer instance-token" ) ;
91- expect ( request . headers [ "connect-protocol-version" ] ) . toBe ( "1" ) ;
92- return Effect . succeed (
93- HttpClientResponse . fromWeb (
94- request ,
95- Response . json ( { enabled : false , planUsage : { totalPercentUsed : 42 } } ) ,
96- ) ,
97- ) ;
98- } ) ;
99- yield * fs . makeDirectory ( path . join ( directory , ".cursor" ) ) ;
100- yield * fs . writeFileString (
101- path . join ( directory , ".cursor" , "auth.json" ) ,
102- '{"accessToken":"instance-token"}' ,
88+ expect ( request . method ) . toBe ( "POST" ) ;
89+ expect ( request . headers . authorization ) . toBe ( "Bearer instance-token" ) ;
90+ expect ( request . headers [ "connect-protocol-version" ] ) . toBe ( "1" ) ;
91+ return Effect . succeed (
92+ HttpClientResponse . fromWeb (
93+ request ,
94+ Response . json ( { enabled : false , planUsage : { totalPercentUsed : 42 } } ) ,
95+ ) ,
10396 ) ;
104- for ( const platform of [ "linux" , "darwin" ] as const ) {
105- const limits = yield * readCursorUsageLimits (
106- { apiEndpoint : "https://cursor.example/" } ,
107- { XDG_CONFIG_HOME : directory , HOME : directory , AGENT_CLI_CREDENTIAL_STORE : "file" } ,
108- ) . pipe (
109- Effect . provideService ( HostProcess . Platform , platform ) ,
110- Effect . provideService ( HttpClient . HttpClient , client ) ,
111- ) ;
112- expect ( limits . windows [ 0 ] ?. usedPercent ) . toBe ( 42 ) ;
113- }
114- } ) . pipe ( Effect . scoped ) ,
115- ) ;
116- } ) ,
97+ } ) ;
98+ yield * fs . makeDirectory ( path . join ( directory , ".cursor" ) ) ;
99+ yield * fs . writeFileString (
100+ path . join ( directory , ".cursor" , "auth.json" ) ,
101+ '{"accessToken":"instance-token"}' ,
102+ ) ;
103+ for ( const platform of [ "linux" , "darwin" ] as const ) {
104+ const limits = yield * readCursorUsageLimits (
105+ { apiEndpoint : "https://cursor.example/" } ,
106+ { XDG_CONFIG_HOME : directory , HOME : directory , AGENT_CLI_CREDENTIAL_STORE : "file" } ,
107+ ) . pipe (
108+ Effect . provideService ( HostProcess . Platform , platform ) ,
109+ Effect . provideService ( HttpClient . HttpClient , client ) ,
110+ ) ;
111+ expect ( limits . windows [ 0 ] ?. usedPercent ) . toBe ( 42 ) ;
112+ }
113+ } ) . pipe ( Effect . scoped ) ,
114+ ) ,
117115 ) ;
118116
119117 it . effect (
0 commit comments