<commit_before>import Page from './page'

// TODO: do not use a hard coded url, but search the position by name or by type
const Page_URL = '/positions/39/edit'
const ADVISOR_ORG = 'EF 2.2 -'

class EditPosition extends Page {
    get form()                  { return browser.element('form') }
    get typeAdvisorButton()     { return browser.element('#typeAdvisorButton') }
    get typePrincipalButton()   { return browser.element('#typePrincipalButton') }
    get organization()          { return browser.element('#organization') }
    get orgAutocomplete()       { return browser.element('#react-autowhatever-1--item-0') }
    get alertSuccess()          { return browser.element('.alert-success') }
    get submitButton()          { return browser.element('#formBottomSubmit') }

    open() {
        super.openAsSuperUser(Page_URL)
    }

    waitForAlertSuccessToLoad() {
        if(!this.alertSuccess.isVisible()) {
            this.alertSuccess.waitForExist()
            this.alertSuccess.waitForVisible()
        }
    }

    waitForOrgAutoCompleteToChange() {<commit_msg>NCI-Agency/anet#562: Search for a principal position by code<commit_after>import Page from './page'

const Search_URL = '/api/positions/search?text=MOI-Pol-HQ-00001'
const ADVISOR_ORG = 'EF 2.2 -'

class EditPosition extends Page {
    get form()                  { return browser.element('form') }
    get typeAdvisorButton()     { return browser.element('#typeAdvisorButton') }
    get typePrincipalButton()   { return browser.element('#typePrincipalButton') }
    get organization()          { return browser.element('#organization') }
    get orgAutocomplete()       { return browser.element('#react-autowhatever-1--item-0') }
    get alertSuccess()          { return browser.element('.alert-success') }
    get submitButton()          { return browser.element('#formBottomSubmit') }

    open() {
        browser.url(super._buildUrl(Search_URL, Page.DEFAULT_CREDENTIALS.superUser))
        const searchRaw = browser.getText('pre')
        const searchJson = JSON.parse(searchRaw)
        const uuid = searchJson.list[0].uuid
        super.openAsSuperUser(`/positions/${uuid}/edit`)
    }

    waitForAlertSuccessToLoad() {
        if(!this.alertSuccess.isVisible()) {
            this.alertSuccess.waitForExist()
            this.alertSuccess.waitForVisible()
        }
    }

    waitForOrgAutoCompleteToChange() {
{'fraction_non_alphanumeric': 0.1228143213988343, 'fraction_numerical': 0.00791007493755204, 'mean_word_length': 2.9523026315789473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2488211', 'n_tokens_mistral': 690, 'n_tokens_neox': 657, 'n_words': 135}