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: round-trip template tasks through list, persistence, and delete (#11887)

Adam Eivyc740998d4378
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index d6cb293a0e..e4c62f500a 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -1560,15 +1560,23 @@ describe('taskSchedule', () => {
expect(result.name).toBe('Custom audit')
})
- it('should get template tasks', async () => {
- const templates = await getTemplateTasks()
- expect(Array.isArray(templates)).toBe(true)
- })
+ it('round-trips a template through listing, the persisted payload, and delete', async () => {
+ // Store reads the file on every call, so each write is fed back as the next read.
+ mockSchedule()
+ const template = await addTemplateTask({ name: 'Round trip', prompt: 'test' })
+ const afterAdd = JSON.parse(writeFile.mock.calls.at(-1)[1])
+ expect(afterAdd.templates.map(t => t.id)).toContain(template.id)
+ readJSONFile.mockResolvedValue(afterAdd)
+ expect((await getTemplateTasks()).map(t => t.id)).toContain(template.id)
- it('should delete template task', async () => {
- const template = await addTemplateTask({ name: 'To delete', prompt: 'test' })
const result = await deleteTemplateTask(template.id)
expect(result.success).toBe(true)
+ const afterDelete = JSON.parse(writeFile.mock.calls.at(-1)[1])
+ expect(afterDelete.templates.map(t => t.id)).not.toContain(template.id)
+ readJSONFile.mockResolvedValue(afterDelete)
+ expect((await getTemplateTasks()).map(t => t.id)).not.toContain(template.id)
+
+ expect(await deleteTemplateTask(template.id)).toMatchObject({ error: expect.any(String) })
})
})