@fansifter
@automated-emails
Feature: Automated Emails

  @FS-6972
  @id_535ae07b4b4664af96b2d286e072e9e103f223a8ab3a2271fd8952f98dfb993e
  Scenario: Automated Emails - verify page, data table and filter by status
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    And I see valid Automated Emails page with create access
    And Default Automated Emails data is correctly shown in the table
    When I select all columns for Automated Emails table
    Then All Automated Emails data is correctly shown in the table
    Then I verify Automated Emails filtered by "ON" status
    Then I verify Automated Emails filtered by "OFF" status
    Then I verify Automated Emails filtered by "All" status
    Then I verify Automated Emails filtered by "Columbia Records Group" account
    Then I verify Automated Emails filtered by "Test Label" account
    Then I verify Automated Emails filtered by "Wolfgang Amadeus Mozart" artist
    Then I verify Automated Emails filtered by "Adele" artist has no results
    Then I verify Automated Emails after reset filters

  @FS-6436
  @FS-6785
  @FS-6852
  @id_bdbf17c355c89d6caa4006fd07c590fed10a7c4f210e07d354d17e3762093f2f
  Scenario Outline: Create, duplicate and delete an Automated Email - <type>
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    When I create Automated Email with data:
      | account | Columbia Records Group |
      | artist  | Adele                  |
      | type    | <type>                 |
    Then created Automated Email default state is correct on overview
    When I edit Automated Email Details with data:
      | Subject      | Original Automated Subject      |
      | Preview Text | Original Automated Preview Text |
      | Sender Name  | Original Automated Sender Name  |
    # FS-7103: Email details aren't updated on the email overview page until page refresh
    And I refresh the page
    Then I see "Original Automated Subject" value for "Subject" field in Automated Email Overview
    And I see "Original Automated Preview Text" value for "Preview Text" field in Automated Email Overview
    And I see "Original Automated Sender Name" value for "Sender Name" field in Automated Email Overview
    And created Automated Email should appear in the list
    When I duplicate created Automated Email
    Then duplicated Automated Email overview matches the original
    And duplicated Automated Email should appear in the list
    When I delete duplicated Automated Email
    Then duplicated Automated Email should not be in the list
    When I delete created Automated Email
    Then created Automated Email should not be in the list

    Examples:
      | type          |
      | TRIGGERED     |
      | DOUBLE_OPT_IN |

  @FS-6481
  @FS-6500
  @id_427019c1ab51a0fa4205c60a97a2f4e13e2555c60e25851a89da5d771b31b15b
  Scenario Outline: Send Test Automated Email and Verify Content - <type>
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    And I have the current timestamp in seconds
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    When I create Automated Email with data:
      | account | Columbia Records Group |
      | artist  | Adele                  |
      | type    | <type>                 |
    Then created Automated Email default state is correct on overview
    When I edit Automated Email Details with unique subject
    And I open Edit Design modal for Automated Email
    And I add text block to Automated Email design
    And I edit added text block with test content for Automated Email
    And I save edited Automated Email design
    And I send test Automated Email to generated address
    And I visit Automated Emails page
    And I delete created Automated Email
    Then I receive test email with correct subject and content

    Examples:
      | type          |
      | TRIGGERED     |
      | DOUBLE_OPT_IN |

  @cleanup-created-automated-email
  @FS-6997
  @id_59d000aed9f86bfef2526b665e3a208eea3fa18d552ce0d3ee116bfa7065b23f
  Scenario: Automated Email - preview with browser link
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    When I create Automated Email with data:
      | account | Columbia Records Group |
      | artist  | Adele                  |
      | type    | TRIGGERED              |
    Then created Automated Email default state is correct on overview
    When I open Edit Design modal for Automated Email
    And I add text block to Automated Email design
    And I edit added text block with test content for Automated Email
    And I save edited Automated Email design
    When I select "View in Browser" test option on Automated Email page
    Then I see email preview with correct content

  @cleanup-created-automated-email
  @FS-6997
  @id_f236d1d1ff973efd2a4d5594a329c321a43af2213f93523143c8092047f47501
  Scenario: Automated Email - Double Opt-In preview in browser from Edit Design modal
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    When I create Automated Email with data:
      | account | Columbia Records Group |
      | artist  | Adele                  |
      | type    | DOUBLE_OPT_IN          |
    Then created Automated Email default state is correct on overview
    When I open Edit Design modal for Automated Email
    And I select "View in Browser" test option in Automated Email Edit Design modal
    Then I see Double Opt-In Automated Email preview with default content

  @cleanup-created-automated-email
  @FS-6997
  @id_63cc01b7620cba1c70ed8361ef3acdf645e21f47ab072bff12dd4de6d4baa1fc
  Scenario: Automated Email - preview with browser link (Stripo v2)
    Given an orchard employee fansifter-e2e-7123-34514 for fansifter
    And Stripo V2 is enabled
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    When I create Automated Email with data:
      | account | Columbia Records Group |
      | artist  | Adele                  |
      | type    | TRIGGERED              |
    Then created Automated Email default state is correct on overview
    When I open Edit Design modal for Automated Email
    And I add text block to Automated Email design
    And I edit added text block with test content for Automated Email
    And I save edited Automated Email design
    When I select "View in Browser" test option on Automated Email page
    Then I see email preview with correct content

  @cleanup-created-automated-email
  @FS-6997
  @id_95d4eb06358db59aeeac156e4a092a841db003dbfd46343c09567baccfd9cdd5
  Scenario: Automated Email - Double Opt-In preview in browser from Edit Design modal (Stripo v2)
    Given an orchard employee fansifter-e2e-7123-34514 for fansifter
    And Stripo V2 is enabled
    When I log in
    And I visit Automated Emails page
    Then I receive automated emails data from backend
    When I create Automated Email with data:
      | account | Columbia Records Group |
      | artist  | Adele                  |
      | type    | DOUBLE_OPT_IN          |
    Then created Automated Email default state is correct on overview
    When I open Edit Design modal for Automated Email
    And I select "View in Browser" test option in Automated Email Edit Design modal
    Then I see Double Opt-In Automated Email preview with default content

  @FS-6975
  @id_72993bba17e9e7978fd7db4a050868e3973caaccd887fabccd24b1c72b7d9446
  Scenario: [Automated Emails] Analytics page verification
    Given an orchard employee fansifter-set-2-12-ophiuchus for fansifter
    And I log in
    When I visit Automated Email Analytics page for "1156cbb8-0e8a-4e98-9c78-0086cb2c0924"
    And I receive automated email analytics data from backend
    Then all elements on automated email analytics page are present
    And I see correct data on automated email analytics page
    When I visit Automated Email Analytics page for "46f4c3f4-1bb7-457c-891b-6c50104f17ce" without analytics
    Then automated email analytics page shows the empty state
