Feature: Supplier section view

  @javascript
  Scenario: the section view displays tables and keeps their status information
    Given there is an active list and order
    And I am signed in as supplier

    When I visit the supplier section path
    Then the section table should be positioned in the section
    And the section table should be marked as having an active order
    And the section table should be marked as occupied
    And the section table should not be marked as in need of help

    When the order gets marked as being in process
    Then the section table should still be marked as having an active order

    When the list is marked as in need of help
    # waiting here only needed in old style implementation
    And I wait 1 second
    Then the section table should be marked as in need of help

    When I click on section table as a supplier
    Then A popup having table options should appear in supplier section area

    When I click on the mark list as helped in the section table popup as supplier
    And I wait 1 second
    Then the section table should not be marked as in need of help
    And the section table popup should no longer have the mark list as helped button

    When the list is marked as in need of payment
    Then the section table should be marked as in need of payment

    And I wait 0.5 seconds

    When I click on the close list button in the section table table popup
    And I wait 1 second
    Then the section table should not have any active list markings anymore
    And the list should be marked as closed

  @javascript
  Scenario: Selecting a specific section limits the result to the lists and orders of those sections
    Given there is an active list and order
    And I am signed in as supplier
    And a new order on a table in another section is created
    Then I should see the list and the new list
    And I should see the order and the new order
    When I select the section in the supplier dashboard
    Then I should see the list and order but not the new list and new order
    When I select the new section in the supplier dashboard
    Then I should see the new list and new order but not the list and order
    When I reset the section selector in the supplier dashboard
    Then I should see the list and the new list
    And I should see the order and the new order


  @javascript
  Scenario: Going to edit mode and change section properties
    Given there is an active list and order
    And there are 2 supplier sections
    And the last supplier section has a table with known coordinates
    And I am signed in as supplier
    When I visit the supplier last section path
    And I click the supplier section edit mode button
    And I fill in the supplier edit section form with new values
    Then the last section tab header should have the newly filled in name
    When I click the supplier section normal mode button
    Then the supplier last section properties should be updated to the new values

  @javascript
  Scenario: A new order is created when the view is already loaded
    Given there is a confirmed and open supplier
    And there is a table in the section
    And there is a product
    And I am signed in as supplier
    When I visit the supplier section path
    And A new order is placed
    Then the table should be marked as occupied and having an active order
    When the supplier clicks on the table having the new list
    Then the supplier table actions of the new list should be visible

  # capybara-webkit 1.1.0 drag to is not yet supported it seems
  @javascript @broken
  Scenario: Dragging a table to another section
    Given there is an active list and order
    And there are 2 supplier sections
    And the last supplier section has a table with known coordinates
    And I am signed in as supplier
    When I visit the supplier last section path
    And I click the supplier section edit mode button
    And I drag the table from the last section to the first section tab header
    And I wait 1 second
    Then the supplier table should have been linked to the first section
