@frontend_royalties
Feature: Abacus Payment Search

  @id_d9c4f7a2e1b38506927c3d5f8e04b1a79e6d28c051f7b3a4e9c6d1f280b5e437
  Scenario: A360 read-only user — direct URL navigation to Payment Search is blocked
    Given an orchard employee abacus+readonly_e2e_1@sonymusic-pde.com for abacus
    When I log in
    And I navigate directly to the Abacus Payment Search URL
    Then the Abacus Payment Search tab should not be visible
    And the Abacus Payment Search content should not be accessible

  @id_8f9e379766409fa8c5ce0677e1df02290d8fbee6673afe907fb501fd9a9d6a24
  Scenario: Search returns all Payment Status
    Given an orchard employee label_7123_admin_3 for abacus
    When I log in
    And I open the Abacus Payment Search page
    When I select all Payment Status options and apply
    When I remove "Not Paid" from the Payment Status filter and apply
    Then payment search table should not contain "Not Paid" in the Payment Status column
    When I remove "Accepted" from the Payment Status filter and apply
    Then payment search table should not contain "Accepted" in the Payment Status column
    When I remove "Successful" from the Payment Status filter and apply
    Then payment search table should not contain "Successful" in the Payment Status column
    When I remove "Cancelled" from the Payment Status filter and apply
    Then payment search table should not contain "Cancelled" in the Payment Status column
    Then payment search table should contain "Failure" in the Payment Status column
    When I remove "Failed" from the Payment Status filter and apply
    Then payment search table should not contain "Failure" in the Payment Status column
    When I clear all Payment Status options and apply
    Then the payment search table should show the empty state

  @id_4d5b12bb215b477b7e7834b5914ee534495aed711b0856207c6c66fbeca88ece
  Scenario: Search returns all Payment Types
    Given an orchard employee label_7123_admin_3 for abacus
    When I log in
    And I open the Abacus Payment Search page
    Then Search filters should contain Payment Type values "Balance Payment", "Advance Payment", "Custom Payment"
    When I select all Payment Type options and apply
    Then payment search table should contain "Balance Payment" in the Payment Type column
    Then payment search table headers should appear in the order: "Payment Type, Account, Payment Status, Error Message, Contract, Pre-Tax Amount, Post-Tax Amount, Payment Created Date, Payment Sent Date, Payment Created Statement Period, Payment Sent Statement Period, Payment File Name"
    And payment search table should show "Payment File Name" as a link
    When I remove "Balance Payment" from the Payment Type filter and apply
    Then payment search table should contain "Advance Payment" in the Payment Type column
    When I remove "Advance Payment" from the Payment Type filter and apply
    Then payment search table should contain "Custom Payment" in the Payment Type column
    When I clear all Payment Type options and apply
    Then the payment search table should show the empty state

  @id_b74f4a21eb2a3fce04a7c708baf08266cb66f55834fc8cc327e9b6a833765160
  Scenario: Check All filters works in proper way and could be cleaned one by one with cross
    Given an orchard employee label_7123_admin_3 for abacus
    When I log in
    And I open the Abacus Payment Search page
    And I select "Successful" in the Payment Status filter
    And I save the Account ID and Contract ID from the first payment search row
    When I clear the "Payment Status" Payment Search filter with cross
    Then the payment search table should show the empty state
    When I filter Payment Search by the saved Account ID
    Then all payment search rows should reference the saved Account ID
    When I clear the "Account" Payment Search filter with cross
    Then the payment search table should show the empty state
    And I filter Payment Search by the saved Contract ID
    Then all payment search rows should reference the saved Contract ID
    When I clear the "Contract" Payment Search filter with cross
    Then the payment search table should show the empty state
    And I select "Balance Payment" in the Payment Type filter
    Then all payment search rows should be of Payment Type "Balance Payment"
    When I clear the "Payment Type" Payment Search filter with cross
    Then the payment search table should show the empty state
    And I select "Advance Payment" in the Payment Type filter
    Then all payment search rows should be of Payment Type "Advance Payment"
    When I clear the "Payment Type" Payment Search filter with cross
    Then the payment search table should show the empty state
    And I apply the Payment Created Date range from "2026-05-20" to "2026-05-21"
    Then all payment search rows should be of Payment Created Date between "2026-05-20" and "2026-05-21"
    When I clear the "Payment Created Date" Payment Search filter with cross
    Then the payment search table should show the empty state
    And I apply the Payment Sent Date range from "2026-05-20" to "2026-05-21"
    Then all payment search rows should be of Payment Sent Date between "2026-05-20" and "2026-05-21"
    When I clear the "Payment Sent Date" Payment Search filter with cross
    Then the payment search table should show the empty state

  @id_205673248d6198fe61091046e382f8434f5bdaf5708a7976a2a9c16a41839ae0
  Scenario: Check Export button works and download the file with proper name and content
    Given an orchard employee label_7123_admin_3 for abacus
    When I log in
    And I open the Abacus Payment Search page
    And I select "Successful" in the Payment Status filter
    Then I click the Export button
    Then the downloaded file name should be Payment-Search
    And the exported CSV should contain correct headers and Payment Status "successful"

  @id_908b0f6cbb1e8ef578338b6816216e5205a50431e2091e53244af2a57368184d
  Scenario: Check pagination works properly
    Given an orchard employee label_7123_admin_3 for abacus
    When I log in
    And I open the Abacus Payment Search page
    And I select "Successful" in the Payment Status filter
    Then the payment search pagination should show "1 - 20"
    And the payment search table should have 20 rows
    When I click the payment search next page button
    Then the payment search pagination should show "21 - 40"
    And the payment search table should have 20 rows
    When I click the payment search previous page button
    Then the payment search pagination should show "1 - 20"
    When I open the payment search pagination popover
    Then the payment search pagination popover should be visible
    And the payment search rows per page "20" should be active
    When I select payment search rows per page "50"
    Then the payment search table should have 50 rows
    And the payment search pagination should show "1 - 50"
    When I open the payment search pagination popover
    And I select payment search rows per page "10"
    Then the payment search table should have 10 rows
    And the payment search pagination should show "1 - 10"
    When I open the payment search pagination popover
    And I click the payment search "Last page" button
    When I open the payment search pagination popover
    Then the payment search "Last page" button should be disabled
    And the payment search "First page" button should be enabled
    When I click the payment search "First page" button
    Then the payment search pagination should show "1 - 10"

  @wip
  @id_7dec25d269f9089ab394abd590f0d5762ac049f19587fbb0911f4708c94338fe
  Scenario: Check column sorting works properly
    Given an orchard employee label_7123_admin_3 for abacus
    When I log in
    And I open the Abacus Payment Search page
    And I select all Payment Status options and apply
    When I sort the payment search table by "Payment Type" in "asc" order
    Then the payment search table should be sorted by "Payment Type" in "asc" order alphabetically
    When I sort the payment search table by "Payment Type" in "desc" order
    Then the payment search table should be sorted by "Payment Type" in "desc" order alphabetically
    When I sort the payment search table by "Error Message" in "asc" order
    Then the payment search table should be sorted by "Error Message" in "asc" order alphabetically
    When I sort the payment search table by "Error Message" in "desc" order
    Then the payment search table should be sorted by "Error Message" in "desc" order alphabetically
    When I sort the payment search table by "Payment Created Date" in "asc" order
    Then the payment search table should be sorted by "Payment Created Date" in "asc" order alphabetically
    When I sort the payment search table by "Payment Created Date" in "desc" order
    Then the payment search table should be sorted by "Payment Created Date" in "desc" order alphabetically
