<commit_before>*** Settings ***
Documentation     INFUND-6390 As an Applicant I will be invited to add project costs, organisation and funding details via links ƒin the 'Finances' section of my application
...
...               INFUND-6393 As an Applicant I will be invited to add Staff count and Turnover where the include projected growth table is set to 'No' within the Finances page of Competition setup
...
...               INFUND-6395 s an Applicant I will be invited to add Projected growth, and Organisation size where the include projected growth table is set to Yes within the Finances page of Competition setup
...
...               INFUND-6895 As an Lead Applicant I will be advised that changing my Research category after completing Funding level will reset the 'Funding level'
Suite Setup       Custom Suite Setup
Suite Teardown    the user closes the browser
Force Tags        Applicant    CompAdmin
Resource          ../../../resources/defaultResources.robot
Resource          ../FinanceSection_Commons.robot
Resource          ../../02__Competition_Setup/CompAdmin_Commons.robot

*** Variables ***
${compWithoutGrowth}    From new Competition to New Application
${applicationTitle}    New Application from the New Competition
${compWITHGrowth}    Competition with growth table

*** Test Cases ***
Comp Admin starts a new Competition
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    [Setup]    guest user log-in    &{Comp_admin1_credentials}
    # For the testing of the story INFUND-6393, we need to create New Competition in order to apply the new Comp Setup fields
    # Then continue with the applying to this Competition, in order to see the new Fields applied
    Given the user navigates to the page    ${CA_UpcomingComp}
    When the user clicks the button/link    jQuery=.button:contains("Create competition")
    Then the user fills in the CS Initial details    ${compWithoutGrowth}    ${day}    ${month}    ${year}
    And the user fills in the CS Funding Information
    And the user fills in the CS Eligibility
    And the user fills in the CS Milestones    ${todayday}    ${day}    ${month}    ${nextyear}

Comp Admin fills in the Milestone Dates and can see them formatted afterwards
    [Documentation]    INFUND-7820
    [Tags]
    Given the user should see the element    jQuery=img[title$="is done"] + h3:contains("Milestones")
    When the user clicks the button/link    link=Milestones
    Then the user should see the element    jQuery=button:contains("Edit")
    And the user should see the dates in full format
    Then the user clicks the button/link    link=Competition setup

Application Finances should not include project growth
    [Documentation]    INFUND-6393
    [Tags]
    Given the user decides about the growth table    no    No

Comp admin completes ths competition setup
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    Given the user should see the element    jQuery=h1:contains("Competition setup")
    Then the user marks the Application as done
    And the user fills in the CS Assessors
    When the user clicks the button/link  link=Public content
    Then the user fills in the Public content and publishes
    And the user clicks the button/link  link=Return to setup overview
    And the user should see the element  css=img[title='The "Public content" section is done']
    When the user clicks the button/link    jQuery=a:contains("Save")
    And the user navigates to the page    ${CA_UpcomingComp}
    Then the user should see the element    jQuery=h2:contains("Ready to open") ~ ul a:contains("${compWithoutGrowth}")

Competition is Open to Applications
    [Documentation]    INFUND-6393
    [Tags]    HappyPath    MySQL
    The competitions date changes so it is now Open    ${compWithoutGrowth}

Create new Application for this Competition
    [Tags]    HappyPath
    Lead Applicant applies to the new created competition    ${compWithoutGrowth}

Applicant visits his Finances
    [Documentation]    INFUND-6393
    [Tags]
    Given the user should see the element    jQuery=h1:contains("Application overview")
    When the user clicks the button/link    link=Your finances
    Then the user should see the element    jQuery=li:contains("Your project costs") > .action-required
    And the user should see the element    jQuery=li:contains("Your organisation") > .action-required
    And the the user should see that the funding depends on the research area
    And the user should see his finances empty
    [Teardown]    the user clicks the button/link    jQuery=a:contains("Return to application overview")

