Skip to content

fix: failing tests by updating expectations to match current API behavior#63

Merged
nicolasleger merged 3 commits intomainfrom
copilot/fix-eb08a182-c951-4076-a9b7-1b2aef294dcb
Sep 29, 2025
Merged

fix: failing tests by updating expectations to match current API behavior#63
nicolasleger merged 3 commits intomainfrom
copilot/fix-eb08a182-c951-4076-a9b7-1b2aef294dcb

Conversation

Copy link
Contributor

Copilot AI commented Sep 29, 2025

The test suite was failing due to changes in the Open Beauty Facts API and data availability. This PR addresses multiple categories of test failures to restore a passing test suite.

Issues Fixed

URL Format Changes

The API changed URL formats from /state/ to /facets/states/. Updated the test_it_fetches_product_states test to expect the new URL format:

# Before: 'https://world.openbeautyfacts.org/state/empty'
# After:  'https://world.openbeautyfacts.org/facets/states/empty'

Data Availability Changes

Several tests expected specific data points that are no longer available in the API responses. Updated these tests to be more resilient:

  • Entry dates and last edit dates tests now check for dates that still exist (2016-02 instead of 2017-03-09)
  • Ingredients test now checks for common ingredients like "water" or "aqua" instead of expecting exactly "Water"
  • Additives test now validates structure and URL format instead of specific additive URLs

Empty API Responses

Multiple API endpoints now return empty results where they previously had data. These tests have been appropriately skipped with clear documentation:

  • Products for specific entry dates, brands, ingredients, states
  • Products with specific additives or number of ingredients
  • Mission-related functionality (also has implementation issues)

Test Results

  • Before: 17 failures + 1 error + 4 existing skips
  • After: 0 failures + 0 errors + 14 skips (36 runs, 57 assertions)

All skipped tests include clear explanations for why they cannot currently pass. The core functionality of the gem remains intact and all essential features are properly tested.

Verification

  • ✅ All tests pass
  • ✅ Gem builds successfully
  • ✅ Basic functionality verified (version access, product URL generation)
  • ✅ No breaking changes to existing API
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix tests</issue_title>
<issue_description>### What
Some tests were not passing, better fix or skip them.

Steps to reproduce the behavior:

  1. rake test

Expected behavior

Tests are passing.
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #62

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…alls

Co-authored-by: nicolasleger <570901+nicolasleger@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tests Fix failing tests by updating expectations to match current API behavior Sep 29, 2025
Copilot AI requested a review from nicolasleger September 29, 2025 17:16
@nicolasleger nicolasleger changed the title Fix failing tests by updating expectations to match current API behavior fix: failing tests by updating expectations to match current API behavior Sep 29, 2025
…ng sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@nicolasleger nicolasleger marked this pull request as ready for review September 29, 2025 17:32
@nicolasleger nicolasleger merged commit f475f07 into main Sep 29, 2025
9 checks passed
@nicolasleger nicolasleger deleted the copilot/fix-eb08a182-c951-4076-a9b7-1b2aef294dcb branch September 29, 2025 17:34
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.

Fix tests

2 participants