Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/FEATURE_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ They resolve in this order, first match wins:
(`src/utils/sessionFeatureFlagOverride.ts`)
2. **Dev override** — `getDevOverride()`
(`src/utils/devFeatureFlagOverride.ts`)
3. **Remote config** — the matching `remoteConfig.value.*` field, when the
3. **Remote config** — the matching `useRemoteConfigStore().config.*` field, when the
getter passes one
4. **Server feature flag** — `api.getServerFeature(flagKey, defaultValue)`

Expand Down
3 changes: 2 additions & 1 deletion src/components/dialog/GlobalDialog.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen, waitFor, within } from '@testing-library/vue'
import userEvent from '@testing-library/user-event'
import { getActivePinia } from 'pinia'
import { describe, expect, it, onTestFinished, vi } from 'vitest'
import { computed, defineComponent, h, nextTick, ref } from 'vue'
import { createI18n } from 'vue-i18n'
Expand Down Expand Up @@ -112,7 +113,7 @@ const Body = defineComponent({

function mountDialog() {
return render(GlobalDialog, {
global: { plugins: [i18n] }
global: { plugins: [getActivePinia()!, i18n] }
})
}

Expand Down
1 change: 0 additions & 1 deletion src/components/dialog/content/SignInContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ vi.mock(import('@/utils/hostWhitelist'), () => ({
isHostWhitelisted: () => true,
normalizeHost: (host: string) => host
}))
vi.mock(import('@/platform/remoteConfig/remoteConfig'))

const inChina = vi.hoisted(() => ({
value: false,
Expand Down
7 changes: 4 additions & 3 deletions src/components/dialog/content/SignInContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ import { useSocialSignIn } from '@/platform/auth/social/useSocialSignIn'
import { getComfyPlatformBaseUrl } from '@/config/comfyApi'
import {
configValueOrDefault,
remoteConfig
} from '@/platform/remoteConfig/remoteConfig'
useRemoteConfigStore
} from '@/platform/remoteConfig/remoteConfigStore'
import type { SignInData, SignUpData } from '@/schemas/signInSchema'
import {
desktopHostReportsSignInFailures,
Expand Down Expand Up @@ -240,9 +240,10 @@ const signInWithDesktopHost = async () => {
}
toast.error(t('auth.desktopHost.signInFailed'), { duration: 6000 })
}
const remoteConfigStore = useRemoteConfigStore()
const comfyPlatformBaseUrl = computed(() =>
configValueOrDefault(
remoteConfig.value,
remoteConfigStore.config,
'comfy_platform_base_url',
getComfyPlatformBaseUrl()
)
Expand Down
7 changes: 4 additions & 3 deletions src/components/dialog/content/signin/ApiKeyForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ import Input from '@comfyorg/design-system/input/Input'
import { getComfyPlatformBaseUrl } from '@/config/comfyApi'
import {
configValueOrDefault,
remoteConfig
} from '@/platform/remoteConfig/remoteConfig'
useRemoteConfigStore
} from '@/platform/remoteConfig/remoteConfigStore'
import { apiKeySchema } from '@/schemas/signInSchema'
import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore'
import { useAuthStore } from '@/stores/authStore'

const authStore = useAuthStore()
const apiKeyStore = useApiKeyAuthStore()
const remoteConfigStore = useRemoteConfigStore()
const loading = computed(() => authStore.loading)
const comfyPlatformBaseUrl = computed(() =>
configValueOrDefault(
remoteConfig.value,
remoteConfigStore.config,
'comfy_platform_base_url',
getComfyPlatformBaseUrl()
)
Expand Down
14 changes: 7 additions & 7 deletions src/components/topbar/WorkflowTabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { render, screen, waitFor } from '@testing-library/vue'
import userEvent from '@testing-library/user-event'
import { fromPartial } from '@total-typescript/shoehorn'
import { TabsTrigger } from 'reka-ui'
import { beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { Mock } from 'vitest'
import type { PropType } from 'vue'
import { computed, defineComponent, h, nextTick } from 'vue'
import { createI18n } from 'vue-i18n'

import { useCurrentUser } from '@/composables/auth/useCurrentUser'
import { remoteConfig } from '@/platform/remoteConfig/remoteConfig'
import { useRemoteConfigStore } from '@/platform/remoteConfig/remoteConfigStore'
import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
import enMessages from '@/locales/en/main.json' with { type: 'json' }
import { useSettingStore } from '@/platform/settings/settingStore'
Expand Down Expand Up @@ -232,11 +232,11 @@ describe('WorkflowTabs profile button', () => {
})

function setBillingNewUx(enabled: boolean) {
const previous = remoteConfig.value
remoteConfig.value = { ...previous, billing_new_ux_enabled: enabled }
onTestFinished(() => {
remoteConfig.value = previous
})
const remoteConfigStore = useRemoteConfigStore()
remoteConfigStore.acceptConfig(
{ ...remoteConfigStore.config, billing_new_ux_enabled: enabled },
false
)
}

it('keeps the profile button in the top bar while billing_new_ux_enabled is off', () => {
Expand Down
24 changes: 13 additions & 11 deletions src/composables/auth/useTurnstile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'

import { useTurnstile } from '@/composables/auth/useTurnstile'
import { getTurnstileSiteKey } from '@/config/turnstile'
import { remoteConfig } from '@/platform/remoteConfig/remoteConfig'
import { useRemoteConfigStore } from '@/platform/remoteConfig/remoteConfigStore'
import { api } from '@/scripts/api'
import { getDevOverride } from '@/utils/devFeatureFlagOverride'

vi.mock(import('@/platform/remoteConfig/remoteConfig'))
vi.mock(import('@/scripts/api'))
vi.mock(import('@/utils/devFeatureFlagOverride'), () => ({
getDevOverride: vi.fn()
Expand All @@ -23,7 +22,6 @@ const mockedSiteKey = vi.mocked(getTurnstileSiteKey)
// suite covers their binding to this app's config sources.
describe('useTurnstile', () => {
beforeEach(() => {
remoteConfig.value = {}
mockedDevOverride.mockReturnValue(undefined)
vi.mocked(api.getServerFeature).mockReturnValue('off')
mockedSiteKey.mockReturnValue('site-key')
Expand All @@ -32,14 +30,14 @@ describe('useTurnstile', () => {
describe('mode precedence', () => {
it('prefers the dev override over remote config and the server feature', () => {
mockedDevOverride.mockReturnValue('enforce')
remoteConfig.value = { signup_turnstile: 'shadow' }
useRemoteConfigStore().acceptConfig({ signup_turnstile: 'shadow' }, false)
vi.mocked(api.getServerFeature).mockReturnValue('off')

expect(useTurnstile().mode.value).toBe('enforce')
})

it('uses remote config when there is no dev override', () => {
remoteConfig.value = { signup_turnstile: 'shadow' }
useRemoteConfigStore().acceptConfig({ signup_turnstile: 'shadow' }, false)

expect(useTurnstile().mode.value).toBe('shadow')
})
Expand All @@ -55,9 +53,7 @@ describe('useTurnstile', () => {
})

it('clamps an unknown remote-config value to off', () => {
remoteConfig.value = {
signup_turnstile: 'bogus' as unknown as 'shadow'
}
useRemoteConfigStore().acceptConfig({ signup_turnstile: 'bogus' }, false)

expect(useTurnstile().mode.value).toBe('off')
})
Expand All @@ -69,23 +65,29 @@ describe('useTurnstile', () => {

describe('enabled / enforced', () => {
it('is enabled but not enforced in shadow with a sitekey', () => {
remoteConfig.value = { signup_turnstile: 'shadow' }
useRemoteConfigStore().acceptConfig({ signup_turnstile: 'shadow' }, false)

const { enabled, enforced } = useTurnstile()
expect(enabled.value).toBe(true)
expect(enforced.value).toBe(false)
})

it('is enabled and enforced in enforce with a sitekey', () => {
remoteConfig.value = { signup_turnstile: 'enforce' }
useRemoteConfigStore().acceptConfig(
{ signup_turnstile: 'enforce' },
false
)

const { enabled, enforced } = useTurnstile()
expect(enabled.value).toBe(true)
expect(enforced.value).toBe(true)
})

it('is neither enabled nor enforced without a sitekey, even in enforce', () => {
remoteConfig.value = { signup_turnstile: 'enforce' }
useRemoteConfigStore().acceptConfig(
{ signup_turnstile: 'enforce' },
false
)
mockedSiteKey.mockReturnValue('')

const { enabled, enforced } = useTurnstile()
Expand Down
Loading
Loading