From 5b33beb6a12fc3aeaa659dacd47255354ea78bf9 Mon Sep 17 00:00:00 2001 From: KernelDeimos <7225168+KernelDeimos@users.noreply.github.com> Date: Tue, 13 Jan 2026 12:58:06 -0500 Subject: [PATCH] test(data-access): check for error, not undefined Check for error when an app doesn't exist, because this is the behavior `es:app` already exhibits. --- .../data-access/AppService.comp.test.js | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/backend/src/modules/data-access/AppService.comp.test.js b/src/backend/src/modules/data-access/AppService.comp.test.js index 8940391b0..2b03370bf 100644 --- a/src/backend/src/modules/data-access/AppService.comp.test.js +++ b/src/backend/src/modules/data-access/AppService.comp.test.js @@ -281,14 +281,21 @@ describe('AppService Regression Prevention Tests', () => { }); }); - it('should return undefined for non-existent app', async () => { + it('should throw error for non-existent app', async () => { await testWithEachService(async ({ kernel, key }) => { const service = kernel.services.get(key); const crudQ = service.constructor.IMPLEMENTS['crud-q']; - // Try to read a non-existent app - const read = await crudQ.read.call(service, { uid: 'app-nonexistent-uid' }); - expect(read).toBeUndefined(); + // Try to read a non-existent app - should throw entity_not_found + let errorThrown = false; + try { + await crudQ.read.call(service, { uid: 'app-nonexistent-uid' }); + } catch ( error ) { + errorThrown = true; + const code = error.fields?.code || error.code; + expect(code).toBe('entity_not_found'); + } + expect(errorThrown).toBe(true); }); }); }); @@ -589,12 +596,18 @@ describe('AppService Regression Prevention Tests', () => { }); // Delete it - const result = await crudQ.delete.call(service, { uid: created.uid }); - expect(result.success).toBe(true); + await crudQ.delete.call(service, { uid: created.uid }); - // Verify it's gone - const read = await crudQ.read.call(service, { uid: created.uid }); - expect(read).toBeUndefined(); + // Verify it's gone - should throw entity_not_found + let errorThrown = false; + try { + await crudQ.read.call(service, { uid: created.uid }); + } catch ( error ) { + errorThrown = true; + const code = error.fields?.code || error.code; + expect(code).toBe('entity_not_found'); + } + expect(errorThrown).toBe(true); }); });