Feature: Masters Registry
  In order to manage territories on existing ISRC
  as an OA Technology_manager user
  I want to be able to lock territories for ISRCs

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Search masters registry for ISRC
    And I am on the MastersRegistry::MastersEditorPage
    When I search for ISRC: US26V4410006
    Then I should be on the MastersRegistry::MastersEditorPage for ISRC US26V4410006

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Bulk Lock Territories
    And I am on MastersRegistry::MastersEditorPage for ISRC: US26V4410006
    Given JO, ME are unclaimed
    Given I am on the MastersRegistry::BulkLockTerritoriesPage
    When I lock territories for ISRCs: US26V4410006
    Then I see a message indicating that the bulk action process started
    When I am on the MastersRegistry::BulkActionStatusPage
    Then I expect to see a success for the last bulk lock action
    Given I am on MastersRegistry::MastersEditorPage for ISRC: US26V4410006
    Then I should see the territories locked for the reason

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Single ISRC Territory Claims
    And I am on MastersRegistry::MastersEditorPage for ISRC: US26V4410006
    Given BV, CD, GG are unclaimed
    When I add BV, CD, GG to the Rightsholders section
    Then BV, CD, GG are added to the Rightsholders list
    When I remove BV, CD, GG from the Rightsholders section
    Then BV, CD, GG become unclaimed

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Single ISRC Territory Locks
    And I am on MastersRegistry::MastersEditorPage for ISRC: US26V4410006
    Given LV, MH, SD are unclaimed
    When I lock LV, MH, SD to the Locked Territories section
    Then LV, MH, SD are added to the Locked Territories list
    When I remove LV, MH, SD from the Locked Territories section
    Then LV, MH, SD become unclaimed

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Rightsholder Worldwide Territories
    Given there is no audit information for ISRC USA371130635
    When I unlock every territory for USA371130635
    Then I see a message indicating that the bulk action process started
    Given I am on the MastersRegistry::BulkActionStatusPage
    Then I expect to see a success for the last bulk lock action
    Given I am on MastersRegistry::MastersEditorPage for ISRC: USA371130635
    And every territory is unclaimed for the ISRC
    When I add a rightsholder for every territory
    Then every territory is claimed for the rightsholder

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Add a rightsholder for all except some territories
    And I am on MastersRegistry::MastersEditorPage for ISRC: USA371130635
    Given every territory is unclaimed for the ISRC
    When I add a rightsholder for every territory except EE, TT
    Then EE, TT should be the only unclaimed territories

  @frontend_masters_registry
  @ows_masters_registry
  Scenario: Bulk lock all except some territories
    And I am on MastersRegistry::MastersEditorPage for ISRC: USA371130635
    Given every territory is unclaimed for the ISRC
    Given I am on the MastersRegistry::BulkLockTerritoriesPage
    When I lock territories except EE, TT for ISRC: USA371130635
    Then I see a message indicating that the bulk action process started
    When I am on the MastersRegistry::BulkActionStatusPage
    Then I expect to see a success for the last bulk lock action
    Given I am on MastersRegistry::MastersEditorPage for ISRC: USA371130635
    Then EE, TT should be the only unclaimed territories

  @frontend_masters_registry
  @ows_masters_registry
  Scenario Outline: Bulk update UPCs
    When I am on the MastersRegistry::BulkUpdateUPCsPage
    And I attempt to update track rights for UPC: <UPC>
    Then I should see an <expected_message> for an <upc_type>

    Examples:
      | upc_type     | UPC            | expected_message                        |
      | invalid      | 20000000050423 | Invalid type of UPC                     |
      | non-existent | 111111111111   | UPC does not exist                      |
      | valid        | 191018751753   | Bulk action has begun in the background |
