@@ -21,7 +21,6 @@ const { QuotaLibrary } = await import('./quota.js');
2121
2222const originalIsCloud = EnvSet . values . isCloud ;
2323const originalIsIntegrationTest = EnvSet . values . isIntegrationTest ;
24- const originalIsDevFeaturesEnabled = EnvSet . values . isDevFeaturesEnabled ;
2524
2625/**
2726 * These tests spin up a full MockTenant, which instantiates the real EnvSet and runs its load sequence.
@@ -30,10 +29,7 @@ const originalIsDevFeaturesEnabled = EnvSet.values.isDevFeaturesEnabled;
3029 * reference to the original EnvSet singleton. Mutating the live flags keeps both MockTenant and
3130 * QuotaLibrary aligned with the test scenarios without breaking their dependency chain.
3231 */
33- const setEnvFlag = (
34- key : 'isCloud' | 'isIntegrationTest' | 'isDevFeaturesEnabled' ,
35- value : boolean
36- ) => {
32+ const setEnvFlag = ( key : 'isCloud' | 'isIntegrationTest' , value : boolean ) => {
3733 Reflect . set ( EnvSet . values , key , value ) ;
3834} ;
3935
@@ -60,15 +56,13 @@ beforeEach(() => {
6056 jest . clearAllMocks ( ) ;
6157 setEnvFlag ( 'isCloud' , true ) ;
6258 setEnvFlag ( 'isIntegrationTest' , false ) ;
63- setEnvFlag ( 'isDevFeaturesEnabled' , originalIsDevFeaturesEnabled ) ;
6459
6560 mockGetTenantSubscription . mockResolvedValue ( mockSubscriptionData ) ;
6661} ) ;
6762
6863afterEach ( ( ) => {
6964 setEnvFlag ( 'isCloud' , originalIsCloud ) ;
7065 setEnvFlag ( 'isIntegrationTest' , originalIsIntegrationTest ) ;
71- setEnvFlag ( 'isDevFeaturesEnabled' , originalIsDevFeaturesEnabled ) ;
7266} ) ;
7367
7468describe ( 'guardTenantUsageByKey' , ( ) => {
@@ -89,7 +83,6 @@ describe('guardTenantUsageByKey', () => {
8983 } ) ;
9084
9185 it ( 'skips guard when both quota and system limits are null/undefined' , async ( ) => {
92- setEnvFlag ( 'isDevFeaturesEnabled' , true ) ;
9386 mockGetTenantSubscription . mockResolvedValueOnce ( {
9487 ...mockSubscriptionData ,
9588 quota : {
@@ -114,35 +107,7 @@ describe('guardTenantUsageByKey', () => {
114107 expect ( getSelfComputedUsageByKey ) . not . toHaveBeenCalled ( ) ;
115108 } ) ;
116109
117- // Todo @xiaoyijun : remove once the dev feature guard is retired.
118- it ( 'skips system limit guard when dev features are disabled' , async ( ) => {
119- setEnvFlag ( 'isDevFeaturesEnabled' , false ) ;
120- mockGetTenantSubscription . mockResolvedValueOnce ( {
121- ...mockSubscriptionData ,
122- quota : {
123- ...mockSubscriptionData . quota ,
124- applicationsLimit : null ,
125- } ,
126- systemLimit : {
127- ...mockSubscriptionData . systemLimit ,
128- applicationsLimit : 2 ,
129- } ,
130- } ) ;
131-
132- const getSelfComputedUsageByKey = jest . fn ( ) . mockResolvedValue ( 2 ) ;
133- const { quotaLibrary } = createQuotaLibrary ( {
134- queriesOverride : {
135- tenantUsage : { getSelfComputedUsageByKey } ,
136- } ,
137- } ) ;
138-
139- await expect ( quotaLibrary . guardTenantUsageByKey ( 'applicationsLimit' ) ) . resolves . not . toThrow ( ) ;
140-
141- expect ( getSelfComputedUsageByKey ) . not . toHaveBeenCalled ( ) ;
142- } ) ;
143-
144110 it ( 'throws when usage reaches system limit' , async ( ) => {
145- setEnvFlag ( 'isDevFeaturesEnabled' , true ) ;
146111 mockGetTenantSubscription . mockResolvedValueOnce ( {
147112 ...mockSubscriptionData ,
148113 quota : {
@@ -228,7 +193,6 @@ describe('guardTenantUsageByKey', () => {
228193 } ) ;
229194
230195 it ( 'throws when numeric quota limit is not number type' , async ( ) => {
231- setEnvFlag ( 'isDevFeaturesEnabled' , true ) ;
232196 mockGetTenantSubscription . mockResolvedValueOnce ( {
233197 ...mockSubscriptionData ,
234198 quota : {
@@ -349,14 +313,17 @@ describe('guardTenantUsageByKey', () => {
349313 } ) ;
350314
351315 it ( 'skips guard for add-on usage keys on paid plans' , async ( ) => {
352- setEnvFlag ( 'isDevFeaturesEnabled' , false ) ;
353316 mockGetTenantSubscription . mockResolvedValueOnce ( {
354317 ...mockSubscriptionData ,
355318 planId : ReservedPlanId . Pro202509 ,
356319 quota : {
357320 ...mockSubscriptionData . quota ,
358321 machineToMachineLimit : 1 ,
359322 } ,
323+ systemLimit : {
324+ ...mockSubscriptionData . systemLimit ,
325+ machineToMachineLimit : undefined ,
326+ } ,
360327 } ) ;
361328
362329 const getSelfComputedUsageByKey = jest . fn ( ) . mockResolvedValue ( 0 ) ;
@@ -373,7 +340,6 @@ describe('guardTenantUsageByKey', () => {
373340 } ) ;
374341
375342 it ( 'calls getTenantUsageByKey only once when both system limit and quota limit checks are needed' , async ( ) => {
376- setEnvFlag ( 'isDevFeaturesEnabled' , true ) ;
377343 mockGetTenantSubscription . mockResolvedValueOnce ( {
378344 ...mockSubscriptionData ,
379345 quota : {
@@ -506,7 +472,6 @@ describe('guardTenantUsageByKey', () => {
506472 } ) ;
507473
508474 it ( 'respects system limit with batch consumption' , async ( ) => {
509- setEnvFlag ( 'isDevFeaturesEnabled' , true ) ;
510475 mockGetTenantSubscription . mockResolvedValueOnce ( {
511476 ...mockSubscriptionData ,
512477 quota : {
0 commit comments