Feature: Songwhip Production Cache

  @production
  @no-silent-login
  @songwhip_production_cache
  @id_0dd1d1e46c358e42860dfdc92875f08e5a1477ba9bd86f404ab877c95915cfa5
  Scenario: Create and publish presave with Spotify album link
    Given an environment dependent user songwhip-prod for prod or songwhip-staging for qa for songwhip
    When I log in
    And I open the songwhip create home page
    And I start creating a songwhip presave
    And I select songwhip artist "Fadi"
    Then I should see the songwhip presave creation form
    When I fill songwhip presave details with spotify id "3FyvmtCMk1ajpycvzlxuG9" and a unique name
    And I skip songwhip artwork upload
    Then I should see the songwhip draft page
    When I publish the songwhip presave draft
    Then the songwhip presave should be published successfully
    When I add a songwhip custom link with domain "fadi-2.sng.to"
    And I add a songwhip custom link with domain "fadi-2.orch.stream"
    And I cache the songwhip presave custom links in a second browser
    # Bug: AD-2861[Pre-save] Amazon and iTunes links are missed after Artist name was edited
    # When I edit the songwhip presave with a new artist name
    # Then the songwhip custom links should reflect the updated artist name
    When I open the songwhip presave upgrade page
    Then I should see the songwhip presave upgrade page
    When I upgrade the songwhip presave to a release
    Then the songwhip release page should have correct service links for album "3FyvmtCMk1ajpycvzlxuG9"
    And the songwhip custom links should show upgraded service links for album "3FyvmtCMk1ajpycvzlxuG9"

  @production
  @no-silent-login
  @songwhip_production_cache
  @id_3ea5c756ae98b48e4cf981bcee865504b268a8bc7ad53e328fffcbbca66b4917
  Scenario: Artist page edit invalidates cache on presave, release, artist, song, and custom link pages
    Given an environment dependent user songwhip-prod for prod or songwhip-staging for qa for songwhip
    When I log in
    # Create presave 1 — will be upgraded to release, with a custom link
    And I open the songwhip create home page
    And I start creating a songwhip presave
    And I select songwhip artist "Tagore"
    Then I should see the songwhip presave creation form
    When I fill songwhip presave details with spotify id "6DEjYFkNZh67HP7R9PSZvv" and a unique name
    And I skip songwhip artwork upload
    Then I should see the songwhip draft page
    When I publish the songwhip presave draft
    Then the songwhip presave should be published successfully
    When I add a songwhip custom link for the release page with domain "tagore.sng.to"
    And I open the songwhip presave upgrade page
    Then I should see the songwhip presave upgrade page
    When I upgrade the songwhip presave to a release
    And I store the songwhip presave path as the release path
    # Create presave 2 — stays as presave, with a custom link
    And I open the songwhip create home page
    And I start creating a songwhip presave
    And I select songwhip artist "Tagore"
    Then I should see the songwhip presave creation form
    When I fill songwhip presave details with spotify id "6DEjYFkNZh67HP7R9PSZvv" and a unique name
    And I skip songwhip artwork upload
    Then I should see the songwhip draft page
    When I publish the songwhip presave draft
    Then the songwhip presave should be published successfully
    When I add a songwhip custom link for the presave page with domain "tagore.orch.stream"
    # Ensure the artist page's own share links exist (general + custom links, reused across runs)
    When I ensure the songwhip artist "tagore" has the following custom links
      | domain             | path                 |
      | tagore.orch.stream | tagore-custom-link   |
      | tagore.sng.to      | tagore-custom-link-2 |
    # Reference the artist's existing song page — a stable prod fixture created once via the
    # create-track UI ("Colombina", Spotify track 6a5QwvY4t88m0i5FCDQBwF), reused across runs.
    When I use the existing songwhip song page "tagore/colombina"
    # Ensure the song page has its own custom links (one per branded domain, reused across
    # runs); they are downstream of the artist and must be invalidated by the artist edit too.
    When I ensure the songwhip song page "tagore/colombina" has the following custom links
      | domain             | path                    |
      | tagore.sng.to      | colombina-custom-link   |
      | tagore.orch.stream | colombina-custom-link-2 |
    When I cache the songwhip artist "tagore", presave, release, song, and custom link pages in a second browser
    Then the songwhip custom links should return the correct presave and release pages
    When I edit the songwhip artist page "tagore" with unique text content
    Then the artist, presave, release, song, and custom link page caches should be invalidated
    And the artist, presave, release, song, and custom link page caches should rebuild after invalidation
