d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
79 lines
2.3 KiB
TypeScript
79 lines
2.3 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
findWorkspaceFileRecord,
|
|
normalizeWorkspaceFileReference,
|
|
type WorkspaceFileRecord,
|
|
} from './workspace-file-manager'
|
|
|
|
const FILE_ID = 'ec28e5d5-898a-48f0-aa6f-2fd7427c9563'
|
|
|
|
function makeFileRecord(): WorkspaceFileRecord {
|
|
return {
|
|
id: FILE_ID,
|
|
workspaceId: 'ws_123',
|
|
name: 'the_last_cartographer_of_vael.md',
|
|
key: 'workspace/ws_123/mock-key',
|
|
path: '/api/files/serve/mock-key?context=workspace',
|
|
size: 128,
|
|
type: 'text/markdown',
|
|
uploadedBy: 'user_123',
|
|
folderId: null,
|
|
folderPath: null,
|
|
uploadedAt: new Date('2026-04-13T00:00:00.000Z'),
|
|
updatedAt: new Date('2026-04-13T00:00:00.000Z'),
|
|
}
|
|
}
|
|
|
|
describe('workspace file reference normalization', () => {
|
|
it('normalizes canonical VFS paths to their sanitized display path', () => {
|
|
expect(normalizeWorkspaceFileReference('files/Reports/q1.csv/content')).toBe('Reports/q1.csv')
|
|
expect(normalizeWorkspaceFileReference('files/Reports/q1.csv/meta.json')).toBe('Reports/q1.csv')
|
|
expect(normalizeWorkspaceFileReference('recently-deleted/files/data.csv/content')).toBe(
|
|
'data.csv'
|
|
)
|
|
})
|
|
|
|
it('still resolves a raw file id passed directly', () => {
|
|
const files = [makeFileRecord()]
|
|
|
|
expect(findWorkspaceFileRecord(files, FILE_ID)).toMatchObject({
|
|
id: FILE_ID,
|
|
name: 'the_last_cartographer_of_vael.md',
|
|
})
|
|
})
|
|
|
|
it('does not resolve id-based VFS paths', () => {
|
|
const files = [makeFileRecord()]
|
|
|
|
expect(findWorkspaceFileRecord(files, `files/by-id/${FILE_ID}/content`)).toBeNull()
|
|
})
|
|
|
|
it('resolves duplicate names by folder-aware VFS path', () => {
|
|
const reportsFile: WorkspaceFileRecord = {
|
|
...makeFileRecord(),
|
|
id: 'file-reports',
|
|
name: 'q1.csv',
|
|
folderId: 'folder-reports',
|
|
folderPath: 'Reports',
|
|
}
|
|
const archiveFile: WorkspaceFileRecord = {
|
|
...makeFileRecord(),
|
|
id: 'file-archive',
|
|
name: 'q1.csv',
|
|
folderId: 'folder-archive',
|
|
folderPath: 'Archive',
|
|
}
|
|
|
|
expect(
|
|
findWorkspaceFileRecord([reportsFile, archiveFile], 'files/Reports/q1.csv/content')
|
|
).toBe(reportsFile)
|
|
expect(findWorkspaceFileRecord([reportsFile, archiveFile], 'files/Archive/q1.csv')).toBe(
|
|
archiveFile
|
|
)
|
|
})
|
|
})
|