Feature: Managing a recipe from the catalog
  As a signed-in user
  I want to favorite or delete one of my recipes
  So that I can curate my catalog as it grows

  Background:
    Given I am signed in as "Alice" "Martin"
    And my household id is 1
    And the disliked ingredients list is empty

  Scenario: Toggles a recipe's favorite from the detail panel and reflects it in the table
    Given the recipe catalog contains "Omelette"
    And recipe 2's detail is available
    And toggling recipe 2's favorite will succeed
    When I visit "/recettes/2"
    Then the recipe "Omelette" should not be marked as favorite
    When I click the favorite star
    Then the favorite request should have been made
    And the favorite star should be marked as favorite
    And the recipe "Omelette" should be marked as favorite

  Scenario: Highlights a detected technique in a step, with its name shown on focus
    Given the recipe catalog contains "Omelette"
    And recipe 2's detail is available
    When I visit "/recettes/2"
    Then I should see the highlighted technique "Cuire"
    When I focus the highlighted technique "Cuire"
    Then the tooltip should show "Cuire"

  Scenario: Corrects a detected technique from its highlight, visible immediately as a manual match
    Given the recipe catalog contains "Omelette"
    And recipe 2's detail is available
    And the tech steps reference list has options
    And correcting step 2's "Cuire" match will succeed
    When I visit "/recettes/2"
    And I click the highlighted technique "Cuire"
    Then I should see the technique correction options
    When I choose "Mijoter" as the correct technique
    Then the correction request should have been made
    # The highlighted *word* stays "Cuire" (a relabel changes which
    # technique a span means, not the literal text at that span, still
    # "Cuire" in the source description) — now styled as a manual
    # correction, with its tooltip naming the newly-assigned technique.
    And the highlighted technique "Cuire" should be marked as a manual correction
    When I focus the highlighted technique "Cuire"
    Then the tooltip should show "Mijoter (correction manuelle)"

  Scenario: Deletes a recipe after a two-step confirmation, then clears the selection
    Given the recipe catalog contains "Omelette"
    And recipe 2's detail is available
    And deleting recipe 2 will succeed
    When I visit "/recettes/2"
    Then the recipe detail panel heading should be "Omelette"
    When I click "Supprimer" in the recipe detail panel
    And I confirm the deletion in the recipe detail panel
    Then the delete request should have been made
    And the URL should match the recipes list
    And the recipe "Omelette" should not be visible in the table
    And I should see "Sélectionnez une recette dans le tableau"
