Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop-app): verify GFS logout suspension with real storage (R12-L1)
Josuéf870a746e3fa
diff --git a/desktop-app/src/__tests__/appService.nativeCommit.test.ts b/desktop-app/src/__tests__/appService.nativeCommit.test.tsindex 3331de3b8..7b7af6b70 100644--- a/desktop-app/src/__tests__/appService.nativeCommit.test.ts+++ b/desktop-app/src/__tests__/appService.nativeCommit.test.ts@@ -1,4 +1,5 @@import { afterEach, describe, expect, it, vi } from 'vitest'+import fs from 'node:fs/promises'import {cleanupNativeCommitTestHarness,createNativeCommitTestHarness,@@ -8,6 +9,72 @@ import {afterEach(cleanupNativeCommitTestHarness)describe('AppService native auth and environment commit ordering', () => {+ it('persists real version-2 GFS state as suspended_auth on logout', async () => {+ const { service, runtimeConfig } = await createNativeCommitTestHarness()+ const me = {+ id: 'user-a',+ email: '[email protected]',+ name: 'User A',+ picture: null,+ teamId: 'team-a',+ teamName: 'Team A',+ role: 'member',+ }+ service.authClient = {+ googleLogin: vi.fn().mockResolvedValue({ token: 'synthetic-session-a', me }),+ } as never+ await service.googleLogin('synthetic-google-token')+ const app = service as unknown as {+ gfsScopeIdentity: {+ ownerId: string+ teamId: string | null+ environmentKey: string+ baseUrl: string+ }+ gfsAuthEpoch: number+ persistDesktopGfsUpload(record: unknown): Promise<void>+ desktopGfsUploadStatePath(): Promise<string>+ }+ const identity = app.gfsScopeIdentity+ const uploadId = '92929292-9292-4292-8292-929292929292'+ await app.persistDesktopGfsUpload({+ version: 2,+ uploadId,+ filePath: '/tmp/payload.bin',+ fileName: 'payload.bin',+ fileSize: 4,+ target: { operation: 'create', parentRid: 'parent-a' },+ name: 'payload.bin',+ session: {+ uploadId,+ drive: 'main',+ operation: 'create',+ expectedBytes: 4,+ partBytes: 4,+ partCount: 1,+ state: 'uploading',+ contiguousBytes: 0,+ committedBytes: 0,+ committedPartCount: 0,+ activePartCount: 0,+ expiresAt: new Date(Date.now() + 60_000).toISOString(),+ },+ scope: { ...identity, drive: 'main', authEpoch: app.gfsAuthEpoch },+ status: 'active',+ updatedAt: new Date().toISOString(),+ })++ await service.logout()++ const statePath = await app.desktopGfsUploadStatePath()+ const state = JSON.parse(await fs.readFile(statePath, 'utf8')) as {+ version: number+ records: Array<{ uploadId: string; status: string }>+ }+ expect(state.version).toBe(2)+ expect(state.records).toEqual([expect.objectContaining({ uploadId, status: 'suspended_auth' })])+ })+it('rejects desktop setup while preserving the active authenticated environment', async () => {const { service, runtimeConfig, restA, restB } = await createNativeCommitTestHarness()const me = { id: 'user-a', email: '[email protected]', teamId: 'team-a' }diff --git a/desktop-app/testSupport/appService.nativeCommitTestHarness.ts b/desktop-app/testSupport/appService.nativeCommitTestHarness.tsindex 534e83f46..52f55f608 100644--- a/desktop-app/testSupport/appService.nativeCommitTestHarness.ts+++ b/desktop-app/testSupport/appService.nativeCommitTestHarness.ts@@ -32,8 +32,6 @@ export type NativeCommitTestService = {sessionToken: string | nullme: { id: string } | nullgfsScopeIdentity: { ownerId: string; environmentKey: string; baseUrl: string } | null- updateDesktopGfsUploadState: ReturnType<typeof vi.fn>- readDesktopGfsUploadState: ReturnType<typeof vi.fn>googleLogin: (token: string) => Promise<unknown>logout: () => Promise<number>selectRuntimeConfig: (optionId: string) => Promise<unknown>@@ -102,9 +100,6 @@ export async function createNativeCommitTestHarness() {getSessionToken: vi.fn().mockResolvedValue(null),setSessionToken: vi.fn().mockResolvedValue(undefined),} as never- service.updateDesktopGfsUploadState = vi.fn().mockResolvedValue(undefined)- service.readDesktopGfsUploadState = vi.fn().mockResolvedValue({ version: 1, records: [] })-return { service, runtimeConfig, restA, restB, optionA, optionB }}