Skip to content

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

TypeScript

test(profile-ui): r2-l3 cover empty discovery and Settings handoff

Josué401b2481739f
diff --git a/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx b/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx
index 1edefd524..6c2938480 100644
--- a/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx
+++ b/profile-ui/app/components/__tests__/ProfilePortalHome.test.tsx
@@ -84,6 +84,24 @@ describe('Profile Portal home desktop setup link', () => {
expect(screen.queryByRole('link', { name: 'Set up Desktop App' })).not.toBeInTheDocument()
})
+ it('explains unavailable setup when discovery has no External REST API URL', async () => {
+ api.getDesktopEnvironment.mockResolvedValue({
+ ...desktopEnvironment,
+ externalRestApiBaseUrl: '',
+ })
+
+ render(<Page />)
+
+ const unavailableStatus = await screen.findByRole('status')
+
+ expect(unavailableStatus).toHaveTextContent('Desktop app setup is unavailable right now.')
+ expect(screen.getByRole('link', { name: 'Settings' })).toHaveAttribute(
+ 'href',
+ '/settings/profile'
+ )
+ expect(screen.queryByRole('link', { name: 'Set up Desktop App' })).not.toBeInTheDocument()
+ })
+
it('labels the environment setup handoff accurately', async () => {
const environment = desktopEnvironment
diff --git a/profile-ui/app/components/__tests__/SettingsContent.test.tsx b/profile-ui/app/components/__tests__/SettingsContent.test.tsx
new file mode 100644
index 000000000..ea0d8a0ff
--- /dev/null
+++ b/profile-ui/app/components/__tests__/SettingsContent.test.tsx
@@ -0,0 +1,147 @@
+import type { ReactNode } from 'react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import '@testing-library/jest-dom/vitest'
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import type { DesktopEnvironmentResponse } from '@/app/types/api'
+import type { Me } from '@/app/types/profile'
+import desktopEnvironmentFixture from '@/test/fixtures/desktop-environment-response.json'
+import { SettingsContent } from '../../settings/SettingsContent'
+
+const mocks = vi.hoisted(() => ({
+ buildDesktopEnvironmentLink: vi.fn(),
+ checkAuth: vi.fn(),
+ confirm: vi.fn(),
+ disconnectWorkflowApprovalMedium: vi.fn(),
+ getConfiguredExternalRestApiBaseUrl: vi.fn(),
+ getDesktopEnvironment: vi.fn(),
+ getMe: vi.fn(),
+ isSilentApiError: vi.fn(),
+ listWorkflowApprovalMediums: vi.fn(),
+ logout: vi.fn(),
+ refreshApprovalTargets: vi.fn(),
+ refreshReleaseIdentity: vi.fn(),
+ routerPush: vi.fn(),
+ routerReplace: vi.fn(),
+ showToast: vi.fn(),
+ updatePassword: vi.fn(),
+ updateProfile: vi.fn(),
+}))
+
+const desktopEnvironment: DesktopEnvironmentResponse = desktopEnvironmentFixture
+const currentUser: Me = {
+ id: 'user-1',
+ email: '[email protected]',
+ name: 'Josue',
+ role: 'member',
+ teamId: null,
+ teamName: null,
+ profile: {
+ displayName: 'Josue',
+ channels: {
+ emails: [],
+ telegramHandles: [],
+ slackUserNames: [],
+ telegramIds: [],
+ discordUserNames: [],
+ whatsappNumbers: [],
+ },
+ },
+}
+
+vi.mock('next/navigation', () => ({
+ useRouter: () => ({ push: mocks.routerPush, replace: mocks.routerReplace }),
+ useSearchParams: () => ({ get: () => null }),
+}))
+
+vi.mock('next/link', () => ({
+ default: ({ children, href, ...props }: { children: ReactNode; href: string }) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+}))
+
+vi.mock('@components/AuthContext', () => ({
+ useAuth: () => ({ checkAuth: mocks.checkAuth, logout: mocks.logout }),
+}))
+
+vi.mock('@components/ConfirmDialog', () => ({
+ useConfirmDialog: () => ({ confirm: mocks.confirm, confirmDialog: null }),
+}))
+
+vi.mock('@components/ProfileAccessContext', () => ({
+ useProfileAccess: () => ({
+ approvalTargets: [],
+ refreshApprovalTargets: mocks.refreshApprovalTargets,
+ }),
+}))
+
+vi.mock('@components/ProfileBodySkeleton', () => ({
+ ProfileBodySkeleton: () => null,
+}))
+
+vi.mock('@components/ProfileShell', () => ({
+ ProfileShell: ({ children }: { children: ReactNode }) => <>{children}</>,
+}))
+
+vi.mock('@components/ReleaseLabel', () => ({
+ ReleaseLabel: () => null,
+}))
+
+vi.mock('@components/Toast', () => ({
+ useToast: () => ({ showToast: mocks.showToast }),
+}))
+
+vi.mock('@lib/api', () => ({
+ getConfiguredExternalRestApiBaseUrl: mocks.getConfiguredExternalRestApiBaseUrl,
+ getDesktopEnvironment: mocks.getDesktopEnvironment,
+ getMe: mocks.getMe,
+ isSilentApiError: mocks.isSilentApiError,
+ updatePassword: mocks.updatePassword,
+ updateProfile: mocks.updateProfile,
+}))
+
+vi.mock('@lib/approvalChannels', () => ({
+ disconnectWorkflowApprovalMedium: mocks.disconnectWorkflowApprovalMedium,
+ listWorkflowApprovalMediums: mocks.listWorkflowApprovalMediums,
+}))
+
+vi.mock('@lib/desktopAppLinks', () => ({
+ buildDesktopEnvironmentLink: mocks.buildDesktopEnvironmentLink,
+}))
+
+vi.mock('@lib/releaseIdentity', () => ({
+ refreshReleaseIdentity: mocks.refreshReleaseIdentity,
+}))
+
+beforeEach(() => {
+ vi.clearAllMocks()
+ mocks.buildDesktopEnvironmentLink.mockReturnValue(null)
+ mocks.getConfiguredExternalRestApiBaseUrl.mockReturnValue('https://api.example.com')
+ mocks.getDesktopEnvironment.mockResolvedValue(desktopEnvironment)
+ mocks.getMe.mockResolvedValue(currentUser)
+ mocks.isSilentApiError.mockReturnValue(false)
+ mocks.listWorkflowApprovalMediums.mockResolvedValue([])
+ mocks.refreshApprovalTargets.mockResolvedValue([])
+})
+
+afterEach(cleanup)
+
+describe('Settings desktop setup handoff', () => {
+ it('uses the shared desktop environment link builder', async () => {
+ render(<SettingsContent activeSettingsTab="profile" activeSocialTab="telegram" />)
+
+ const setupButton = await screen.findByRole('button', { name: 'Setup desktop app' })
+ await waitFor(() => expect(setupButton).toBeEnabled())
+ fireEvent.click(setupButton)
+
+ const dialog = await screen.findByRole('dialog', { name: 'Setup desktop app' })
+ const openButton = within(dialog).getByRole('button', {
+ name: 'Open desktop app and setup',
+ })
+ await waitFor(() => expect(openButton).toBeEnabled())
+ fireEvent.click(openButton)
+
+ expect(mocks.buildDesktopEnvironmentLink).toHaveBeenCalledWith(desktopEnvironment)
+ })
+})
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index 4770168ff..cf8db8f06 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.155",
+ "version": "0.1.156",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.155",
+ "version": "0.1.156",
"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 9b4093907..477d12f6f 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.155",
+ "version": "0.1.156",
"private": true,
"scripts": {
"dev": "next dev",