Skip to content

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

TypeScript

test(profile-ui): r3-l8 isolate async shell api tests

Josuéed85c382451e
diff --git a/profile-ui/app/components/__tests__/ProfileAppFrame.invite.test.tsx b/profile-ui/app/components/__tests__/ProfileAppFrame.invite.test.tsx
index a5e119bdb..978190d21 100644
--- a/profile-ui/app/components/__tests__/ProfileAppFrame.invite.test.tsx
+++ b/profile-ui/app/components/__tests__/ProfileAppFrame.invite.test.tsx
@@ -12,6 +12,11 @@ const navigationState = vi.hoisted(() => ({
replace: vi.fn(),
}))
+const api = vi.hoisted(() => ({
+ getDesktopEnvironment: vi.fn(),
+ getDesktopRelease: vi.fn(),
+}))
+
const authState = vi.hoisted(
(): AuthState => ({
isLoggedIn: true,
@@ -44,6 +49,11 @@ vi.mock('next/navigation', () => ({
useSearchParams: () => new URLSearchParams(navigationState.search),
}))
+vi.mock('@lib/api', () => ({
+ getDesktopEnvironment: api.getDesktopEnvironment,
+ getDesktopRelease: api.getDesktopRelease,
+}))
+
vi.mock('next/image', () => ({
default: ({ alt = '', ...props }: React.ImgHTMLAttributes<HTMLImageElement>) => (
// eslint-disable-next-line @next/next/no-img-element
@@ -72,6 +82,21 @@ vi.mock('@components/AuthContext', () => ({
}),
}))
+vi.mock('@components/ProfileAccessContext', () => ({
+ ProfileAccessProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+ useProfileAccess: () => ({
+ approvalTargets: [],
+ approvalTargetsError: false,
+ approvalTargetsLoading: false,
+ canManageMembers: false,
+ manageableTeams: [],
+ manageableTeamsError: false,
+ manageableTeamsLoading: false,
+ refreshApprovalTargets: vi.fn(),
+ refreshManageableTeams: vi.fn(),
+ }),
+}))
+
vi.mock('@components/LoginPanel', () => ({
LoginPanel: () => <div data-testid="profile-login-panel">login-panel</div>,
}))
@@ -85,6 +110,8 @@ function renderRootPage() {
}
beforeEach(() => {
+ api.getDesktopEnvironment.mockReset().mockReturnValue(new Promise(() => {}))
+ api.getDesktopRelease.mockReset().mockReturnValue(new Promise(() => {}))
navigationState.pathname = '/'
navigationState.search = ''
navigationState.replace.mockClear()
diff --git a/profile-ui/app/components/__tests__/Sidebar.test.tsx b/profile-ui/app/components/__tests__/Sidebar.test.tsx
index e6d7ea2c4..d42ab3292 100644
--- a/profile-ui/app/components/__tests__/Sidebar.test.tsx
+++ b/profile-ui/app/components/__tests__/Sidebar.test.tsx
@@ -6,10 +6,12 @@ import { Sidebar } from '@components/Sidebar'
import { resetReleaseIdentityCache } from '@lib/releaseIdentity'
const api = vi.hoisted(() => ({
+ getDesktopEnvironment: vi.fn(),
getDesktopRelease: vi.fn(),
}))
vi.mock('@lib/api', () => ({
+ getDesktopEnvironment: api.getDesktopEnvironment,
getDesktopRelease: api.getDesktopRelease,
}))
@@ -59,8 +61,9 @@ beforeEach(() => {
profileAccessState.refreshApprovalTargets.mockClear()
profileAccessState.refreshManageableTeams.mockClear()
resetReleaseIdentityCache()
+ api.getDesktopEnvironment.mockReset().mockReturnValue(new Promise(() => {}))
api.getDesktopRelease.mockReset()
- api.getDesktopRelease.mockResolvedValue({ releaseId: 'v0.6.0' })
+ api.getDesktopRelease.mockReturnValue(new Promise(() => {}))
})
afterEach(cleanup)
@@ -107,6 +110,7 @@ describe('Profile Sidebar navigation order', () => {
describe('Profile Sidebar release identity', () => {
it('titles the brand with the platform release, not the portal package version', async () => {
+ api.getDesktopRelease.mockResolvedValue({ releaseId: 'v0.6.0' })
const view = render(<Sidebar currentRoute="settings" onLogout={vi.fn()} />)
const brand = view.container.querySelector('.cu-sidebar__brand')
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index 86ebc7f83..17e3488bb 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.163",
+ "version": "0.1.164",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.163",
+ "version": "0.1.164",
"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 a166ab8bd..dc7929062 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.163",
+ "version": "0.1.164",
"private": true,
"scripts": {
"dev": "next dev",