From 05d60305fdf9939c62d0f1b0c4826ac144a9fd2d Mon Sep 17 00:00:00 2001 From: Andrew Plummer Date: Tue, 25 Jun 2024 19:20:35 +0900 Subject: [PATCH] fixed csv test breakage --- services/api/src/utils/__tests__/csv.js | 32 ++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/services/api/src/utils/__tests__/csv.js b/services/api/src/utils/__tests__/csv.js index d2383136..86ddd52b 100644 --- a/services/api/src/utils/__tests__/csv.js +++ b/services/api/src/utils/__tests__/csv.js @@ -85,22 +85,26 @@ describe('csvExport', () => { `); }); - it('should call toObject to prevent private field access', async () => { - const obj = { - user, - toObject: () => { - return { - user: { - firstName: 'Frank', - lastName: 'Reynolds', - }, - }; + it('should not export fields with no read access', async () => { + const User = createTestModel({ + name: { + type: 'String', }, - }; - const csv = await run([obj]); + secret: { + type: 'String', + readAccess: 'none', + }, + }); + const user = await User.create({ + name: 'Frank', + secret: 'secret!!', + }); + const created = user.createdAt.toISOString(); + const updated = user.updatedAt.toISOString(); + const csv = await run([user]); expect(csv).toBe(d` - user.firstName,user.lastName - Frank,Reynolds + name,createdAt,updatedAt + Frank,${created},${updated} `); });