@android
Feature: Chart Digest Screen

  Background:
    Given a valid test user
    Given I login to the android app

  Scenario: Charts list is visible on the Charts screen
    Given I am on the home tab
    When I navigate to the Chart Digest screen
      Then The Charts screen should be displayed
      And The Charts screen should present the correct list of charts

  # --- Spotify ---
  Scenario: Display and attributes of songs on Spotify Daily Viral 100 chart
    When I tap on the 'Daily Viral 100' chart card
      Then I should be navigated to the 'Daily Viral 100' chart screen
      And The song list should be displayed for the 'Global' country filter by default
      And Songs should be sorted by position in ascending order
      And All expected song attributes should be displayed for each track on Top 100 charts
      And I should be able to navigate back

  Scenario: Display and attributes of songs on Spotify Weekly Top 200 chart
    When I tap on the 'Weekly Top 200' chart card
      Then I should be navigated to the 'Weekly Top 200' chart screen
      And The song list should be displayed for the 'Global' country filter by default
      And Songs should be sorted by position in ascending order
      And All expected song attributes should be displayed for each track on non-Top 100 charts
      And I should be able to navigate back

  Scenario: Display and attributes of songs on Spotify Daily Top 200 chart
    When I tap on the 'Daily Top 200' chart card
      Then I should be navigated to the 'Daily Top 200' chart screen
      And The song list should be displayed for the 'Global' country filter by default
      And Songs should be sorted by position in ascending order
      And All expected song attributes should be displayed for each track on non-Top 100 charts

    Scenario: Sorting and filtering songs on Spotify
      When I change the charts sorting option to NEW ENTRIES
        Then Songs with a blue dot should be displayed at the top
      When I change the charts sorting option to MAJOR MOVES
        Then Songs should be ordered by major moves: positive (high to low), zero, negative, then blue-dot songs
        And I should be able to navigate back to the charts page by tapping the back button
      When I tap on the 'Daily Top 200' chart card
      And I filter songs by 'My Catalog'
        Then I should see the 'No Results' message while logged in as a client user
      When I reset the filter
        Then Songs should be sorted by position in ascending order

  Scenario: Info popup on Daily Top 200 chart
    When I tap the information icon next to the Charts filter
      Then A popup with information about the 'Daily Top 200' chart should appear

  Scenario: Navigate to track page and back
    When I tap on a song card number 1
      Then The track page for the selected track should be displayed
      And I should be able to navigate back to the charts page by tapping the back button

  Scenario: Info popup on Weekly Top 200 chart
    When I select 'Weekly Top 200' chart type
    And I tap the information icon next to the Charts filter
      Then A popup with information about the 'Weekly Top 200' chart should appear
      And I should be able to navigate back

# TODO: Temporarily commented out because an error occurs when changing the country on QA env
#  Scenario: Handle empty state for unsupported market
#    When I tap on the market selector
#    And I select 'Kosovo' from the market selector
#      Then An empty state should be displayed

#  Scenario: Market selection and persistence after chart switch
#    When I tap on the market selector
#    And I select 'Argentina' from the market selector
#      Then The song list should be displayed for the 'Argentina' country filter by default
#    When I select 'Daily Viral 100' chart type
#      Then The country filter should remain set to 'Argentina' after switching charts

#  Scenario: Retain scroll position after track page navigation
#    When I scroll through the song list 2 times
#    And I tap on a song card number 1
#      Then The track page for the selected track should be displayed
#      And I should be able to navigate back to the charts page by tapping the back button
#      And The song list should retain its previous scroll position after returning from the track page

#  Scenario: Search for songs and verify sorted results
#    When I scroll to the top of the chart screen
#    And I tap on the market selector
#    And I select 'Global (Default)' from the market selector
#    And I use the chart screen's search to look for 'all'
#      Then The search results should contain 'all' in either the song name or artist name
#      And Songs should be sorted by position in ascending order
#      And I should be able to navigate back

  # --- Apple ---
  Scenario: Display and attributes of songs on Apple Daily Top 100 chart
    When I tap on the 'Daily Top 100' chart card
      Then I should be navigated to the 'Daily Top 100' chart screen
      And The song list should be displayed for the 'Global' country filter by default
      And Songs should be sorted by position in ascending order
      And All expected song attributes should be displayed for each track on Top 100 charts

  Scenario: Info popup on Daily Top 100 chart
    When I tap the information icon next to the Charts filter
      Then A popup with information about the 'Daily Top 100' chart should appear

    Scenario: Sorting and filtering songs on Apple
      When I change the charts sorting option to NEW ENTRIES
        Then Songs with a blue dot should be displayed at the top
      When I change the charts sorting option to MAJOR MOVES
        Then Songs with the highest positive trend should be displayed first in descending order
      When I filter songs by 'My Catalog'
        Then I should see the 'No Results' message
      When I reset the filter
        Then Songs should be sorted by position in ascending order

#  Scenario: Handle empty state for unsupported market
#    When I tap on the market selector
#    And I select 'Kosovo' from the market selector
#      Then An empty state should be displayed
#
#  Scenario: Market selection
#    When I tap on the market selector
#    And I select 'Australia' from the market selector
#      Then The song list should be displayed for the 'Australia' country filter by default

#  Scenario: Retain scroll position after track page navigation
#    When I scroll through the song list 2 times
#    And I tap on a song card number 1
#      Then The track page for the selected track should be displayed
#      And I should be able to navigate back to the charts page by tapping the back button
#      And The song list should retain its previous scroll position after returning from the track page
#
#  Scenario: Search for songs and verify sorted results
#    When I scroll to the top of the chart screen
#    And I use the chart screen's search to look for 'in'
#      Then The search results should contain 'in' in either the song name or artist name
#      And Songs should be sorted by position in ascending order
