Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set count as number of valid Page['results'] #1881

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Sep 2, 2024

Summary

Invalid Page['results'][number] items are excluding in lenient page schemas, but remain in the Page['count']. This adjusts buildLenientPageSchema to set the count as the valid results array length as per #1871 (comment).

Changes

  • Set count as length of valid Page['results']
  • Add/update tests accordingly

@iamacook iamacook self-assigned this Sep 2, 2024
@@ -281,6 +284,31 @@ describe('Chains Controller (Unit)', () => {
},
});
});

it('Failure: received data is not valid', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously in the suite but removed.

/**
* Builds a lenient page schema that filters out invalid items from the results array.
*/
export function buildLenientPageSchema<T extends z.ZodTypeAny>(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to the factory file as the base schema was extracted to BasePageSchema.

@iamacook iamacook marked this pull request as ready for review September 2, 2024 09:27
@iamacook iamacook requested a review from a team as a code owner September 2, 2024 09:27
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10664491020

Details

  • 5 of 9 (55.56%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 46.323%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/domain/entities/schemas/page.schema.factory.ts 4 8 50.0%
Totals Coverage Status
Change from base Build 10639751772: -0.004%
Covered Lines: 4811
Relevant Lines: 8364

💛 - Coveralls

@iamacook iamacook merged commit 66b0ed3 into main Sep 3, 2024
18 checks passed
@iamacook iamacook deleted the lenient-count branch September 3, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants