#  AUT-930 Workstation accounting deprecation
@statement_attachments
@wip
Feature: Accounting Statement Attachments D3

  # ACC-756, ACC-757, ACC-885
  @frontend_accounting
  @ows_accounting
  @id_0ce367aad5ba81a63e62855748826c95a00e67f8b91dd93de55f9ce833a4f5a9
  Scenario: D3 user can see Statement Attachments for selected period
    Given an orchard employee d3_16055 for workstation
    And I log in to workstation silently
    And I am on the accounting-d3 statements page
    Then the page should include Statement Attachments column
    When I click 'View' button of a period without Statement Attachments
    Then Statement Attachments page should be displayed with all appropriate fields

  # ACC-768, ACC-772, ACC-758
  @frontend_accounting
  @ows_accounting
  @id_6e6275437e6f07cbdb0b02ccf28cd98a708f1e8fa3c2500fe66c7e6d88aed0c9
  Scenario: User should be able to download Statement Attachments
    Given an orchard employee d3_16055 for workstation
    And I log in to workstation silently
    And I am on the accounting-d3 statements page
    When I click 'View' button for the last period
    And I upload a XLS file to S3 bucket for the selected period
    Then a new record should be created in statement_attachments_success table for XLS file
    When I refresh the page
    When I click 'View' button for the last period
    And I click 'Get download link' for the last file
    Then the link text should be changed to 'Download'
    When I download the Statement Attachment file
    Then the downloaded file should exactly the same as the just uploaded one

  #   ACC-764, ACC-765, ACC-749, ACC-766, ACC-908, ACC-747, ACC-737, ACC-763
  @frontend_accounting
  @ows_accounting
  @id_fc495d6871d26d17d7f5520ca310224240d2f04563005b3f137b36e849167601
  Scenario Outline: User should be able to see uploaded files on Statement Attachments page
    Given an orchard employee d3_16055 for workstation
    And I log in to workstation silently
    And I am on the accounting-d3 statements page
    When I click 'View' button for the last period
    And I upload a <file_type> file to S3 bucket for the selected period
    Then a new record should be created in statement_attachments_success table for <file_type> file
    And I refresh the page
    When I click 'View' button for the last period
    Then the file should be displayed on the page
    And I should see the upload date "YYYY-MM-DD"
    And I should see the file name auto_test_<file_type>
    And I should see the file type "<file_type>"
    And I should see the status "Get download link"

    Examples:
      | file_type |
      | PDF       |
      | PNG       |
      | JPG       |
      | XLS       |
      | XLSX      |
      | DOC       |
      | DOCX      |

  # ACC-775
  @frontend_accounting
  @ows_accounting
  @id_6f6d47581fc1937990876fe805d394e00f3cecd7bc6b4f97113450426e309021
  Scenario: Statement attachment file should not be displayed on the page if it was removed from S3
    Given an orchard employee d3_16055 for workstation
    And I log in to workstation silently
    And I am on the accounting-d3 statements page
    When I click 'View' button for the last period
    And I upload a PDF file to S3 bucket for the selected period
    Then a new record should be created in statement_attachments_success table for PDF file
    When I remove the uploaded PDF file from the qa bucket
    Then the file should not be displayed on the page
