Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test([issue-1848]): replace weak toBeTruthy assertions with concrete value/shape checks

[._.]/ Adam Eivy1ab6ce277fdd
diff --git a/server/lib/commandSecurity.test.js b/server/lib/commandSecurity.test.js
index 70d03c1ed4..4309a3b25b 100644
--- a/server/lib/commandSecurity.test.js
+++ b/server/lib/commandSecurity.test.js
@@ -50,6 +50,23 @@ describe('commandSecurity', () => {
expect(ALLOWED_COMMANDS.has(cmd)).toBe(true)
}
})
+
+ // Anchor against known-safe entries so the allowlist can't silently lose a
+ // command everything else depends on. Iterating the array against itself
+ // (above) is tautological — these assert real, expected membership.
+ it.each(['git', 'gh', 'node', 'npm', 'pm2', 'ls', 'cat', 'echo'])(
+ 'includes the known-safe command %s',
+ (cmd) => {
+ expect(ALLOWED_COMMANDS.has(cmd)).toBe(true)
+ expect(ALLOWED_COMMANDS_SORTED).toContain(cmd)
+ },
+ )
+
+ it('does NOT include dangerous commands that were never on the allowlist', () => {
+ for (const cmd of ['rm', 'env', 'sudo', 'sh', 'bash', 'eval']) {
+ expect(ALLOWED_COMMANDS.has(cmd)).toBe(false)
+ }
+ })
})
describe('DANGEROUS_SHELL_CHARS', () => {
diff --git a/server/lib/fileUtils.test.js b/server/lib/fileUtils.test.js
index 748ec20043..2231c4a66d 100644
--- a/server/lib/fileUtils.test.js
+++ b/server/lib/fileUtils.test.js
@@ -672,10 +672,12 @@ describe('fileUtils', () => {
it('resolves a basename present only in visualTemplates', () => {
const out = resolveImageInputPath(templateName);
- expect(out).toBeTruthy();
- // visualTemplates is the third root; without a basename in gallery first
- // it falls through. We can't fully isolate that here without temp dirs,
- // so just assert the resolver doesn't return null.
+ // `templateName` is unique to the visualTemplates root (it is NOT copied
+ // into gallery or image-refs), so the resolver must land on the third
+ // root and the returned path must carry that root's segment + basename —
+ // a plain truthiness check would pass even on a wrong-root resolution.
+ expect(out).toContain('data/templates/');
+ expect(out).toContain(templateName);
});
it('REGRESSION: absolute path under a specific root stays in that root', () => {
diff --git a/server/services/autobiography.test.js b/server/services/autobiography.test.js
index 9e9d89ee04..5fb5c737fa 100644
--- a/server/services/autobiography.test.js
+++ b/server/services/autobiography.test.js
@@ -193,7 +193,13 @@ describe('Autobiography - getNextPrompt', () => {
const prompt = await getNextPrompt();
- expect(prompt).toBeTruthy();
+ // A real prompt object, not just any truthy value.
+ expect(prompt).toMatchObject({
+ id: expect.any(String),
+ themeId: expect.any(String),
+ text: expect.any(String),
+ });
+ expect(prompt.text.length).toBeGreaterThan(0);
// usedPrompts should have been reset
expect(savedData.usedPrompts).toEqual([]);
});
@@ -236,7 +242,8 @@ describe('Autobiography - getPromptById', () => {
expect(prompt.id).toBe('childhood-0');
expect(prompt.themeId).toBe('childhood');
expect(prompt.themeLabel).toBe('Childhood');
- expect(prompt.text).toBeTruthy();
+ expect(typeof prompt.text).toBe('string');
+ expect(prompt.text.length).toBeGreaterThan(0);
});
it('should return null for an invalid ID', () => {
@@ -276,7 +283,8 @@ describe('Autobiography - saveStory', () => {
expect(story.themeLabel).toBe('Childhood');
expect(story.content).toBe('My first memory is the old red house.');
expect(story.wordCount).toBe(8);
- expect(story.createdAt).toBeTruthy();
+ // createdAt must be a round-trippable ISO-8601 timestamp, not just truthy.
+ expect(new Date(story.createdAt).toISOString()).toBe(story.createdAt);
});
it('should add the prompt to usedPrompts', async () => {
@@ -348,7 +356,12 @@ describe('Autobiography - updateStory', () => {
expect(updated.content).toBe('Updated content with more words');
expect(updated.wordCount).toBe(5);
- expect(updated.updatedAt).toBeTruthy();
+ // updatedAt is a valid ISO timestamp and strictly newer than the
+ // original createdAt (2026-01-01), not merely truthy.
+ expect(new Date(updated.updatedAt).toISOString()).toBe(updated.updatedAt);
+ expect(new Date(updated.updatedAt).getTime()).toBeGreaterThan(
+ new Date('2026-01-01T00:00:00.000Z').getTime(),
+ );
});
it('should return null for non-existent story', async () => {
@@ -615,7 +628,10 @@ describe('Autobiography - checkAndPrompt', () => {
expect(result.prompted).toBe(true);
expect(savedConfig).not.toBeNull();
- expect(savedConfig.lastPromptAt).toBeTruthy();
+ // lastPromptAt is a valid ISO timestamp, freshly stamped — strictly newer
+ // than the 48h-old value we seeded — not merely truthy.
+ expect(new Date(savedConfig.lastPromptAt).toISOString()).toBe(savedConfig.lastPromptAt);
+ expect(new Date(savedConfig.lastPromptAt).getTime()).toBeGreaterThan(new Date(oldTime).getTime());
expect(savedConfig.lastPromptId).toBe(result.prompt.id);
});
@@ -691,7 +707,9 @@ describe('Autobiography - generateFollowUps (depth-aware)', () => {
expect(result.followUps).toHaveLength(3);
expect(saved.stories[0].followUpPrompts).toEqual(['Q1?', 'Q2?', 'Q3?']);
- expect(saved.stories[0].followUpsGeneratedAt).toBeTruthy();
+ // followUpsGeneratedAt is a round-trippable ISO timestamp, not just truthy.
+ const generatedAt = saved.stories[0].followUpsGeneratedAt;
+ expect(new Date(generatedAt).toISOString()).toBe(generatedAt);
});
it('passes shallow (depth-1) guidance for a root story', async () => {
diff --git a/server/services/storyBuilder.test.js b/server/services/storyBuilder.test.js
index 0dbc689ab3..cf8556aa47 100644
--- a/server/services/storyBuilder.test.js
+++ b/server/services/storyBuilder.test.js
@@ -277,7 +277,8 @@ describe('storyBuilder — catalog ingredient linking (#1761)', () => {
// Session was saved despite the link failure, and the shells exist.
expect(s.id).toMatch(/^stb-/);
expect((await sb.listStorySessions()).map((x) => x.id)).toContain(s.id);
- expect(await seriesSvc.getSeries(s.seriesId)).toBeTruthy();
+ const persistedSeries = await seriesSvc.getSeries(s.seriesId);
+ expect(persistedSeries.id).toBe(s.seriesId);
expect(catalogMocks.linkIngredientsToSeries).toHaveBeenCalledWith(s.seriesId, [ing]);
});
@@ -299,7 +300,8 @@ describe('storyBuilder — lock state machine + gating', () => {
const s = await sb.createStorySession({ title: 'X', seedIdea: 'seed' });
const locked = await sb.lockStep(s.id, 'idea');
expect(locked.steps.idea.locked).toBe(true);
- expect(locked.steps.idea.lockedAt).toBeTruthy();
+ // lockedAt is a round-trippable ISO-8601 timestamp, not merely truthy.
+ expect(new Date(locked.steps.idea.lockedAt).toISOString()).toBe(locked.steps.idea.lockedAt);
// Shape AND derivation: the stamped hash must be the SAME value the
// integrity helper produces from the idea step's whitelisted upstream
// inputs — not just any 64-char hex digest. Asserting against the real