From 33ad1fd63b91aa7c23d52c75bc75744b3e4af901 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Mon, 14 Apr 2025 11:45:45 -0400 Subject: [PATCH] chore: fix flaky api key test (#1357) ## Summary by CodeRabbit - **Tests** - Improved test validations to flexibly verify dynamic timestamp values in API responses. --- api/src/unraid-api/auth/api-key.service.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/unraid-api/auth/api-key.service.spec.ts b/api/src/unraid-api/auth/api-key.service.spec.ts index cc83fb494..dac020e60 100644 --- a/api/src/unraid-api/auth/api-key.service.spec.ts +++ b/api/src/unraid-api/auth/api-key.service.spec.ts @@ -317,8 +317,8 @@ describe('ApiKeyService', () => { ], }; - expect(result[0]).toEqual(expectedApiKey1); - expect(result[1]).toEqual(expectedApiKey2); + expect(result[0]).toMatchObject({ ...expectedApiKey1, createdAt: expect.any(String) }); + expect(result[1]).toMatchObject({ ...expectedApiKey2, createdAt: expect.any(String) }); }); it('should handle file read errors gracefully', async () => { @@ -334,7 +334,7 @@ describe('ApiKeyService', () => { const result = await apiKeyService.findById(mockApiKeyWithSecret.id); - expect(result).toEqual(mockApiKey); + expect(result).toMatchObject({ ...mockApiKey, createdAt: expect.any(String) }); }); it('should return null if API key not found', async () => {