mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-14 01:36:14 +00:00
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user