Skip to content

Commit 5ea4672

Browse files
authored
chore: remove dev feature guard of system limit (#7948)
1 parent b210a96 commit 5ea4672

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

packages/core/src/libraries/quota.test.ts

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const { QuotaLibrary } = await import('./quota.js');
2121

2222
const originalIsCloud = EnvSet.values.isCloud;
2323
const 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

6863
afterEach(() => {
6964
setEnvFlag('isCloud', originalIsCloud);
7065
setEnvFlag('isIntegrationTest', originalIsIntegrationTest);
71-
setEnvFlag('isDevFeaturesEnabled', originalIsDevFeaturesEnabled);
7266
});
7367

7468
describe('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: {

packages/core/src/libraries/quota.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ export class QuotaLibrary {
169169
this.connectorLibrary
170170
);
171171

172-
// Todo: @xiaoyijun: remove dev feature flag
173-
if (EnvSet.values.isDevFeaturesEnabled && isSystemUsageKey(key)) {
172+
if (isSystemUsageKey(key)) {
174173
await this.assertSystemLimit({
175174
key,
176175
entityId,

0 commit comments

Comments
 (0)