Applicant fills in the Application Details
    [Documentation]    INFUND-6895
    [Tags]    HappyPath
    Given the user should see the element    jQuery=h1:contains("Application overview")
    When the user clicks the button/link    link=Application details
    Then the user enters text to a text field    css=#application_details-title    ${applicationTitle}
    And the user selects technical feasibility and no to resubmission and an innovation area
    And the user enters text to a text field    css=#application_details-startdate_day    ${day}
    And the user enters text to a text field    css=#application_details-startdate_month    ${month}
    And the user enters text to a text field    css=#application_details-startdate_year    ${nextyear}
    And the user enters text to a text field    css=#application_details-duration    24
    When The user clicks the button/link    jQuery=button[name="mark_as_complete"]
    Then the user clicks the button/link    link=Application Overview
    And the user should see the element     jQuery=li:contains("Application details") > .task-status-complete

Turnover and Staff count fields
    [Documentation]    INFUND-6393
    [Tags]
    Given the user clicks the button/link    link=Your finances
    Then the user clicks the button/link    link=Your organisation
    And the user should see the text in the page    Turnover (£)
    And the user should see the text in the page    Full time employees
    And the user should see the text in the page    Number of full time employees at your organisation.

Once the project growth table is selected
    [Documentation]    INFUND-6393
    [Tags]
    [Setup]    log in as a different user    &{Comp_admin1_credentials}
    Given the user navigates to the page    ${CA_UpcomingComp}
    When the user clicks the button/link    jQuery=.button:contains("Create competition")
    Then the user fills in the CS Initial details    Competition with growth table    ${day}    ${month}    ${year}
    And the user fills in the CS Funding Information
    And the user fills in the CS Eligibility
    And the user fills in the CS Milestones    ${todayday}    ${day}    ${month}    ${nextyear}
    When the user decides about the growth table    yes    Yes
    Then the user marks the Application as done
    And the user fills in the CS Assessors
    When the user clicks the button/link  link=Public content
    Then the user fills in the Public content and publishes
    And the user clicks the button/link  link=Return to setup overview
    And the user should see the element  css=img[title='The "Public content" section is done']
    When the user clicks the button/link    jQuery=a:contains("Save")
    And the user navigates to the page    ${CA_UpcomingComp}
    Then the user should see the element    jQuery=h2:contains("Ready to open") ~ ul a:contains("${compWITHGrowth}")
    [Teardown]    The competitions date changes so it is now Open    ${compWITHGrowth}

As next step the Applicant cannot see the turnover field
    [Documentation]    INFUND-6393, INFUND-6395
    [Tags]
    Given Lead Applicant applies to the new created competition    ${compWITHGrowth}
    When the user clicks the button/link    link=Your finances
    And the user clicks the button/link    link=Your organisation
    Then the user should not see the text in the page    Turnover (£)
    And the user should see the text in the page    Full time employees
    And the user should see the text in the page    How many full-time employees did you have on the project at the close of your last financial year?

Organisation server side validation when no
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    [Setup]    log in as a different user    &{lead_applicant_credentials}
    Given the user navigates to Your-finances page    ${applicationTitle}
    Then the user clicks the button/link    link=Your organisation
    When the user clicks the button/link    jQuery=button:contains("Mark as complete")
    Then the user should see the element    jQuery=.error-summary-list:contains("Enter your organisation size.")
    When the user enters text to a text field    jQuery=label:contains("Turnover") + input    -42
    And the user enters text to a text field    jQuery=label:contains("employees") + input    15.2
    And the user clicks the button/link    jQuery=button:contains("Mark as complete")
    Then the user should see the element    jQuery=.error-summary li:contains("This field should be 0 or higher.")
    And the user should see the element    jQuery=.error-summary li:contains("This field can only accept whole numbers.")
    And the user should not see the element    jQuery=h1:contains("Your finances")
    # Checking that by marking as complete, the user doens't get redirected to the main finances page

