Skip to content

Commit 3972141

Browse files
devin-ai-integration[bot]eunjae-lee
authored andcommitted
fix: revert permissive default and mock scope validation in integration tests
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
1 parent 0929d71 commit 3972141

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/features/feature-opt-in/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ export function getOptInFeaturesForScope(scope: OptInFeatureScope): OptInFeature
6868
/**
6969
* Check if a feature is allowed for a specific scope.
7070
* Features without a scope field are allowed for all scopes.
71-
* Features not in the config are allowed for all scopes (permissive by default).
71+
* Features not in the config are NOT allowed (must be explicitly configured).
7272
*/
7373
export function isFeatureAllowedForScope(slug: string, scope: OptInFeatureScope): boolean {
7474
const config = getOptInFeatureConfig(slug);
75-
if (!config) return true;
75+
if (!config) return false;
7676
return !config.scope || config.scope.includes(scope);
7777
}

packages/features/feature-opt-in/services/FeatureOptInService.integration-test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, describe, expect, it } from "vitest";
1+
import { afterEach, describe, expect, it, vi } from "vitest";
22

33
import { getFeatureOptInService } from "@calcom/features/di/containers/FeatureOptInService";
44
import { getFeaturesRepository } from "@calcom/features/di/containers/FeaturesRepository";
@@ -8,6 +8,16 @@ import { prisma } from "@calcom/prisma";
88

99
import type { IFeatureOptInService } from "./IFeatureOptInService";
1010

11+
// Mock isFeatureAllowedForScope to always return true for integration tests.
12+
// The scope validation logic is tested in unit tests; integration tests focus on database behavior.
13+
vi.mock("../config", async (importOriginal) => {
14+
const actual = await importOriginal<typeof import("../config")>();
15+
return {
16+
...actual,
17+
isFeatureAllowedForScope: () => true,
18+
};
19+
});
20+
1121
// Helper to generate unique identifiers per test
1222
const uniqueId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
1323

0 commit comments

Comments
 (0)