@fansifter
@ows_dmp
@audience-overview-page
Feature: Audience filters tests

  Rule: Audience with city radius filter, Email audience use, email and songwhip filters

    Background: Log in (user has access to a few labels)
      Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
      And I have the audience data:
        | Account                | Test Label                                          |
        | Audience Use           | Email                                               |
        | Artist                 | Wolfgang Amadeus Mozart                             |
        | Fan city               | New York                                            |
        | Additional city radius | 150 mi                                              |
        | Email Campaign         | Has NOT Received, DON"T DELETE USED BY AUTOTESTS    |
        | Songwhip               | Has NOT Participated, Sneak Peak at new Magic Flute |
      And I log in
      When I visit Audiences page
      And I open New audience page
      And I fill new audience data

    @FS-4354
    @cleanup-created-audience
    @id_60eb3bde905338509a365f2a32d83211d02d7ce2043b5fa65eefc0d36d7f825c
    Scenario: Audience overview page design (City radius filter and Email campaign use)
      When I save new audience
      And audience overview page header contains audience name and export button
      And audience details block contains Edit button and all entered information
      And audience size block contains size, last updated info and Refresh button

  Rule: Audience with only city filter and Email campaign use

    Background: Log in (user has access to a few labels)
      Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
      And I have the audience data:
        | Account      | Test Label              |
        | Audience Use | Email                   |
        | Artist       | Wolfgang Amadeus Mozart |
        | Fan city     | New York, Toronto       |
      And I log in
      When I visit Audiences page
      And I open New audience page
      And I fill new audience data

    @FS-4355
    @cleanup-created-audience
    @id_6ed3a290f4738cc273a7a835f0181403a588f3a320f0bdaf1137ee307f848983
    Scenario: Audience overview page design (City filter and Email campaign use)
      When I save new audience
      And audience overview page header contains audience name and export button
      And audience details block contains Edit button and all entered information
      And audience size block contains size, last updated info and Refresh button

  Rule: Exclusion filter scenarios

    Background: Log in (user has access to exclusion filter feature flag)
      Given an orchard employee fansifter-e2e-7123-34514 for fansifter
      And I log in
      When I visit Audiences page
      And I open New audience page

    @FS-6489
    @cleanup-created-audience
    @id_2781429ad3f7f4004200c5be286fa3d7bc1b3748ef73e153b802f57b45ab18a8
    Scenario Outline: Audience overview page with exclusion filter
      Given I have the audience data:
        | Account        | Columbia Records Group |
        | Audience Use   | <audience-use>         |
        | <artist-field> | Adele                  |
      And I fill new audience data
      And I remember audience size as "before exclusions"
      When I add exclusion artist "AC/DC"
      Then audience size is lower then "before exclusions" for new audience
      When I remember audience size as "after artist exclusion"
      And I add exclusion list "Renegade EU"
      Then audience size is lower then "after artist exclusion" for new audience
      When I save new audience
      Then new audience is created
      And audience page shows correct audience data
      And audience page does not show elements not in audience data

      Examples:
        | audience-use | artist-field |
        | Advertising  | Artists      |
        | Email        | Artist       |

  Rule: Country exclusion filter

    Background: Log in (user has access to country exclusion feature flag)
      Given an orchard employee fansifter-e2e-7123-34514 for fansifter
      And I log in
      When I visit Audiences page
      And I open New audience page

    @FS-6611
    @cleanup-created-audience
    @id_43300e1a702405201df0853a3c6dfa811130c66540e882d63726bf8feae34b72
    Scenario: Country exclusion - create, toggle include/exclude on edit, and add a second country
      Given I am watching audience re-calculations
      And I have the audience data:
        | Account      | Columbia Records Group |
        | Audience Use | Advertising            |
        | Artists      | Adele                  |
        | Fan location | Exclude, United States |
      And I fill new audience data
      And I remember audience size as "single-country exclude"
      When I save new audience
      Then new audience is created
      And audience page shows correct audience data

      When I click edit audience button
      Then audience size is recalculated
      When I toggle Fan location exclude mode off
      Then audience size is recalculated
      And audience size is different from "single-country exclude" for new audience
      When I remember audience size as "include-only"
      And I save updated audience
      Then audience is updated
      And audience page shows correct audience data

      When I click edit audience button
      Then audience size is recalculated
      When I select "Canada" location for edit audience
      Then audience size is recalculated
      When I toggle Fan location exclude mode on
      Then audience size is recalculated
      And audience size is lower then "single-country exclude" for new audience
      When I save updated audience
      Then audience is updated
      And audience page shows correct audience data

  Rule: Form filter scenarios

    Background: Log in (user has access to Form filter test data)
      Given an orchard employee fansifter-e2e-7123-34514 for fansifter
      And I log in
      And I am watching audience re-calculations
      When I visit Audiences page
      And I open New audience page

    @FS-5874
    @cleanup-created-audience
    @id_0b32491d6b39304b18f834b207058304af4f628e84d96cca5e45a3073852dcbd
    Scenario: Form filter comprehensive workflow
      Given no Forms are available to select
      When I select "Columbia Records Group" account for new audience
      Then no Forms are available to select

      When I open artist multiselect for new audience
      And I select "Adele" artist in multiselect for new audience and close
      And audience size is recalculated
      Then Forms for "Adele" are available

      When I open Form filter dropdown
      Then there is an ability to select "Has Participated" or "Has NOT Participated" in Form filter
      And "Has Participated" operator is selected by default for Form filter

      When I select "Adele in Munich - 2024 - Form" Form and close
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has Participated" operator
      And audience size is recalculated

      When I enter random audience name
      And I save new audience
      Then new audience is created
      And audience overview page header contains audience name and export button
      And Form filter displays "Has Participated" with "Adele in Munich - 2024 - Form" on audience overview page

      When I click edit audience button
      And I select "Has NOT Participated" operator for Form filter
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has NOT Participated" operator
      And audience size is recalculated

      When I save updated audience
      Then audience is updated
      And audience overview page header contains audience name and export button
      And Form filter displays "Has NOT Participated" with "Adele in Munich - 2024 - Form" on audience overview page

      When I click edit audience button
      And I select "Adele Newsletter Signup 2024 - Website" Form and close
      Then "Adele in Munich - 2024 - Form+1" Forms are selected with "Has NOT Participated" operator

      When I save updated audience
      Then audience is updated
      And audience overview page header contains audience name and export button
      And Form filter displays "Has NOT Participated" with "Adele in Munich - 2024 - Form, Adele Newsletter Signup 2024 - Website" on audience overview page

      When I click edit audience button
      And I clear all Forms
      When I save updated audience
      Then audience is updated
      And audience overview page header contains audience name and export button
      And Form filter is NOT displayed in audience details card

    @FS-5874
    @cleanup-created-audience
    @id_2bb804525954238afca077d132f0a93ef2d241e91c6540abfbadebe2d97f35c6
    Scenario: Form filter persists across Audience Use switches
      Given I select "Columbia Records Group" account for new audience
      When I open artist multiselect for new audience
      And I select "Adele" artist in multiselect for new audience and close
      And I select "United States" location for new audience
      And I open fan segments filter dropdown
      And I select "Engaged Fans" fan segment and close

      When I select "Adele in Munich - 2024 - Form" Form and close
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has Participated" operator

      When I enter random audience name
      And I save new audience
      Then new audience is created
      And audience overview page header contains audience name and export button
      And Form filter displays "Has Participated" with "Adele in Munich - 2024 - Form" on audience overview page

      When I click edit audience button
      And I select Email campaign audience use
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has Participated" operator
      And "Email" campaign audience use is selected

      When I select Advertising campaign audience use
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has Participated" operator
      And "Advertising" campaign audience use is selected

      When I save updated audience
      Then audience is updated
      And audience overview page header contains audience name and export button
      And Form filter displays "Has Participated" with "Adele in Munich - 2024 - Form" on audience overview page

    @FS-5874
    @cleanup-created-audience
    @id_32bd7c5eb2427db744b0240710553950982562d22cb7fd0cdebac48091749148
    Scenario: Form filter behavior when managing multiple artists
      Given I select "Columbia Records Group" account for new audience
      When I open artist multiselect for new audience
      And I select "Adele" artist in multiselect for new audience and close
      And I select "Adele in Munich - 2024 - Form" Form and close
      And I select "Has NOT Participated" operator for Form filter
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has NOT Participated" operator
      And artist "Adele" is selected in multiselect for new audience

      When I open artist multiselect for new audience
      And I select "AC/DC" artist in multiselect for new audience and close
      Then artist "Adele,AC/DC" is selected in multiselect for new audience
      And "Adele in Munich - 2024 - Form" Form is selected with "Has NOT Participated" operator

      When I remove "Adele" artist from multiselect for new audience
      Then artist "AC/DC" is selected in multiselect for new audience
      And Form filter has no selections
      And "Has NOT Participated" operator is selected by default for Form filter

      When I open artist multiselect for new audience
      And I select "Adele" artist in multiselect for new audience and close
      Then artist "AC/DC,Adele" is selected in multiselect for new audience
      And Form filter has no selections
      And "Has NOT Participated" operator is selected by default for Form filter

      When I select "Adele in Munich - 2024 - Form" Form and close
      Then "Adele in Munich - 2024 - Form" Form is selected with "Has NOT Participated" operator
      And I select "AC/DC - The Quiz!" Form and close
      Then "Adele in Munich - 2024 - Form+1" Forms are selected with "Has NOT Participated" operator

      When I enter random audience name
      And I save new audience
      Then new audience is created
      And audience overview page header contains audience name and export button
      And Form filter displays "Has NOT Participated" with "Adele in Munich - 2024 - Form, AC/DC - The Quiz!" on audience overview page

  Rule: Audience with birth month, genre, and preferred language filters

    Background: Log in (user has access to additional fan targeting feature flag)
      Given an orchard employee fansifter-e2e-7123-34514 for fansifter
      And I log in
      And I am watching audience re-calculations
      When I visit Audiences page
      And I open New audience page

    @FS-7359
    @cleanup-created-audience
    @id_844d5df517b170e48a05b6086ada001a70201192963321420082acfdf0a5fe26
    Scenario: Audience with birth month, genre, and preferred language filters
      Given I have the audience data:
        | Account            | Columbia Records Group     |
        | Audience Use       | Advertising                |
        | Artists            | Adele                      |
        | Birth month        | Include, January, February |
        | Genre              | Include, Pop, Rock         |
        | Preferred language | Exclude, English           |
      When I fill new audience data
      And I save new audience
      Then new audience is created
      And audience overview page header contains audience name and export button
      And audience page shows correct audience data
      And audience page does not show elements not in audience data

      When I click edit audience button
      And I toggle Birth month exclude mode on
      And I toggle Genre exclude mode on
      And I toggle Preferred language exclude mode off
      Then audience size is recalculated
      When I save updated audience
      Then audience is updated
      And audience page shows correct audience data
