<commit_before>Feature: ndr / report submit

    @ndr
    Scenario: NDR review page
        Given I am logged in as "<EMAIL>" with password "<PASSWORD>"
        # go to review page
        When I click on "ndr-start, ndr-submit"
        Then the URL should match "/ndr/\d+/review"
        # quick check sections are presented. An unit test asserts
        And I should see an "#visits-care-section" element
        And I should see an "#assets-section" element
        And I should see an "#debts-section" element
        And I should see an "#income-benefits-section" element
        And I should see an "#expenses-section" element
        And I should see an "#action-section" element
        And I should see an "#accounts-section" element
        And I save the application status into "ndr-before-submission"
        # assert pages not accessible

    @ndr
    Scenario: NDR declaration and submission
        Given emails are sent from "deputy" area
        And I reset the email log
        And I am logged in as "<EMAIL>" with password "<PASSWORD>"
        And I click on "ndr-start, ndr-submit, ndr-declaration-page"
        Then the URL should match "/ndr/\d+/declaration"
        #
        # empty form
        #
        When I press "ndr_declaration_save"
        Then the following fields should have an error:
            | ndr_declaration_agree |
            | ndr_declaration_agreedBehalfDeputy_0 |
            | ndr_declaration_agreedBehalfDeputy_1 |
            | ndr_declaration_agreedBehalfDeputy_2 |
            | ndr_declaration_agreedBehalfDeputyExplanation |
        # missing explanation
        When I fill in the following:
            | ndr_declaration_agree | 1 |
            | ndr_declaration_agreedBehalfDeputy_2 | more_deputies_not_behalf |
            | ndr_declaration_agreedBehalfDeputyExplanation |  |
        And I press "ndr_declaration_save"
        Then the following fields should have an error:
            | ndr_declaration_agreedBehalfDeputyExplanation |
        # change to one deputy and submit
        When I fill in the following:
            | ndr_declaration_agree | 1 |
            | ndr_declaration_agreedBehalfDeputy_0 | only_deputy |
            | ndr_declaration_agreedBehalfDeputyExplanation |  |
        And I press "ndr_declaration_save"
        Then the form should be valid
        And the URL should match "/ndr/\d+/submitted"
        And the response status code should be 200
        # return to homepage
        When I click on "return-homepage"
        Then I should be on "/ndr"

    @ndr
    Scenario: admin area check submission ZIP file
        Given I am logged in to admin as "<EMAIL>" with password "<PASSWORD>"
        And I click on "admin-documents"
        Then I should be on "/admin/documents/list"
        And I save the current URL as "ndr-admin-documents-list-new"
            # test filters
        When I click on "tab-archived"
        Then I should see the "report-submission" region exactly 0 times
        When I click on "tab-new"
        Then I should see the "report-submission" region exactly 1 times
            # assert submission and download
        Given each text should be present in the corresponding region:
            | <NAME> | report-submission-1 |
            | behat001 | report-submission-1 |
            | 1 document | report-submission-1 |
        When I click on "download" in the "report-submission-1" region
        Then the page content should be a zip file containing files with the following files:
            | NdrRep-.*\.pdf | regexpName+sizeAtLeast | 50000  |
            # archive (and clean for future tests)
        When I go to the URL previously saved as "ndr-admin-documents-list-new"
        When I click on "archive" in the "report-submission-1" region
        Then I should see the "report-submission" region exactly 0 times

<commit_msg>DDPB-839-fixed test for NDR documents admin<commit_after>Feature: ndr / report submit

    @ndr
    Scenario: NDR review page
        Given I am logged in as "<EMAIL>" with password "<PASSWORD>"
        # go to review page
        When I click on "ndr-start, ndr-submit"
        Then the URL should match "/ndr/\d+/review"
        # quick check sections are presented. An unit test asserts
        And I should see an "#visits-care-section" element
        And I should see an "#assets-section" element
        And I should see an "#debts-section" element
        And I should see an "#income-benefits-section" element
        And I should see an "#expenses-section" element
        And I should see an "#action-section" element
        And I should see an "#accounts-section" element
        And I save the application status into "ndr-before-submission"
        # assert pages not accessible

    @ndr
    Scenario: NDR declaration and submission
        Given emails are sent from "deputy" area
        And I reset the email log
        And I am logged in as "<EMAIL>" with password "<PASSWORD>"
        And I click on "ndr-start, ndr-submit, ndr-declaration-page"
        Then the URL should match "/ndr/\d+/declaration"
        #
        # empty form
        #
        When I press "ndr_declaration_save"
        Then the following fields should have an error:
            | ndr_declaration_agree |
            | ndr_declaration_agreedBehalfDeputy_0 |
            | ndr_declaration_agreedBehalfDeputy_1 |
            | ndr_declaration_agreedBehalfDeputy_2 |
            | ndr_declaration_agreedBehalfDeputyExplanation |
        # missing explanation
        When I fill in the following:
            | ndr_declaration_agree | 1 |
            | ndr_declaration_agreedBehalfDeputy_2 | more_deputies_not_behalf |
            | ndr_declaration_agreedBehalfDeputyExplanation |  |
        And I press "ndr_declaration_save"
        Then the following fields should have an error:
            | ndr_declaration_agreedBehalfDeputyExplanation |
        # change to one deputy and submit
        When I fill in the following:
            | ndr_declaration_agree | 1 |
            | ndr_declaration_agreedBehalfDeputy_0 | only_deputy |
            | ndr_declaration_agreedBehalfDeputyExplanation |  |
        And I press "ndr_declaration_save"
        Then the form should be valid
        And the URL should match "/ndr/\d+/submitted"
        And the response status code should be 200
        # return to homepage
        When I click on "return-homepage"
        Then I should be on "/ndr"

    @ndr
    Scenario: admin area check submission ZIP file
        Given I am logged in to admin as "<EMAIL>" with password "<PASSWORD>"
        And I click on "admin-documents"
        Then I should be on "/admin/documents/list"
        And I save the current URL as "ndr-admin-documents-list-new"
            # test filters
        When I click on "tab-archived"
        Then I should see the "report-submission" region exactly 0 times
        When I click on "tab-new"
        Then I should see the "report-submission" region exactly 1 times
            # assert submission and download
        Given each text should be present in the corresponding region:
            | <NAME> | report-submission-1 |
            | behat001 | report-submission-1 |
            | 1 document | report-submission-1 |
        When I check "cb1"
        Then I click on "download"
        # only checks one level deep. In this case, we check for a single report zip file
        And the page content should be a zip file containing files with the following files:
            | NdrRep.*.zip | regexpName+sizeAtLeast | 40000 |
        # test archive
        When I go to the URL previously saved as "ndr-admin-documents-list-new"
        Then I check "cb1"
        When I click on "archive"
        Then I should see the "report-submission" region exactly 0 times
        When I click on "tab-archived"
        Then I should see the "report-submission" region exactly 1 times
        And each text should be present in the corresponding region:
            | <NAME> | report-submission-1 |
            | behat001 | report-submission-1 |
            | 1 document | report-submission-1 |
            | AU | report-submission-1 |


{'fraction_non_alphanumeric': 0.062461726883037354, 'fraction_numerical': 0.008083282302510717, 'mean_word_length': 2.2162268609688853, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4643338', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2210, 'n_words': 853}