Organisation client side validation when no
    [Documentation]    INFUND-6393
    [Tags]
    Given the user selects medium organisation size
    When the user enters text to a text field    jQuery=label:contains("Turnover") + input    -33
    And the user moves focus to the element    jQuery=label:contains("Full time employees") + input
    Then the user should see a field and summary error      This field should be 0 or higher.
    And the user enters text to a text field    jQuery=label:contains("Full time employees") + input    ${empty}
    When the user moves focus to the element    jQuery=button:contains("Mark as complete")
    Then the user should see a field and summary error      This field cannot be left blank.
    When the user enters text to a text field    jQuery=label:contains("Turnover") + input    150
    And the user enters text to a text field    jQuery=label:contains("employees") + input    0
    And the user moves focus to the element    jQuery=button:contains("Mark as complete")
    Then the user should not see the element    css=.error-message

Mark Organisation as complete when no
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    Given the user enters text to a text field    jQuery=label:contains("employees") + input    42
    And the user enters text to a text field    jQuery=label:contains("Turnover") + input    17506
    And the user selects medium organisation size
    When the user clicks the button/link    jQuery=button:contains("Mark as complete")
    Then the user should see the element    jQuery=li:contains("Your organisation") > .task-status-complete
    When the user clicks the button/link    link=Your organisation
    # Then the user should see the fields in readonly mode, but currently they are missing this attribute
    # TODO INFUND-8071
    Then the user should see the element    jQuery=button:contains("Edit your organisation")
    And the user clicks the button/link    jQuery=a:contains("Return to finances")

The Lead applicant is able to edit and re-submit when no
    [Documentation]  INFUND-8518
    [Tags]
    Given the user can edit resubmit and read only of the organisation

Funding subsection opens when Appl details and organisation info are provided
    [Documentation]    INFUND-6895
    [Tags]    HappyPath
    [Setup]    the user navigates to the page    ${dashboard_url}
    And the user clicks the button/link    link=${applicationTitle}
    When the user should see the element   jQuery=li:contains("Application details") > .task-status-complete
    And the user clicks the button/link    link=Your finances
    And the user should see the element    jQuery=li:contains("Your organisation") > .task-status-complete
    Then the user should see the element    jQuery=li:contains("Your funding") > .action-required

Organisation server side validation when yes
    [Documentation]    INFUND-6393
    [Tags]
    [Setup]    the user navigates to the growth table finances
    Given the user clicks the button/link    link=Your organisation
    When the user clicks the button/link    jQuery=button:contains("Mark as complete")
    #Then the user should see the element    jQuery=.error-summary-list:contains("Enter your organisation size.")
    And the user should see the element    jQuery=.error-summary-list li:contains("This field cannot be left blank.")
    And the user should see the element    jQuery=.error-message:contains("This field cannot be left blank.")
    And the user should see the element    jQuery=.error-summary-list li:contains("Please enter a valid date.")
    And the user should see the element    jQuery=.error-message:contains("Please enter a valid date.")
    And The user should see a field error    This field cannot be left blank.
    And The user should see a field error    Please enter a valid date.
    #And The user should see a field error    Enter your organisation size
    #TODO Enable the above checks when INFUND-8297 is ready

Organisation client side validation when yes
    [Documentation]    INFUND-6395
    [Tags]
    When the user enters text to a text field    css=input[name$="month"]    42
    And the user enters text to a text field    css=input[name$="year"]    ${nextyear}
    Then the user should see a field and summary error      Please enter a valid date.
    When the user enters text to a text field    css=input[name$="month"]    12
    When the user enters text to a text field    css=input[name$="year"]    2016
    Then the user should see a field and summary error      Please enter a past date.
    And the user enters value to field    Annual turnover    ${EMPTY}
    And the user moves focus to the element    jQuery=button:contains("Mark as complete")
    Then the user should see a field and summary error      Please enter a valid date.
    Then the user should see a field and summary error      This field cannot be left blank.
    When the user enters value to field    Annual turnover    8.5
    And the user moves focus to the element    jQuery=td:contains("Annual profit") + td input
    Then the user should see a field and summary error      This field can only accept whole numbers.
    And the user enters value to field    Annual profit    -5
    When the user enters value to field    Annual export    ${empty}<commit_msg>INFUND-8767 fixing tests.<commit_after>*** Settings ***
