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.
This commit is contained in:
KernelDeimos
2026-01-13 12:58:06 -05:00
committed by Eric Dubé
parent 519ad336ba
commit 5b33beb6a1
@@ -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);
});
});