Feature: Manage employees

  @javascript
  Scenario: create an not yet existing extra employee
    Given there is a confirmed and open supplier
    And I am signed in as supplier
    When the supplier employee visits the 'employees' path
    And I click on selector '.new-employee-button'
    And the supplier emloyee sets the 'name' to 'New employee' in the employee popup
    And the supplier emloyee sets the 'email' to 'new-employee@example.com' in the employee popup
    And I click on selector '.form-row.manager label'
    And I click on selector '.modal-confirm'
    And I wait 1 second
    Then the new employee should be added to the supplier
    When I reload the page
    Then the supplier employee should see content 'new-employee@example.com'

  @javascript
  Scenario: adding an already existing employee that was firstly added as manager without manager and active
    Given there is a confirmed and open supplier
    And I am signed in as supplier
    When the supplier employee visits the 'employees' path
    And I click on selector '.new-employee-button'
    And the supplier emloyee sets the 'name' to 'Existing employee' in the employee popup
    And the supplier emloyee sets the 'email' to 'existing-employee@example.com' in the employee popup
    And I click on selector '.form-row.manager label'
    And I click on selector '.modal-confirm'
    And the supplier employee clicks on the existing employee table destroy button
    And I click on selector '.modal-confirm'
    And I click on selector '.new-employee-button'
    And the supplier emloyee sets the 'name' to 'Existing employee readded' in the employee popup
    And the supplier emloyee sets the 'email' to 'existing-employee@example.com' in the employee popup
    And I click on selector '.form-row.active label'
    And I click on selector '.modal-confirm'
    And I wait 1 second
    Then the new employee should be re-added to the supplier as non manager non active

  @javascript
  Scenario: a just signed up manager can manage employees
    Given there is a confirmed and open supplier
    And there is an other employee
    And I am signed in as supplier
    When the supplier employee visits the 'employees' path
    And the supplier employee clicks on the other employee table edit button
    And the supplier emloyee sets the 'name' to 'Edited employee' in the employee popup
    And the supplier emloyee clicks the active switch to deactivate the employee
    And the supplier employee clicks the confirm modal button
    Then the other employee should no longer be active for the current supplier
