@analytics
@cache_warm
@glacial
@frontend_analytics
@frontend_engagement
Feature: Analytics
  In order to view Analytics data
  As a user
  I want the Overview page to work
  * Default dates for Overview page should be TO (today's date - 2 days) FROM 1 month prior to that
  # TODO: move this to SPA SA once AnalyticsTopChartsPage and AnalyticsOverviewPage are under SPA

  @legacy
  # Previously wip'd without a written cause. Add wip tag again with an explanation if it flickers.
  Scenario: Navigate to overview page using UI and back button (MOV-796)
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsTopChartsPage
    When I view the Analytics Overview page
    Then I should be on the Analytics Overview page
    When I use my browser's back button
    And I view the Analytics Overview page
    Then I should be on the Analytics Overview page

  @legacy
  Scenario: Analytics data source and region lists
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I view the sources filter
    Then I should see at least 2 unique sources in the list
    When I view the regions filter
    Then I should see at least 2 unique regions in the list

  Scenario Outline: Search & apply each type of card, validate filter applied
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I filter for <something>: <name>
    Then I should see my chosen filter applied

  Examples:
    | something | name                                                      |
    | track     | "'Mbilta Solo (Eritrea)"                                  |
    | imprint   | PAREDON RECORDS                                           |
    | artist    | Abraham Brun                                              |
    | genre     | Folk                                                      |

  # really old test that probably can be removed
  @wip
  Scenario Outline: Validate historical monthly channel data
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I set the Overview start date to <start_date> and end date to <end_date>
    And I apply the selected filters
    Then I should see a Download Albums total of <download_album>
    Then I should see a Download Tracks total of <download_tracks>
    Then I should see a Tethered Downloads total of <tethered_downloads>
    Then I should see a Ad-Supported Audio Stream total of <ad_supported_stream>
    Then I should see a Subscription Audio Streams total of <streams>

  Examples:
  | start_date | end_date   | download_album | download_tracks | tethered_downloads | ad_supported_stream | streams |
  | 2014-03-09 | 2014-04-09 | 821            | 2225            | 31427              | 711380              | 1099120 |
  | 2014-04-01 | 2014-05-01 | 790            | 2073            | 29460              | 665327              | 986072  |

  Scenario Outline: Hover over points on the graphs to get daily totals
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I set the Overview start date to <start_date> and end date to <end_date>
    And I apply the selected filters
    And I get the data for <date> from point <point> on the <channel> chart
    Then the number of sales for the data point is <sales>

    Examples:
      |start_date|end_date  |point|date           |channel                   |sales|
      |2014-07-01|2014-08-01|14   |JULY 15, 2014  |Tethered Downloads        |670  |
      |2014-10-01|2014-12-01|3    |OCTOBER 4, 2014|Ad-Supported Audio Streams|22091|
      |2014-12-10|2015-03-02|30   |JANUARY 9, 2015|Download Tracks           |45   |

  @regression
  Scenario: Modify dates on Overview page
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I set the Overview start date to 2013-07-01 and end date to 2014-08-01
    And I apply the selected filters
    Then the to and from dates in the URL should be correct
    And the to and from dates in the UI should be correct

  @wip
  Scenario: Data channel order
    Given a Workstation label_9808 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I change the data channel order
    Then the channel order should remain same when I revisit
    And I log out of Workstation
    Given a Workstation label_9808 user
    When I am on the Workstation::AnalyticsOverviewPage
    Then the channel order should remain same when I revisit

  @legacy
  Scenario: Verify YouTube Audio and Video Streams section and total streams graph
    Given a Workstation label_15063 user
    And I am on the Workstation::AnalyticsOverviewPage
    And I apply the selected filters
    Then I should see the YouTube Audio and Video Streams section
    Then I see the data channels for YouTube Audio and Video Streams section

  @legacy
  Scenario: Verify Audio Streams section and total streams graph
    Given a Workstation label_15063 user
    And I am on the Workstation::AnalyticsOverviewPage
    When I set the Overview start date to 2018-10-15 and end date to 2018-11-14
    And I apply the selected filters
    Then I should see the Audio Streams section
    Then I see the data channels for Audio Streams section
