hermes-agent/apps/desktop/e2e/profile-soul-missing.spec.ts
BlackishGreen33 55e27e5dbe fix(desktop): explain missing profile SOUL.md files
The backend already reports {content, exists} from GET
/api/profiles/{name}/soul, but both SOUL.md editors read only content —
a profile whose personality lives in config.yaml
(agent.personalities.<name>) rendered a blank CodeEditor with no hint
that anything was missing or where the persona actually lives (#89436).

Both surfaces (Profiles view editor and the sidebar Edit SOUL.md
dialog) now show a localized notice when exists is false: no SOUL.md
exists yet, instructions below will create one on save, and config.yaml
personality presets are managed separately. The notice clears on a
successful save; an existing empty file or a read error is never
misreported as missing.

i18n: soulMissing added to every full locale (de/es/fr are override
locales and fall back to English). Component tests cover the
missing/empty/read-error distinction and cross-profile leakage; an e2e
spec drives both editors end to end.

The config.yaml read-back fallback and the dashboard source indicator
stay deferred to the personality-precedence work (#82801).

Salvaged from PR #105201 (author preserved).

Fixes #89436
2026-09-27 06:54:56 -05:00

63 lines
3.2 KiB
TypeScript

import fs from 'node:fs'
import path from 'node:path'
import { writeMockProviderConfig } from '../../../tests-js/scripts/mock-provider-config'
import { setupMockBackend, waitForAppReady } from './fixtures'
import { expect, test } from './test'
test('both SOUL editors explain a missing file and save it without changing personality config', async () => {
test.setTimeout(180_000)
const fixture = await setupMockBackend()
const { page, sandbox, mockUrl } = fixture
const profileName = 'soul-test'
const profileHome = path.join(sandbox.hermesHome, 'profiles', profileName)
fs.mkdirSync(profileHome, { recursive: true })
writeMockProviderConfig(profileHome, mockUrl, undefined, 'personalities:\n helper: "Keep answers brief."')
const configPath = path.join(profileHome, 'config.yaml')
const config = fs.readFileSync(configPath, 'utf8')
const soulPath = path.join(profileHome, 'SOUL.md')
const missing = /No SOUL\.md file exists for this profile/
try {
await waitForAppReady(fixture, 120_000)
await page.getByRole('button', { name: 'Manage profiles…' }).click()
await page.locator(`[data-panel-row="${profileName}"] [data-slot="row-button"]`).click()
await expect(page.locator('.cm-content')).toBeVisible()
// First-use initialization can seed a default SOUL.md. Remove only this
// sandbox profile's file after initialization to exercise the missing state.
fs.rmSync(soulPath, { force: true })
await page.locator('[data-panel-row="default"] [data-slot="row-button"]').click()
await page.locator(`[data-panel-row="${profileName}"] [data-slot="row-button"]`).click()
await expect(page.locator('.cm-content')).toBeVisible()
expect(fs.existsSync(soulPath)).toBe(false)
await expect(page.getByText(missing)).toBeVisible()
await page.screenshot({ path: test.info().outputPath('missing-soul.png') })
// Dismiss without saving: the sidebar editor must report the same state,
// not silently create a file merely because either editor was opened.
await page.getByRole('button', { name: 'Close profiles' }).click()
const square = page.locator('[data-slot="profile-rail"]').getByRole('button', { name: profileName, exact: true })
await square.click({ button: 'right' })
await page.getByRole('menuitem', { name: 'Edit SOUL.md…' }).click()
const dialog = page.getByRole('dialog')
await expect(dialog.getByText(missing)).toBeVisible()
expect(fs.existsSync(soulPath)).toBe(false)
await page.screenshot({ path: test.info().outputPath('missing-soul-dialog.png') })
const instructions = '# Soul test\n\nGive concise answers.'
await dialog.locator('.cm-content').fill(instructions)
await dialog.getByRole('button', { name: 'Save SOUL.md' }).click()
await expect(dialog).toBeHidden()
expect(fs.readFileSync(soulPath, 'utf8')).toBe(instructions)
expect(fs.readFileSync(configPath, 'utf8')).toBe(config)
await page.getByRole('button', { name: 'Manage profiles…' }).click()
await page.locator(`[data-panel-row="${profileName}"] [data-slot="row-button"]`).click()
await expect(page.locator('.cm-content')).toContainText('Give concise answers.')
await expect(page.getByText(missing)).toHaveCount(0)
} finally {
await fixture.cleanup()
}
})