Feature: Ordering a product as a user

  @javascript
  Scenario: Happy flow
    Given there is an open supplier with a menu
    And I am signed in as a user
    And I am on the user homepage
    When the user scans a table QR code
    And the user clicks on the order 'Heineken beer' twice
    Then the user order 'Heineken beer' should be in the order list with price
    And the user order total should not be visible for only one order
    When the user clicks on the order product button 'Apple pie'
    Then the user order total should be visible with the correct total price
    When the user clicks on the user order button
    Then the user should be redirected to the user order overview page
    And the supplier orders placed counter for the user should be 1
    And the user order should be created as a new order
    When the user order gets marked as being in process
    Then the user order should get feedback of being in process
    And the supplier orders placed counter for the user should be 0
    And the supplier orders in process counter for the user should be 1
    When the user order gets marked as being delivered
    Then the user order should get feedback of being delivered
    And the supplier orders in process counter for the user should be 0
    When the user orders list gets closed
    Then the user should be redirected to the archived list path

  @javascript
  Scenario: Resetting an active order
    Given there is an open supplier with a menu
    And I am signed in as a user
    And I am on the user homepage
    When the user scans a table QR code
    And the user clicks on the order 'Heineken beer' twice
    And the user clicks on the order product button 'Apple pie'
    And the user clicks on the clear order for the last order button
    And the user clicks on the clear order for the last order button
    Then the user should see an empty active order panel
    And the user clicks on the order 'Heineken beer' twice
    And the user clicks on the user order button
    Then an order with 2 products 'Heineken beer' should have been created
    And no order for the product 'Apple pie' should have been created

  @javascript
  Scenario: Loading lists and switching to the order products view works, lists loading may unlink active list orders
    Given there is an open supplier with a menu
    And there is a signed in user with an active order
    And the user has an older list for the same supplier
    And I wait 1 second
    And the user is on the order products page
    When the user opens the side menu
    And the user clicks on the lists link in the side menu
    And the user opens the side menu again
    And the user clicks on the order products link in the side menu
    Then the user should see the products listed for the active list
