@fansifter
@email-campaigns
Feature: Email Campaigns - Send & Schedule

  @FS-5091
  @id_2be68e8031816063cd836b085a71fc523ce7829614269e7e975e3c2992e17804
  Scenario: Send Test Email Campaign and Verify Content
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    Given I have email campaign data:
      | Account | Test Label (7123)       |
      | Artist  | Wolfgang Amadeus Mozart |
    And I have the current timestamp in seconds
    When I log in
    And I visit Email Campaigns page
    Then I receive email campaigns data from backend
    And I see valid Email Campaigns page with create access
    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 unique subject
    Then I see correct email campaign data on Email Overview page
    When I open Edit Design modal
    And I add text block to email design
    And I edit added text block with test content
    And I save edited email design
    When I send test email to generated address
    And I visit Email Campaigns page
    And I delete created Email Campaign
    Then I receive test email with correct subject and content

  @FS-5277
  @cleanup-created-email-campaign
  @id_e4951880f841e7fbb21ce093b364fe9b57cb163d44e0585dc1e3c688819a7739
  Scenario: [Email Campaign] Schedule/Reschedule/Unschedule email campaign
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    Given I have email campaign data:
      | Account | Test Label (7123)       |
      | Artist  | Wolfgang Amadeus Mozart |
    When I log in
    And I visit Email Campaigns page
    And I create Email Campaign with data
    Then I see correct email campaign data on Email Overview page
    # Test validation error - try to schedule without required details
    When I try to schedule or send email campaign
    Then I see schedule validation alert
    # Add required details and verify alert disappears
    When I edit Email Campaign Details with data:
      | Subject      | Test Subject                        |
      | Preview Text | Test Preview Text                   |
      | Audience     | AUTO_TEST_LABEL_EMAIL_DO_NOT_DELETE |
    Then I see correct email campaign data on Email Overview page
    And I don't see schedule validation alert
    # Schedule campaign successfully
    When I schedule email campaign for future date
    Then I see campaign status changed to "Scheduled"
    And I see campaign edit buttons show unschedule modal when scheduled
    # Reschedule the campaign
    When I reschedule email campaign to future date
    Then I see campaign status changed to "Scheduled"
    # Unschedule back to draft
    When I unschedule email campaign
    Then I see campaign status changed to "Draft"
    # Schedule campaign again
    When I schedule email campaign for future date
    Then I see campaign status changed to "Scheduled"
    # Unschedule via edit button modal
    When I unschedule email campaign via edit button modal
    Then I see campaign status changed to "Draft"

  @FS-5291
  @id_0230f5e5b40b43eb99b8f9cedbdaa9db51d241f2a037e1868d58987c3746ab11
  Scenario Outline: [Email Campaign] Send Now complete workflow - <Account>
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    Given I have email campaign data:
      | Account | <Account> |
      | Artist  | <Artist>  |
    When I log in
    And I visit Email Campaigns page
    And 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:
      | Subject      | Test Send Now Subject #automationtest |
      | Preview Text | Test Send Now Preview Text            |
      | Audience     | <Audience>                            |
    Then I see correct email campaign data on Email Overview page
    And I don't see schedule validation alert
    When I send email campaign now
    Then I see send now confirmation for "<Audience>" audience with any recipients
    When I confirm send now action
    Then I wait for campaign to be sent
    And I see campaign status changed to "Sent"

    Examples:
      | Account                | Artist                  | Audience                                                       |
      | Test Label (7123)      | Wolfgang Amadeus Mozart | Email Campaign: yuliia.dytyniak.sme@sonymusic-pde.com          |
      | Columbia Records Group | 44phantom               | Email Campaign Columbia: yuliia.dytyniak.sme@sonymusic-pde.com |