Documentation     INFUND-6390 As an Applicant I will be invited to add project costs, organisation and funding details via links ƒin the 'Finances' section of my application
...
...               INFUND-6393 As an Applicant I will be invited to add Staff count and Turnover where the include projected growth table is set to 'No' within the Finances page of Competition setup
...
...               INFUND-6395 s an Applicant I will be invited to add Projected growth, and Organisation size where the include projected growth table is set to Yes within the Finances page of Competition setup
...
...               INFUND-6895 As an Lead Applicant I will be advised that changing my Research category after completing Funding level will reset the 'Funding level'
Suite Setup       Custom Suite Setup
Suite Teardown    the user closes the browser
Force Tags        Applicant    CompAdmin
Resource          ../../../resources/defaultResources.robot
Resource          ../FinanceSection_Commons.robot
Resource          ../../02__Competition_Setup/CompAdmin_Commons.robot

*** Variables ***
${compWithoutGrowth}    From new Competition to New Application
${applicationTitle}    New Application from the New Competition
${compWITHGrowth}    Competition with growth table

*** Test Cases ***
Comp Admin starts a new Competition
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    [Setup]    guest user log-in    &{Comp_admin1_credentials}
    # For the testing of the story INFUND-6393, we need to create New Competition in order to apply the new Comp Setup fields
    # Then continue with the applying to this Competition, in order to see the new Fields applied
    Given the user navigates to the page    ${CA_UpcomingComp}
    When the user clicks the button/link    jQuery=.button:contains("Create competition")
    Then the user fills in the CS Initial details    ${compWithoutGrowth}    ${day}    ${month}    ${year}
    And the user fills in the CS Funding Information
    And the user fills in the CS Eligibility
    And the user fills in the CS Milestones    ${todayday}    ${day}    ${month}    ${nextyear}

Comp Admin fills in the Milestone Dates and can see them formatted afterwards
    [Documentation]    INFUND-7820
    [Tags]
    Given the user should see the element    jQuery=img[title$="is done"] + h3:contains("Milestones")
    When the user clicks the button/link    link=Milestones
    Then the user should see the element    jQuery=button:contains("Edit")
    And the user should see the dates in full format
    Then the user clicks the button/link    link=Competition setup

Application Finances should not include project growth
    [Documentation]    INFUND-6393
    [Tags]
    Given the user decides about the growth table    no    No

Comp admin completes ths competition setup
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    Given the user should see the element    jQuery=h1:contains("Competition setup")
    Then the user marks the Application as done
    And the user fills in the CS Assessors
    When the user clicks the button/link  link=Public content
    Then the user fills in the Public content and publishes
    And the user clicks the button/link  link=Return to setup overview
    And the user should see the element  css=img[title='The "Public content" section is done']
    When the user clicks the button/link    jQuery=a:contains("Save")
    And the user navigates to the page    ${CA_UpcomingComp}
    Then the user should see the element    jQuery=h2:contains("Ready to open") ~ ul a:contains("${compWithoutGrowth}")

Competition is Open to Applications
    [Documentation]    INFUND-6393
    [Tags]    HappyPath    MySQL
    The competitions date changes so it is now Open    ${compWithoutGrowth}

Create new Application for this Competition
    [Tags]    HappyPath
    Lead Applicant applies to the new created competition    ${compWithoutGrowth}

Applicant visits his Finances
    [Documentation]    INFUND-6393
    [Tags]
    Given the user should see the element    jQuery=h1:contains("Application overview")
    When the user clicks the button/link    link=Your finances
    Then the user should see the element    jQuery=li:contains("Your project costs") > .action-required
    And the user should see the element    jQuery=li:contains("Your organisation") > .action-required
    And the the user should see that the funding depends on the research area
    And the user should see his finances empty
    [Teardown]    the user clicks the button/link    jQuery=a:contains("Return to application overview")

