-
Notifications
You must be signed in to change notification settings - Fork 616
feat: follow --comfy-api-base for staging and preview backends #13054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bigcat88
wants to merge
1
commit into
main
Choose a base branch
from
feat/ephemeral-env-features
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import { refreshRemoteConfig } from '@/platform/remoteConfig/refreshRemoteConfig' | ||
| import { remoteConfig } from '@/platform/remoteConfig/remoteConfig' | ||
|
|
||
| import { getComfyApiBaseUrl, getComfyPlatformBaseUrl } from './comfyApi' | ||
|
|
||
| vi.mock('@/scripts/api', () => ({ | ||
| api: { | ||
| apiURL: (route: string) => `/api${route}`, | ||
| fetchApi: vi.fn() | ||
| } | ||
| })) | ||
|
|
||
| vi.stubGlobal('fetch', vi.fn()) | ||
|
|
||
| describe('getComfyApiBaseUrl', () => { | ||
| const originalConfig = remoteConfig.value | ||
|
|
||
| beforeEach(() => { | ||
| remoteConfig.value = {} | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| remoteConfig.value = originalConfig | ||
| }) | ||
|
|
||
| it('honors the server-provided override', () => { | ||
| remoteConfig.value = { comfy_api_base_url: 'https://my-ephem.example.com' } | ||
| expect(getComfyApiBaseUrl()).toBe('https://my-ephem.example.com') | ||
| }) | ||
|
|
||
| it('falls back to the build-time default when the key is absent', () => { | ||
| expect(getComfyApiBaseUrl()).toBe('https://stagingapi.comfy.org') | ||
| }) | ||
|
|
||
| it('falls back to the build-time default when the value is empty', () => { | ||
| remoteConfig.value = { comfy_api_base_url: '' } | ||
| expect(getComfyApiBaseUrl()).toBe('https://stagingapi.comfy.org') | ||
| }) | ||
| }) | ||
|
|
||
| describe('getComfyPlatformBaseUrl', () => { | ||
| const originalConfig = remoteConfig.value | ||
|
|
||
| beforeEach(() => { | ||
| remoteConfig.value = {} | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| remoteConfig.value = originalConfig | ||
| }) | ||
|
|
||
| it('honors the server-provided override', () => { | ||
| remoteConfig.value = { | ||
| comfy_platform_base_url: 'https://my-ephem-platform.example.com' | ||
| } | ||
| expect(getComfyPlatformBaseUrl()).toBe( | ||
| 'https://my-ephem-platform.example.com' | ||
| ) | ||
| }) | ||
|
|
||
| it('falls back to the build-time default when the key is absent', () => { | ||
| expect(getComfyPlatformBaseUrl()).toBe('https://stagingplatform.comfy.org') | ||
| }) | ||
|
|
||
| it('falls back to the build-time default when the value is empty', () => { | ||
| remoteConfig.value = { comfy_platform_base_url: '' } | ||
| expect(getComfyPlatformBaseUrl()).toBe('https://stagingplatform.comfy.org') | ||
| }) | ||
| }) | ||
|
|
||
| describe('compatibility with comfyui servers that predate the override keys', () => { | ||
| const originalConfig = remoteConfig.value | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| remoteConfig.value = {} | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| remoteConfig.value = originalConfig | ||
| }) | ||
|
|
||
| it('falls back to build-time defaults when /features omits the URL keys', async () => { | ||
| // An older comfyui server has /features but doesn't know about | ||
| // comfy_api_base_url / comfy_platform_base_url yet. | ||
| vi.mocked(global.fetch).mockResolvedValue({ | ||
| ok: true, | ||
| json: async () => ({ | ||
| supports_preview_metadata: true, | ||
| max_upload_size: 104857600 | ||
| }) | ||
| } as Response) | ||
|
|
||
| await refreshRemoteConfig({ useAuth: false }) | ||
|
|
||
| expect(getComfyApiBaseUrl()).toBe('https://stagingapi.comfy.org') | ||
| expect(getComfyPlatformBaseUrl()).toBe('https://stagingplatform.comfy.org') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| async function loadFirebase(useProdConfig: boolean) { | ||
| vi.resetModules() | ||
| vi.stubGlobal('__USE_PROD_CONFIG__', useProdConfig) | ||
| const { remoteConfig } = await import('@/platform/remoteConfig/remoteConfig') | ||
| const { getFirebaseConfig } = await import('./firebase') | ||
| return { getFirebaseConfig, remoteConfig } | ||
| } | ||
|
|
||
| describe('getFirebaseConfig', () => { | ||
| afterEach(() => { | ||
| vi.unstubAllGlobals() | ||
| }) | ||
|
|
||
| it('honors a full server-provided firebase_config (cloud builds)', async () => { | ||
| const cloud = { | ||
| apiKey: 'cloud-key', | ||
| authDomain: 'cloud.example.com', | ||
| projectId: 'some-cloud-project', | ||
| storageBucket: 'cloud.appspot.com', | ||
| messagingSenderId: '1', | ||
| appId: '1:1:web:abc' | ||
| } | ||
| const { getFirebaseConfig, remoteConfig } = await loadFirebase(true) | ||
| remoteConfig.value = { firebase_config: cloud } | ||
| expect(getFirebaseConfig()).toEqual(cloud) | ||
| }) | ||
|
|
||
| it('uses the dev project when the server reports firebase_env "dev", even if the build-time fallback is prod', async () => { | ||
| const { getFirebaseConfig, remoteConfig } = await loadFirebase(true) | ||
| remoteConfig.value = { firebase_env: 'dev' } | ||
| expect(getFirebaseConfig().projectId).toBe('dreamboothy-dev') | ||
| }) | ||
|
|
||
| it('falls back to the build-time config when the server reports no firebase_env', async () => { | ||
| const prod = await loadFirebase(true) | ||
| prod.remoteConfig.value = {} | ||
| expect(prod.getFirebaseConfig().projectId).toBe('dreamboothy') | ||
|
|
||
| const dev = await loadFirebase(false) | ||
| dev.remoteConfig.value = {} | ||
| expect(dev.getFirebaseConfig().projectId).toBe('dreamboothy-dev') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.