Skip to content

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

TypeScript

test(profile-ui): verify Settings hands off the desktop URL

Josué93f7a9edffd4
diff --git a/profile-ui/app/components/__tests__/SettingsContent.test.tsx b/profile-ui/app/components/__tests__/SettingsContent.test.tsx
index ea0d8a0ff..d0a547d0f 100644
--- a/profile-ui/app/components/__tests__/SettingsContent.test.tsx
+++ b/profile-ui/app/components/__tests__/SettingsContent.test.tsx
@@ -18,6 +18,7 @@ const mocks = vi.hoisted(() => ({
isSilentApiError: vi.fn(),
listWorkflowApprovalMediums: vi.fn(),
logout: vi.fn(),
+ navigateToDesktopApp: vi.fn(),
refreshApprovalTargets: vi.fn(),
refreshReleaseIdentity: vi.fn(),
routerPush: vi.fn(),
@@ -108,6 +109,7 @@ vi.mock('@lib/approvalChannels', () => ({
vi.mock('@lib/desktopAppLinks', () => ({
buildDesktopEnvironmentLink: mocks.buildDesktopEnvironmentLink,
+ navigateToDesktopApp: mocks.navigateToDesktopApp,
}))
vi.mock('@lib/releaseIdentity', () => ({
@@ -129,6 +131,10 @@ afterEach(cleanup)
describe('Settings desktop setup handoff', () => {
it('uses the shared desktop environment link builder', async () => {
+ const desktopHref =
+ 'evenfire://desktop-environment?externalRestApiBaseUrl=https%3A%2F%2Fapi.example.com&tenantName=Example+Tenant'
+ mocks.buildDesktopEnvironmentLink.mockReturnValue(desktopHref)
+
render(<SettingsContent activeSettingsTab="profile" activeSocialTab="telegram" />)
const setupButton = await screen.findByRole('button', { name: 'Setup desktop app' })
@@ -143,5 +149,6 @@ describe('Settings desktop setup handoff', () => {
fireEvent.click(openButton)
expect(mocks.buildDesktopEnvironmentLink).toHaveBeenCalledWith(desktopEnvironment)
+ expect(mocks.navigateToDesktopApp).toHaveBeenCalledWith(desktopHref)
})
})
diff --git a/profile-ui/app/settings/SettingsContent.tsx b/profile-ui/app/settings/SettingsContent.tsx
index b5efd86a3..714f758af 100644
--- a/profile-ui/app/settings/SettingsContent.tsx
+++ b/profile-ui/app/settings/SettingsContent.tsx
@@ -28,7 +28,7 @@ import {
disconnectWorkflowApprovalMedium,
listWorkflowApprovalMediums,
} from '@lib/approvalChannels'
-import { buildDesktopEnvironmentLink } from '@lib/desktopAppLinks'
+import { buildDesktopEnvironmentLink, navigateToDesktopApp } from '@lib/desktopAppLinks'
import {
EMPTY_PROFILE_CHANNELS,
addDraftRow,
@@ -336,7 +336,7 @@ export function SettingsContent({
function openDesktopAppSetup() {
const desktopEnvironmentLink = buildDesktopEnvironmentLink(desktopEnvironment)
if (!desktopEnvironmentLink) return
- window.location.href = desktopEnvironmentLink
+ navigateToDesktopApp(desktopEnvironmentLink)
}
return (
diff --git a/profile-ui/lib/desktopAppLinks.ts b/profile-ui/lib/desktopAppLinks.ts
index 09ca29d8a..1247d8a06 100644
--- a/profile-ui/lib/desktopAppLinks.ts
+++ b/profile-ui/lib/desktopAppLinks.ts
@@ -18,6 +18,13 @@ export function buildDesktopEnvironmentLink(
return `evenfire://desktop-environment?${params.toString()}`
}
+export function navigateToDesktopApp(
+ href: string,
+ location: Pick<Location, 'href'> = window.location
+): void {
+ location.href = href
+}
+
export function buildEvenfireDesktopAppLink(parts: {
recipeNs: string
recipeName: string
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index cf8db8f06..0f3823274 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.156",
+ "version": "0.1.157",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.156",
+ "version": "0.1.157",
"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 477d12f6f..9718c3e8e 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.156",
+ "version": "0.1.157",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/profile-ui/test/desktopAppLinks.test.ts b/profile-ui/test/desktopAppLinks.test.ts
index 5c4672c42..0e4cb29e4 100644
--- a/profile-ui/test/desktopAppLinks.test.ts
+++ b/profile-ui/test/desktopAppLinks.test.ts
@@ -4,8 +4,19 @@ import {
buildEvenfireDesktopAppContentSecurityPolicy,
buildEvenfireDesktopAppLink,
buildEvenfireDesktopAppRedirectDocument,
+ navigateToDesktopApp,
} from '../lib/desktopAppLinks'
+test('navigateToDesktopApp assigns the protocol URL to the browser location', () => {
+ const location = { href: 'https://profile.example.com/settings' }
+ const desktopHref =
+ 'evenfire://desktop-environment?externalRestApiBaseUrl=https%3A%2F%2Fapi.example.com&tenantName=Example+Tenant'
+
+ navigateToDesktopApp(desktopHref, location)
+
+ assert.equal(location.href, desktopHref)
+})
+
test('buildEvenfireDesktopAppLink preserves a nested app pathname and team', () => {
assert.equal(
buildEvenfireDesktopAppLink({