Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(profile-ui): r2-b1 decouple discovery fixture from express

Josué3d429d012aa5
diff --git a/external-rest-api/package-lock.json b/external-rest-api/package-lock.json
index 81c281065..c47638178 100644
--- a/external-rest-api/package-lock.json
+++ b/external-rest-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-external-rest-api",
- "version": "0.1.85",
+ "version": "0.1.86",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-external-rest-api",
- "version": "0.1.85",
+ "version": "0.1.86",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2",
diff --git a/external-rest-api/package.json b/external-rest-api/package.json
index ce716823a..01619c163 100644
--- a/external-rest-api/package.json
+++ b/external-rest-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-external-rest-api",
- "version": "0.1.85",
+ "version": "0.1.86",
"description": "External REST API for profile, team management, and RPC token brokerage",
"main": "dist/main.js",
"engines": {
diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.ts
index 338f898a4..499d9d7fa 100644
--- a/external-rest-api/src/releaseManifest.ts
+++ b/external-rest-api/src/releaseManifest.ts
@@ -8,7 +8,7 @@ export type ReleaseManifest = {
export const releaseManifest: ReleaseManifest = {
releaseId: 'v0.10.0',
- externalRestApiVersion: '0.1.85',
+ externalRestApiVersion: '0.1.86',
rpcProxyVersion: '0.1.94',
desktopVersion: '0.10.0',
minimumDesktopVersion: '0.1.252',
diff --git a/external-rest-api/src/routes/desktop.ts b/external-rest-api/src/routes/desktop.ts
index 60024f0c0..3361a8a6a 100644
--- a/external-rest-api/src/routes/desktop.ts
+++ b/external-rest-api/src/routes/desktop.ts
@@ -2,6 +2,7 @@ import { Router } from 'express'
import { config } from '../config.js'
import { requireAuth } from '../middleware/auth.js'
import { releaseManifest } from '../releaseManifest.js'
+import { buildDesktopEnvironmentResponse } from './desktopEnvironmentResponse.js'
export function createDesktopRouter(): Router {
const router = Router()
@@ -9,11 +10,13 @@ export function createDesktopRouter(): Router {
// Public discovery only: returns non-secret tenant URLs so setup can resolve
// the RPC proxy after the user confirms the External REST API host.
router.get('/desktop/environment', (_req, res) => {
- res.status(200).json({
- appName: config.desktopAppName,
- externalRestApiBaseUrl: config.publicBaseUrl,
- rpcProxyBaseUrl: config.desktopRpcProxyBaseUrl,
- })
+ res.status(200).json(
+ buildDesktopEnvironmentResponse({
+ desktopAppName: config.desktopAppName,
+ publicBaseUrl: config.publicBaseUrl,
+ desktopRpcProxyBaseUrl: config.desktopRpcProxyBaseUrl,
+ })
+ )
})
router.get('/desktop/release', requireAuth, (_req, res) => {
diff --git a/external-rest-api/src/routes/desktopEnvironmentResponse.ts b/external-rest-api/src/routes/desktopEnvironmentResponse.ts
new file mode 100644
index 000000000..6730ec091
--- /dev/null
+++ b/external-rest-api/src/routes/desktopEnvironmentResponse.ts
@@ -0,0 +1,21 @@
+export type DesktopEnvironmentConfig = {
+ desktopAppName: string
+ publicBaseUrl: string
+ desktopRpcProxyBaseUrl: string
+}
+
+export type DesktopEnvironmentResponse = {
+ appName: string
+ externalRestApiBaseUrl: string
+ rpcProxyBaseUrl: string
+}
+
+export function buildDesktopEnvironmentResponse(
+ config: DesktopEnvironmentConfig
+): DesktopEnvironmentResponse {
+ return {
+ appName: config.desktopAppName,
+ externalRestApiBaseUrl: config.publicBaseUrl,
+ rpcProxyBaseUrl: config.desktopRpcProxyBaseUrl,
+ }
+}
diff --git a/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx b/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx
index c703f7a18..b7eafe7cd 100644
--- a/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx
+++ b/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx
@@ -2,24 +2,11 @@ import React from 'react'
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import '@testing-library/jest-dom/vitest'
import { cleanup, render, screen } from '@testing-library/react'
-import { createRequire } from 'node:module'
-import { join, resolve } from 'node:path'
import { buildDesktopEnvironmentLink } from '@lib/desktopAppLinks'
import type { DesktopEnvironmentResponse } from '@/app/types/api'
+import { buildDesktopEnvironmentResponse } from '../../../../external-rest-api/src/routes/desktopEnvironmentResponse.js'
import Page from '../../page'
-type ExpressTestApp = { use: (path: string, router: unknown) => void }
-type ExpressFactory = () => ExpressTestApp
-type SupertestResponse = { body: unknown }
-type SupertestRequest = { expect: (status: number) => Promise<SupertestResponse> }
-type SupertestFactory = (app: ExpressTestApp) => { get: (path: string) => SupertestRequest }
-
-const requireExternalRestApi = createRequire(
- join(resolve(process.cwd(), '../external-rest-api'), 'package.json')
-)
-const express = requireExternalRestApi('express') as ExpressFactory
-const request = requireExternalRestApi('supertest') as SupertestFactory
-
const api = vi.hoisted(() => ({
getDesktopEnvironment: vi.fn(),
}))
@@ -30,14 +17,12 @@ const originalDesktopEnvironmentConfig = {
rpcProxyBaseUrl: process.env.EXTERNAL_REST_API_DESKTOP_RPC_PROXY_BASE_URL,
}
-async function getDesktopEnvironmentFromProducer(): Promise<DesktopEnvironmentResponse> {
- const { createDesktopRouter } =
- await import('../../../../external-rest-api/src/routes/desktop.js')
- const app = express()
- app.use('/api/v1', createDesktopRouter())
-
- const response = await request(app).get('/api/v1/desktop/environment').expect(200)
- return response.body as DesktopEnvironmentResponse
+function getDesktopEnvironmentFromProducer(): DesktopEnvironmentResponse {
+ return buildDesktopEnvironmentResponse({
+ desktopAppName: process.env.EXTERNAL_REST_API_DESKTOP_APP_NAME ?? '',
+ publicBaseUrl: process.env.EXTERNAL_REST_API_PUBLIC_BASE_URL ?? '',
+ desktopRpcProxyBaseUrl: process.env.EXTERNAL_REST_API_DESKTOP_RPC_PROXY_BASE_URL ?? '',
+ })
}
vi.mock('@lib/api', () => ({
@@ -71,7 +56,7 @@ vi.mock('next/link', () => ({
}))
beforeAll(() => {
- process.env.EXTERNAL_REST_API_PUBLIC_BASE_URL = 'https://api.example.com/'
+ process.env.EXTERNAL_REST_API_PUBLIC_BASE_URL = 'https://api.example.com'
process.env.EXTERNAL_REST_API_DESKTOP_RPC_PROXY_BASE_URL = 'https://rpc.example.com/'
process.env.EXTERNAL_REST_API_DESKTOP_APP_NAME = 'Example Tenant'
})
@@ -138,7 +123,7 @@ describe('Profile Portal home desktop setup link', () => {
})
it('labels the environment setup handoff accurately', async () => {
- const environment = await getDesktopEnvironmentFromProducer()
+ const environment = getDesktopEnvironmentFromProducer()
api.getDesktopEnvironment.mockResolvedValue(environment)
render(<Page />)
@@ -153,8 +138,8 @@ describe('Profile Portal home desktop setup link', () => {
expect(href.searchParams.get('tenantName')).toBe(environment.appName)
})
- it('builds the setup link from the real public discovery response', async () => {
- const environment = await getDesktopEnvironmentFromProducer()
+ it('builds the setup link from the production discovery response', () => {
+ const environment = getDesktopEnvironmentFromProducer()
const href = buildDesktopEnvironmentLink(environment)
expect(href).not.toBeNull()
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index 9d06f1e14..e86988ea2 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.151",
+ "version": "0.1.152",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.151",
+ "version": "0.1.152",
"dependencies": {
"@clerum/desktop-app-links": "file:../packages/desktop-app-links",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/profile-ui/package.json b/profile-ui/package.json
index ad9d115db..1754fdbef 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.151",
+ "version": "0.1.152",
"private": true,
"scripts": {
"dev": "next dev",