Skip to content

Update settings tests to assert field inclusion in API responses #634

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

Merged
merged 1 commit into from
Jun 10, 2025

Conversation

Strift
Copy link
Contributor

@Strift Strift commented Jun 4, 2025

Pull Request

Related issue

This PR makes the settings tests more flexible by avoiding breaking when a Meilisearch version returns a new field that did not exist previously. See discussion meilisearch/integration-guides#316.

What does this PR do?

  • Update settings tests to assert field inclusion in API responses (instead of API egality)

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • Tests
    • Updated test assertions for index settings to allow for partial matches, making tests more flexible regarding additional returned data.

@Strift Strift self-assigned this Jun 4, 2025
@Strift Strift added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Jun 4, 2025
Copy link

coderabbitai bot commented Jun 4, 2025

Walkthrough

The test assertions in the Meilisearch index settings spec were updated from strict equality checks to partial inclusion checks. This adjustment affects pagination, typo tolerance, faceting, and localized attributes, allowing the tests to pass as long as the expected key-value pairs are present, regardless of any additional data.

Changes

File(s) Change Summary
spec/meilisearch/index/settings_spec.rb Updated test assertions from strict equality (eq) to inclusion (include) for several settings.

Poem

In the warren of specs, we now softly peek,
Not for perfect matches, but the values we seek.
Inclusion, not precision, is now our delight,
As extra keys hop in, we still test it right.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b1cd31 and c86b7e5.

📒 Files selected for processing (1)
  • spec/meilisearch/index/settings_spec.rb (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
spec/meilisearch/index/settings_spec.rb (3)
lib/meilisearch/index.rb (11)
  • pagination (561-563)
  • update_pagination (566-569)
  • reset_pagination (572-575)
  • typo_tolerance (577-579)
  • update_typo_tolerance (582-586)
  • reset_typo_tolerance (589-592)
  • faceting (594-596)
  • update_faceting (599-603)
  • reset_faceting (606-609)
  • localized_attributes (699-701)
  • update_localized_attributes (703-709)
lib/meilisearch/models/task.rb (1)
  • await (114-121)
lib/meilisearch/utils.rb (1)
  • transform_attributes (32-42)
🔇 Additional comments (4)
spec/meilisearch/index/settings_spec.rb (4)

548-571: LGTM: Improved test flexibility for pagination settings.

The change from strict equality to inclusion checks allows the tests to pass when Meilisearch introduces additional fields in pagination responses, while still validating that the expected fields are present and correct.


606-620: LGTM: Improved test flexibility for typo tolerance settings.

The inclusion-based assertions ensure that the expected typo tolerance configuration is present while accommodating potential additional fields in future API versions.


632-659: LGTM: Improved test flexibility for faceting settings.

The change to inclusion checks maintains validation of the core faceting configuration while allowing for API response evolution.


784-798: LGTM: Well-designed approach for localized attributes validation.

The updated assertion strategy for localized attributes is well-thought-out:

  • Validates the response is an array with the expected length
  • Uses inclusion checks for the array elements to allow for additional fields

This approach maintains test reliability while accommodating API evolution for array-based responses.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jun 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5b1cd31) to head (c86b7e5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #634   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          804       804           
=========================================
  Hits           804       804           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes settings tests more flexible by replacing strict equality checks with partial inclusion checks, preventing failures when new fields appear in API responses.

  • Replace eq matcher with include for pagination, typo tolerance, and faceting settings assertions.
  • Refactor localized_attributes tests to verify array structure and partial matching of expected entries.
Comments suppressed due to low confidence (2)

spec/meilisearch/index/settings_spec.rb:609

  • The test description mistypes the method name as update_type_tolerance; rename it to update_typo_tolerance for consistency with the tested method.
it '#update_type_tolerance updates typo tolerance settings' do

spec/meilisearch/index/settings_spec.rb:801

  • [nitpick] For consistency with other settings tests and to avoid breaks if new fields appear, consider using include instead of eq when asserting default localized attributes.
expect(index.localized_attributes).to eq(default_localized_attributes)

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

LGTM!

bors merge

Copy link
Contributor

meili-bors bot commented Jun 10, 2025

@meili-bors meili-bors bot merged commit 7f3a162 into main Jun 10, 2025
9 checks passed
@meili-bors meili-bors bot deleted the chore/permissive-settings-tests branch June 10, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants