diff --git a/src/domain/chains/entities/schemas/__tests__/chain.schema.spec.ts b/src/domain/chains/entities/schemas/__tests__/chain.schema.spec.ts index b782c225b1..d7f2bbfa97 100644 --- a/src/domain/chains/entities/schemas/__tests__/chain.schema.spec.ts +++ b/src/domain/chains/entities/schemas/__tests__/chain.schema.spec.ts @@ -660,7 +660,7 @@ describe('Chain schemas', () => { expect(result.success).toBe(true); }); - it('should exclude invalid Chain items, adjusting the count accordingly', () => { + it('should exclude invalid Chain items', () => { const chains = faker.helpers.multiple(() => chainBuilder().build(), { count: { min: 1, max: 5 }, }); @@ -674,10 +674,6 @@ describe('Chain schemas', () => { const result = ChainLenientPageSchema.safeParse(chainPage); expect(result.success).toBe(true); - expect(result.success && result.data.results.length).toBe( - chains.length - 1, - ); - expect(result.success && result.data.count).toBe(chains.length - 1); }); }); }); diff --git a/src/domain/entities/schemas/page.schema.factory.spec.ts b/src/domain/entities/schemas/page.schema.factory.spec.ts index 1b586c5abe..d73ce92912 100644 --- a/src/domain/entities/schemas/page.schema.factory.spec.ts +++ b/src/domain/entities/schemas/page.schema.factory.spec.ts @@ -174,7 +174,7 @@ describe('Page schema factory', () => { }, ); - it('should remove invalid items from results, reducing count accordingly', () => { + it('should remove invalid items from results', () => { const results = faker.helpers.multiple( () => ({ test: faker.lorem.word() }), { count: { min: 2, max: 5 } }, @@ -192,7 +192,6 @@ describe('Page schema factory', () => { const result = Schema.safeParse(page); - expect(result.success && result.data.count).toBe(results.length - 1); expect(result.success && result.data.results).toStrictEqual( results.slice(1), ); diff --git a/src/domain/entities/schemas/page.schema.factory.ts b/src/domain/entities/schemas/page.schema.factory.ts index 4c6ed5b507..b99f7343ce 100644 --- a/src/domain/entities/schemas/page.schema.factory.ts +++ b/src/domain/entities/schemas/page.schema.factory.ts @@ -30,9 +30,14 @@ export function buildLenientPageSchema( return result.success ? [result.data] : []; }); + // Note: @TODO The `results` object includes a `count` property, which the client is not currently using. + // We validate the chains and subtract the invalid ones from the count. + // However, due to pagination, we can only validate the chains on the current page, + // meaning the count may still include invalid chains from subsequent pages. + // For now, it's acceptable to ignore these inaccuracies in the count. + // That said, we should address this issue in the future to ensure the count is fully accurate. return { ...data, - count: results.length, results, }; }); diff --git a/src/routes/chains/chains.controller.spec.ts b/src/routes/chains/chains.controller.spec.ts index 8da30cedf0..9771c8ba11 100644 --- a/src/routes/chains/chains.controller.spec.ts +++ b/src/routes/chains/chains.controller.spec.ts @@ -215,8 +215,6 @@ describe('Chains Controller (Unit)', () => { networkService.get.mockResolvedValueOnce({ data: rawify({ ...chainsResponse, - // Ensure count does not include invalid chains - count: chainsResponse.results.length + invalidChains.length, results: [...chainsResponse.results, ...invalidChains], }), status: 200,