From 5cd3fc966ea8747cb1b4d830be17c1afca60b478 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Tue, 5 May 2026 04:13:20 +0000 Subject: [PATCH] test: cover production fallback for nodeLibraryEssentialsEnabled Add unit tests for the new default-true production fallback and the explicit-disable path so the rollout semantics are codified. --- src/composables/useFeatureFlags.test.ts | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/composables/useFeatureFlags.test.ts b/src/composables/useFeatureFlags.test.ts index 0b242d4b79..1dc7e1d9e4 100644 --- a/src/composables/useFeatureFlags.test.ts +++ b/src/composables/useFeatureFlags.test.ts @@ -176,6 +176,48 @@ describe('useFeatureFlags', () => { }) }) + describe('nodeLibraryEssentialsEnabled', () => { + afterEach(() => { + vi.unstubAllEnvs() + }) + + it('should return true when isNightly is true', () => { + vi.mocked(distributionTypes).isNightly = true + + const { flags } = useFeatureFlags() + expect(flags.nodeLibraryEssentialsEnabled).toBe(true) + expect(api.getServerFeature).not.toHaveBeenCalled() + }) + + it('should default to true in production when no remote config or server flag is set', () => { + vi.mocked(distributionTypes).isNightly = false + vi.stubEnv('DEV', false) + vi.mocked(api.getServerFeature).mockImplementation( + (_path, defaultValue) => defaultValue + ) + + const { flags } = useFeatureFlags() + expect(flags.nodeLibraryEssentialsEnabled).toBe(true) + expect(api.getServerFeature).toHaveBeenCalledWith( + ServerFeatureFlag.NODE_LIBRARY_ESSENTIALS_ENABLED, + true + ) + }) + + it('should return false in production when the server feature flag explicitly disables it', () => { + vi.mocked(distributionTypes).isNightly = false + vi.stubEnv('DEV', false) + vi.mocked(api.getServerFeature).mockImplementation((path) => { + if (path === ServerFeatureFlag.NODE_LIBRARY_ESSENTIALS_ENABLED) + return false + return undefined + }) + + const { flags } = useFeatureFlags() + expect(flags.nodeLibraryEssentialsEnabled).toBe(false) + }) + }) + describe('dev override via localStorage', () => { afterEach(() => { localStorage.clear()