Applicant fills in the Application Details
    [Documentation]    INFUND-6895
    [Tags]    HappyPath
    Given the user should see the element    jQuery=h1:contains("Application overview")
    When the user clicks the button/link    link=Application details
    Then the user enters text to a text field    css=#application_details-title    ${applicationTitle}
    And the user selects technical feasibility and no to resubmission and an innovation area
    And the user enters text to a text field    css=#application_details-startdate_day    ${day}
    And the user enters text to a text field    css=#application_details-startdate_month    ${month}
    And the user enters text to a text field    css=#application_details-startdate_year    ${nextyear}
    And the user enters text to a text field    css=#application_details-duration    24
    When The user clicks the button/link    jQuery=button[name="mark_as_complete"]
    Then the user clicks the button/link    link=Application Overview
    And the user should see the element     jQuery=li:contains("Application details") > .task-status-complete

Turnover and Staff count fields
    [Documentation]    INFUND-6393
    [Tags]
    Given the user clicks the button/link    link=Your finances
    Then the user clicks the button/link    link=Your organisation
    And the user should see the text in the page    Turnover (£)
    And the user should see the text in the page    Full time employees
    And the user should see the text in the page    Number of full time employees at your organisation.

Once the project growth table is selected
    [Documentation]    INFUND-6393
    [Tags]
    [Setup]    log in as a different user    &{Comp_admin1_credentials}
    Given the user navigates to the page    ${CA_UpcomingComp}
    When the user clicks the button/link    jQuery=.button:contains("Create competition")
    Then the user fills in the CS Initial details    Competition with growth table    ${day}    ${month}    ${year}
    And the user fills in the CS Funding Information
    And the user fills in the CS Eligibility
    And the user fills in the CS Milestones    ${todayday}    ${day}    ${month}    ${nextyear}
    When the user decides about the growth table    yes    Yes
    Then the user marks the Application as done
    And the user fills in the CS Assessors
    When the user clicks the button/link  link=Public content
    Then the user fills in the Public content and publishes
    And the user clicks the button/link  link=Return to setup overview
    And the user should see the element  css=img[title='The "Public content" section is done']
    When the user clicks the button/link    jQuery=a:contains("Save")
    And the user navigates to the page    ${CA_UpcomingComp}
    Then the user should see the element    jQuery=h2:contains("Ready to open") ~ ul a:contains("${compWITHGrowth}")
    [Teardown]    The competitions date changes so it is now Open    ${compWITHGrowth}

As next step the Applicant cannot see the turnover field
    [Documentation]    INFUND-6393, INFUND-6395
    [Tags]
    Given Lead Applicant applies to the new created competition    ${compWITHGrowth}
    When the user clicks the button/link    link=Your finances
    And the user clicks the button/link    link=Your organisation
    Then the user should not see the text in the page    Turnover (£)
    And the user should see the text in the page    Full time employees
    And the user should see the text in the page    How many full-time employees did you have on the project at the close of your last financial year?

Organisation server side validation when no
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    [Setup]    log in as a different user    &{lead_applicant_credentials}
    Given the user navigates to Your-finances page    ${applicationTitle}
    Then the user clicks the button/link    link=Your organisation
    When the user clicks the button/link    jQuery=button:contains("Mark as complete")
    Then the user should see the element    jQuery=.error-summary-list:contains("Enter your organisation size.")
    When the user enters text to a text field    jQuery=label:contains("Turnover") + input    -42
    And the user enters text to a text field    jQuery=label:contains("employees") + input    15.2
    And the user clicks the button/link    jQuery=button:contains("Mark as complete")
    Then the user should see the element    jQuery=.error-summary li:contains("This field should be 0 or higher.")
    And the user should see the element    jQuery=.error-summary li:contains("This field can only accept whole numbers.")
    And the user should not see the element    jQuery=h1:contains("Your finances")
    # Checking that by marking as complete, the user doens't get redirected to the main finances page

