@fansifter_permissions
Feature: Permissions for users with single label access Part 1

  Rule: User with no access to any features (set-0-1-no-access)
    User should not have access to any features

    @wip
    @id_4e296b70369c1a2d9a530ad4ddbb35fe5ade619a37ac3820d02fdca7198bbb03
    Scenario: User with no access to any features
      Given an orchard employee fansifter-set-0-1-no-access visits fansifter
      When I log in
      Then I see "Search, My Roster" navigation tab in Fansifter navbar
      And I don't see "Audiences, Ad Reporting, Emails, Email Campaigns, SMS Campaigns, App Connections" navigation tabs in Fansifter navbar
      When I receive My Roster data from backend
      Then I see error loading data on My Roster page
      When I open Fansifter Search page
      And I search for an artist "Wolfgang Amadeus Mozart"
      And I select #1 search result containing "Wolfgang Amadeus Mozart" without access
      Then page header with all elements is shown without fans
      And total fans count is "—"
      And all fan data and charts are hidden
      And I see error message that something went wrong on artist page

  Rule: User with only Shopify app access (set-1-3-basic-shopify)
    User should have access to the following pages:
    - Search
    - Artist
    - My Roster
    - App Connections
    V2 Roles (Test Label):
    - fansifter_can_view_fan_data

    @id_294f493876fb46f97974ca2bbe3e71ca8d6bb25f95854283148b7f7cc1035a98
    Scenario: User have access only to Shopify app
      Given an orchard employee fansifter-set-1-3-basic-shopify visits fansifter
      And I log in
      Then I see "Search, My Roster, App Connections" navigation tab in Fansifter navbar
      And I don't see "Audiences, Ad Reporting, Emails, Email Campaigns, SMS Campaigns" navigation tabs in Fansifter navbar
      And I see "fansifter" icon in app switcher popover
      When I open App Connections page
      Then App Connections page header is shown
      And Shopify stores section with table is shown
      And I see only "Test Label" accounts in "Shopify" app connections table
      And Meta Ad Accounts section with table is hidden
      And Google Ad Accounts section with table is hidden
      And TikTok Ad Accounts section with table is hidden
      When I open Connect a Shopify store modal
      Then Connect a Shopify store modal is shown

  Rule: User with audiences access (set-1-5-ad-audiences)
    User should have access to the following pages:
    - Search
    - Artist
    - My Roster
    - Audiences
    V2 Roles (Test Label):
    - fansifter_can_view_fan_data
    - fansifter_can_share_ad_campaign_audiences

    Background: Login as fansifter-set-1-5-ad-audiences
      Given an orchard employee fansifter-set-1-5-ad-audiences visits fansifter
      When I log in
      Then I see "Search, My Roster, Audiences" navigation tab in Fansifter navbar
      And I don't see "Ad Reporting, Emails, Email Campaigns, SMS Campaigns, App Connections" navigation tabs in Fansifter navbar

    @id_17a1ab21e9e41fb8054ae610cd1e05ef166c1c3c25f4de02596b5809834bbb8a
    Scenario: User with audiences access can create/update/delete audiences
      Given I have the audience data:
        | Account         | Test Label                             |
        | Audience Use    | Advertising                            |
        | Artists         | Wolfgang Amadeus Mozart, Frank Sinatra |
        | Fan location    | Include, United States                 |
        | Fan segment     | Include, Engaged Fans                  |
        | Last engagement | Include, Past Year                     |
        | Fan DSP         | Exclude, Apple Music                   |
        | Heavy rotation  | Exclude, NOT in Heavy Rotation         |
      When I open Audiences page
      And I open New audience page
      Then "Advertising" campaign audience use should be available
      And "Email" campaign audience use should not be available
      And account "Test Label (7123)" is selected for new audience and disabled
      When I fill new audience data
      And I save new audience
      Then new audience is created
      When I click edit audience button
      Then "Advertising" campaign audience use should be available and disabled
      And "Email" campaign audience use should not be available
      And account "Test Label (7123)" is selected for new audience and disabled
      And I select "Australia" location for new audience
      And I save updated audience
      Then audience is updated
      When I open the Share audience sidebar
      And I set Ad account to Demo Ad Account
      And I share the audience to Meta
      Then audience is successfully shared to Meta
      When I visit Audiences page
      Then created audience exists in the table
      When I archive the created audience
      Then archived audience is not shown in the table
      When I visit archived audience by URL
      Then I see Not found error on a page

  Rule: User with app connections without Shopify access (set-1-7-app-conn)
    User should have access to the following pages:
    - Search
    - Artist
    - My Roster
    - App Connections
    V2 Roles (Test Label):
    - fansifter_can_view_fan_data
    - fansifter_can_connect_ad_accounts

    @id_bf9142b7e795a5c1594f2d3d899c364972cc6333b5e4554b7f3c2fe7b6169ca7
    Scenario: User have access only to App connection without Shopify app
      Given an orchard employee fansifter-set-1-7-app-conn visits fansifter
      And I log in
      Then I see "Search, My Roster, App Connections" navigation tab in Fansifter navbar
      And I don't see "Audiences, Ad Reporting, Emails, Email Campaigns, SMS Campaigns" navigation tabs in Fansifter navbar
      When I open App Connections page
      Then App Connections page header is shown
      And Meta Ad Accounts section with table is shown
      And I see only "Test Label" accounts in "Meta" app connections table
      And Google Ad Accounts section with table is shown
      And I see only "Test Label" accounts in "Google" app connections table
      And TikTok Ad Accounts section with table is shown
      And I see only "Test Label" accounts in "TikTok" app connections table
      And Shopify stores section with table is hidden

  Rule: User with email campaigns create access (set-1-9-email-create)
    User should have access to the following pages:
    - Search
    - Artist
    - My Roster
    - Email Campaigns
    V2 Roles (Test Label):
    - fansifter_can_view_fan_data
    - fansifter_can_create_email_campaigns

    Background: Login as fansifter-set-1-9-email-create
      Given an orchard employee fansifter-set-1-9-email-create visits fansifter
      Given I have Email Campaigns permissions:
        | Test Label | create |
      And I log in
      Then I see "Search, My Roster, Audiences, Emails" navigation tab in Fansifter navbar
      And I don't see "Ad Reporting, SMS Campaigns, App Connections" navigation tabs in Fansifter navbar

    @id_247e91e15569034206f06ce38f5df776fe7df5d6c69e06a1a12b9d48916ebbb9
    Scenario: User with email create access should be able to edit/duplicate/delete email campaigns
      When I visit Email Campaigns page
      Then I receive email campaigns data from backend
      And I see correct data table on Email Campaigns page
      And I see valid Email Campaigns page with create access
      When I show "Account" column for Email Campaigns table
      Then I see only "Test Label" account in Email Campaigns table
      And I check correct permissions for Sent Email Campaigns
      And I check correct permissions for Draft Email Campaigns
      And I check correct permissions for Scheduled Email Campaigns

    @cleanup-created-email-campaign
    @cleanup-duplicated-email-campaign
    @id_11923d580b28a015f4b29a83a4236a9f1981f7134b51f862611007e7abe49d20
    Scenario: User with email create access should be able delete and duplicate email campaigns
      When I visit Email Campaigns page
      Then I receive email campaigns data from backend
      Then I see valid Email Campaigns page with create access
      Given I have email campaign data:
        | Account | Test Label (7123), Disabled |
        | Artist  | Wolfgang Amadeus Mozart     |
      When I create Email Campaign with data
      Then I see correct email campaign data on Email Overview page
      When I edit Email Campaign Details with data:
        | Account      | Test Label (7123), Disabled         |
        | Subject      | Edited Subject                      |
        | Preview Text | Edited Preview Text                 |
        | Sender Name  | Edited Sender Name                  |
        | Audience     | AUTO_TEST_LABEL_EMAIL_DO_NOT_DELETE |
      Then I see correct email campaign data on Email Overview page
      When I duplicate opened Email Campaign
      Then I see duplicated Email Campaign overview page
      Then I see correct email campaign data on Email Overview page

    @cleanup-created-email-campaign
    @cleanup-duplicated-email-campaign
    @id_d1cbc8443060f4e4c940892f69ee5a5753ec13e95b007ceaeae2ec6c9435ed8f
    Scenario: User with email create access should have access to email audiences and email campaign creation
      When I open Audiences page
      And I open New audience page
      Then "Email" campaign audience use should be available
      And "Advertising" campaign audience use should not be available
      When I select Email campaign audience use
      And account "Test Label (7123)" is selected for new audience and disabled
      And I have the audience data:
        | Account         | Test Label                     |
        | Audience Use    | Email                          |
        | Artist          | Wolfgang Amadeus Mozart        |
        | Fan location    | Include, United States         |
        | Fan segment     | Include, Engaged Fans          |
        | Last engagement | Include, Past Year             |
        | Fan DSP         | Exclude, Apple Music           |
        | Heavy rotation  | Exclude, NOT in Heavy Rotation |
      When I fill new audience data
      And I save new audience
      Then new audience is created
      When I click edit audience button
      And I select "Australia" location for new audience
      And I save updated audience
      Then audience is updated
      When I visit Audiences page
      Then created audience exists in the table
      When I archive the created audience
      Then archived audience is not shown in the table
      When I visit archived audience by URL
      Then I see Not found error on a page
      When I visit Email Campaigns page
      Then I see valid Email Campaigns page with create access
      Given I have email campaign data:
        | Account | Test Label (7123), Disabled |
        | Artist  | Wolfgang Amadeus Mozart     |
      When I create Email Campaign with data
      Then I see correct email campaign data on Email Overview page
      When I duplicate opened Email Campaign
      Then I see duplicated Email Campaign overview page
      And I see correct email campaign data on Email Overview page

  Rule: User with sms create access (set-1-11-sms-create)
    User should have access to the following pages:
    - Search
    - Artist
    - My Roster
    - SMS Campaigns
    V2 Roles (Test Label):
    - fansifter_can_view_fan_data
    - fansifter_can_create_sms_campaigns

    Background: Login as fansifter-set-1-11-sms-create
      Given an orchard employee fansifter-set-1-11-sms-create visits fansifter
      And I log in
      Then I see "Search, My Roster, Audiences" navigation tab in Fansifter navbar
      And I don't see "Ad Reporting, Emails, Email Campaigns, App Connections" navigation tabs in Fansifter navbar

    # SMS Campaigns still in development
    @id_ca4da90279b3ccbb57e144aa97846b847349bc12fcceb2d5ccec80dc5557bbe9
    Scenario: User with sms create access should have access to sms audiences
      When I visit Email Campaigns page without access
      Then I see Not found error on a page
      When I visit Ad Reporting page without access
      Then I see Not found error on a page
      When I visit App Connections page without access
      Then I see Not found error on a page

  Rule: User with email create, sms view, audiences, ad reporting access (set-1-13-ad-rep-ad-aud-email-create-sms-view)
    User should have access to the following pages:
    - Search
    - Artist
    - My Roster
    - Audiences
    - Ad Reporting
    - Email Campaigns
    V2 Roles (Test Label):
    - fansifter_can_view_fan_data
    - fansifter_can_create_ad_reports
    - fansifter_can_share_ad_campaign_audiences
    - fansifter_can_create_email_campaigns
    - fansifter_can_view_sms_campaigns
    - fansifter_can_connect_ad_accounts

    @cleanup-created-email-campaign
    @id_a1d18d0770451e64a18b3aee559ba62b14ce1332a79adb5e77666a1b029a7ff7
    Scenario: User with email create access should have access to email audiences
      Given an orchard employee fansifter-set-1-13-ad-rep-ad-aud-email-create-sms-view visits fansifter
      And I log in
      Then I see "Search, My Roster, Audiences, Emails, Ad Reporting, App Connections" navigation tab in Fansifter navbar
      When I open Audiences page
      And I open New audience page
      Then "Email" campaign audience use should be available
      And "Advertising" campaign audience use should be available
      When I select Email campaign audience use
      And account "Test Label (7123)" is selected for new audience and disabled
      When I visit Email Campaigns page
      Then I see valid Email Campaigns page with create access
      Given I have email campaign data:
        | Account | Test Label (7123), Disabled |
        | Artist  | Wolfgang Amadeus Mozart     |
      When I create Email Campaign with data
      Then I see correct email campaign data on Email Overview page
