Allow users to set where new fields must be created in a record page layout (#18420)
## Demo https://github.com/user-attachments/assets/eaf89d0c-96e0-4e49-ac58-290c8e7403ff
This commit is contained in:
committed by
GitHub
parent
d37ed7e07c
commit
a79b816117
+85
@@ -0,0 +1,85 @@
|
||||
import { type CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
|
||||
import { checkIfFeatureFlagIsEnabledOnWorkspace } from '@/workspace/utils/checkIfFeatureFlagIsEnabledOnWorkspace';
|
||||
|
||||
const makeWorkspace = (
|
||||
featureFlags?: Array<{ key: string; value: boolean; id: string }>,
|
||||
): CurrentWorkspace =>
|
||||
({
|
||||
id: 'workspace-1',
|
||||
featureFlags,
|
||||
}) as unknown as CurrentWorkspace;
|
||||
|
||||
describe('checkIfFeatureFlagIsEnabledOnWorkspace', () => {
|
||||
it('should return false when featureKey is null', () => {
|
||||
const workspace = makeWorkspace([]);
|
||||
|
||||
expect(checkIfFeatureFlagIsEnabledOnWorkspace(null, workspace)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when featureKey is undefined', () => {
|
||||
const workspace = makeWorkspace([]);
|
||||
|
||||
expect(checkIfFeatureFlagIsEnabledOnWorkspace(undefined, workspace)).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it('should return false when workspace is null', () => {
|
||||
expect(
|
||||
checkIfFeatureFlagIsEnabledOnWorkspace(
|
||||
'IS_AIRTABLE_INTEGRATION_ENABLED' as any,
|
||||
null,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when workspace has no featureFlags', () => {
|
||||
const workspace = makeWorkspace(undefined);
|
||||
|
||||
expect(
|
||||
checkIfFeatureFlagIsEnabledOnWorkspace(
|
||||
'IS_AIRTABLE_INTEGRATION_ENABLED' as any,
|
||||
workspace,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when feature flag is not found', () => {
|
||||
const workspace = makeWorkspace([
|
||||
{ key: 'OTHER_FLAG', value: true, id: 'flag-1' },
|
||||
]);
|
||||
|
||||
expect(
|
||||
checkIfFeatureFlagIsEnabledOnWorkspace(
|
||||
'IS_AIRTABLE_INTEGRATION_ENABLED' as any,
|
||||
workspace,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when feature flag exists but is disabled', () => {
|
||||
const workspace = makeWorkspace([
|
||||
{ key: 'IS_AIRTABLE_INTEGRATION_ENABLED', value: false, id: 'flag-1' },
|
||||
]);
|
||||
|
||||
expect(
|
||||
checkIfFeatureFlagIsEnabledOnWorkspace(
|
||||
'IS_AIRTABLE_INTEGRATION_ENABLED' as any,
|
||||
workspace,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true when feature flag exists and is enabled', () => {
|
||||
const workspace = makeWorkspace([
|
||||
{ key: 'IS_AIRTABLE_INTEGRATION_ENABLED', value: true, id: 'flag-1' },
|
||||
]);
|
||||
|
||||
expect(
|
||||
checkIfFeatureFlagIsEnabledOnWorkspace(
|
||||
'IS_AIRTABLE_INTEGRATION_ENABLED' as any,
|
||||
workspace,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user