Organisation client side validation when no
    [Documentation]    INFUND-6393
    [Tags]
    Given the user selects medium organisation size
    When the user enters text to a text field    jQuery=label:contains("Turnover") + input    -33
    And the user moves focus to the element    jQuery=label:contains("Full time employees") + input
    Then the user should see a field and summary error      This field should be 0 or higher.
    And the user enters text to a text field    jQuery=label:contains("Full time employees") + input    ${empty}
    When the user moves focus to the element    jQuery=button:contains("Mark as complete")
    Then the user should see a field and summary error      This field cannot be left blank.
    When the user enters text to a text field    jQuery=label:contains("Turnover") + input    150
    And the user enters text to a text field    jQuery=label:contains("employees") + input    0
    And the user moves focus to the element    jQuery=button:contains("Mark as complete")
    Then the user should not see the element    css=.error-message

Mark Organisation as complete when no
    [Documentation]    INFUND-6393
    [Tags]    HappyPath
    Given the user enters text to a text field    jQuery=label:contains("employees") + input    42
    And the user enters text to a text field    jQuery=label:contains("Turnover") + input    17506
    And the user selects medium organisation size
    When the user clicks the button/link    jQuery=button:contains("Mark as complete")
    Then the user should see the element    jQuery=li:contains("Your organisation") > .task-status-complete
    When the user clicks the button/link    link=Your organisation
    # Then the user should see the fields in readonly mode, but currently they are missing this attribute
    # TODO INFUND-8071
    Then the user should see the element    jQuery=button:contains("Edit your organisation")
    And the user clicks the button/link    jQuery=a:contains("Return to finances")

The Lead applicant is able to edit and re-submit when no
    [Documentation]  INFUND-8518
    [Tags]
    Given the user can edit resubmit and read only of the organisation

Funding subsection opens when Appl details and organisation info are provided
    [Documentation]    INFUND-6895
    [Tags]    HappyPath
    [Setup]    the user navigates to the page    ${dashboard_url}
    And the user clicks the button/link    link=${applicationTitle}
    When the user should see the element   jQuery=li:contains("Application details") > .task-status-complete
    And the user clicks the button/link    link=Your finances
    And the user should see the element    jQuery=li:contains("Your organisation") > .task-status-complete
    Then the user should see the element    jQuery=li:contains("Your funding") > .action-required

Organisation server side validation when yes
    [Documentation]    INFUND-6393
    [Tags]
    [Setup]    the user navigates to the growth table finances
    Given the user clicks the button/link    link=Your organisation
    When the user clicks the button/link    jQuery=button:contains("Mark as complete")
    #Then the user should see the element    jQuery=.error-summary-list:contains("Enter your organisation size.")
    And the user should see the element    jQuery=.error-summary-list li:contains("This field cannot be left blank.")
    And the user should see the element    jQuery=.error-message:contains("This field cannot be left blank.")
    And the user should see the element    jQuery=.error-summary-list li:contains("Please enter a valid date.")
    And the user should see the element    jQuery=.error-message:contains("Please enter a valid date.")
    And The user should see a field error    This field cannot be left blank.
    And The user should see a field error    Please enter a valid date.
    #And The user should see a field error    Enter your organisation size
    #TODO Enable the above checks when INFUND-8297 is ready

Organisation client side validation when yes
    [Documentation]    INFUND-6395
    [Tags]
    When the user enters text to a text field    css=input[name$="month"]    42
    Then the user should see a field and summary error      Please enter a valid date.
    When the user enters text to a text field    css=input[name$="month"]    12
    And the user enters text to a text field    css=input[name$="year"]    ${nextyear}
    Then the user should see a field and summary error      Please enter a past date.
    When the user enters text to a text field    css=input[name$="year"]    2016
    And the user enters value to field    Annual turnover    ${EMPTY}
    Then the user should see a field and summary error      This field cannot be left blank.
    When the user enters value to field    Annual turnover    8.5
    And the user moves focus to the element    jQuery=td:contains("Annual profit") + td input
    Then the user should see a field and summary error      This field can only accept whole numbers.
    And the user enters value to field    Annual profit    -5
    When the user enters value to field    Annual export    ${empty}
{'fraction_non_alphanumeric': 0.056232715353887124, 'fraction_numerical': 0.00996961316535218, 'mean_word_length': 3.2821637426900585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2022391', 'n_tokens_mistral': 7716, 'n_tokens_neox': 7320, 'n_words': 3699}