@analytics
@cache_warm
@glacial
@frontend_analytics
@frontend_engagement
Feature: Analytics
  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
  Background: Clear browser
    Given I have a clear browser

  @legacy
  @oaworkstation
  @id_2632dbd0d8301381636d9f747e3f9146b6c462b3bf093d5ca5d308382296a81d
  Scenario: Navigate to overview page using UI and back button (MOV-796)
    Given an orchard employee label_9808 for workstation
    And I login silently to workstation and visit the analytics top charts page
    When I am on the workstation 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
  @oaworkstationw
  @id_a62d3f93231ab7934bb291daf6a499a7aea43e4b9d872ef2fe96fec8a061853d
  Scenario: Analytics data source and region lists
    Given an orchard employee label_9808 for workstation
    And I login silently to workstation and visit the analytics overview page
    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

  @id_55b08e616e361ad544112001817202ff120be2846b77a1e694e04400f49800f5
  Scenario Outline: Search & apply each type of card, validate filter applied
    Given an orchard employee label_9808 for workstation
    And I login silently to workstation and visit the analytics overview page
    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                  |

  @id_bca5291f3dbed0abea2f04b32b8054b2cc37ce7791a748586f0a76de1c051ea0
  Scenario Outline: Hover over points on the graphs to get daily totals
    Given an orchard employee label_9808 for workstation
    And I login silently to workstation and visit the analytics overview page
    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
  @ows_features
  @id_d0c23cd02e08c88634bfb5b4d2e8ddc33fda66b989bdbc58b6d938976765d8ed
  Scenario: Modify dates on Overview page
    Given an orchard employee label_9808 for workstation
    And I login silently to workstation and visit the analytics overview page
    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
  @oaworkstation
  @id_5031316de5c82aa2bd9a874fb68129aa93ba0cd98eabfe0e255921bc327865fa
  Scenario: Verify YouTube Audio and Video Streams section and total streams graph
    Given an orchard employee label_15063 for workstation
    And I login silently to workstation and visit the analytics overview page
    And I apply the selected filters
    Then I should see the YouTube Audio and Video Streams section
    And I see the data channels for YouTube Audio and Video Streams section

  @legacy
  @oaworkstation
  @id_3792c1b0fd1c5e44f165450bb77f62bd64fe6cc0273fec7e534f6524f7d4a1c6
  Scenario: Verify Audio Streams section and total streams graph
    Given an orchard employee label_15063 for workstation
    And I login silently to workstation and visit the analytics overview page
    When I set the Overview start date to 2025-03-22 and end date to 2025-04-21
    And I apply the selected filters
    Then I should see the Audio Streams section
    Then I see the data channels for Audio Streams section
