<commit_before>import moment from "moment"
import Page from "../page"

const PAGE_URL = "/reports/new"

class CreateReport extends Page {
  get form() {
    return browser.$("form")
  }

  get title() {
    return browser.$("h2.legend")
  }

  get intent() {
    return browser.$("#intent")
  }

  get engagementDate() {
    return browser.$("#engagementDate")
  }

  get today() {
    return browser.$(".bp3-datepicker-footer > button:first-child")
  }

  get tomorrow() {
    const tomorrow = moment().add(1, "day").format("ddd MMM DD YYYY")
    return browser.$(`div[aria-label="${tomorrow}"]`)
  }

  get hour() {
    return browser.$("input.bp3-timepicker-input.bp3-timepicker-hour")
  }

  get minute() {
    return browser.$("input.bp3-timepicker-input.bp3-timepicker-minute")
  }

  get duration() {
    return browser.$("#duration")
  }

  get attendees() {
    return browser.$("#attendees")
  }

  get attendeesTable() {
    return browser.$("#attendees-popover .table-responsive table")
  }

  get submitButton() {
    return browser.$("#formBottomSubmit")
  }

  open() {
    super.open(PAGE_URL)
  }

  getAdvisor(index) {
    const advisor = browser.$(
      `.advisorAttendeesTable tbody tr:nth-child(${index})`
    )

    // wait for conflict loader to disappear
    advisor.$("td:nth-child(6) div.bp3-spinner").waitForExist({ reverse: true })

    return {
      name: advisor.$("td:nth-child(2)").getText(),
      conflictButton: advisor.$("td:nth-child(6) > span"),
      deleteButton: advisor.$("td:nth-child(7) > button")
    }
  }

  getPrincipal(index) {
    // principals table has an empty row at top
    const principal = browser.$(
      `.principalAttendeesTable tbody tr:nth-child(${index + 1})`
    )

    // wait for conflict loader to disappear
    principal
      .$("td:nth-child(6) div.bp3-spinner")
      .waitForExist({ reverse: true })

    return {
      name: principal.$("td:nth-child(2)").getText(),
      conflictButton: principal.$("td:nth-child(6) > span"),
      deleteButton: principal.$("td:nth-child(7) > button")
    }
  }

  selectAttendeeByName(name) {
    this.attendees.click()
    // wait for attendess table loader to disappear
    this.attendeesTable.waitForDisplayed()
    let searchTerm = name
    if (searchTerm.startsWith("CIV") || searchTerm.startsWith("Maj")) {
      searchTerm = name.substr(name.indexOf(" ") + 1)
    }
    browser.keys(searchTerm)
    this.attendeesTable.waitForDisplayed()
    const checkBox = this.attendeesTable.$(
      "tbody tr:first-child td:first-child input.checkbox"
    )
    if (!checkBox.isSelected()) {
      checkBox.click()
    }
    this.title.click()
    this.attendeesTable.waitForDisplayed({ reverse: true })
  }

  fillForm(fields) {
    this.form.waitForClickable()

    if (fields.intent !== undefined) {
      this.intent.setValue(fields.intent)
    }

    if (moment.isMoment(fields.engagementDate)) {
      this.engagementDate.click()
      this.tomorrow.waitForDisplayed()
      this.tomorrow.waitForClickable()
      browser.pause(300) // wait for calendar popup animation
      this.tomorrow.click()
      browser.waitUntil(() => !!browser.$("#engagementDate").getValue())
      this.hour.waitForDisplayed()
      this.hour.waitForClickable()
      this.hour.click()
      browser.keys(fields.engagementDate.format("HH"))
      this.minute.waitForDisplayed()<commit_msg>Fix planning conflict intermittent wdio test errors<commit_after>import moment from "moment"
import Page from "../page"

const PAGE_URL = "/reports/new"

class CreateReport extends Page {
  get form() {
    return browser.$("form")
  }

  get title() {
    return browser.$("h2.legend")
  }

  get intent() {
    return browser.$("#intent")
  }

  get intentHelpBlock() {
    return browser.$("#fg-intent .help-block")
  }

  get engagementDate() {
    return browser.$("#engagementDate")
  }

  get today() {
    return browser.$(".bp3-datepicker-footer > button:first-child")
  }

  get tomorrow() {
    const tomorrow = moment().add(1, "day").format("ddd MMM DD YYYY")
    return browser.$(`div[aria-label="${tomorrow}"]`)
  }

  get hour() {
    return browser.$("input.bp3-timepicker-input.bp3-timepicker-hour")
  }

  get minute() {
    return browser.$("input.bp3-timepicker-input.bp3-timepicker-minute")
  }

  get duration() {
    return browser.$("#duration")
  }

  get attendees() {
    return browser.$("#attendees")
  }

  get attendeesTable() {
    return browser.$("#attendees-popover .table-responsive table")
  }

  get submitButton() {
    return browser.$("#formBottomSubmit")
  }

  open() {
    super.open(PAGE_URL)
  }

  getAdvisor(index) {
    const advisor = browser.$(
      `.advisorAttendeesTable tbody tr:nth-child(${index})`
    )

    // wait for conflict loader to disappear
    advisor.$("td:nth-child(6) div.bp3-spinner").waitForExist({ reverse: true })

    return {
      name: advisor.$("td:nth-child(2)").getText(),
      conflictButton: advisor.$("td:nth-child(6) > span"),
      deleteButton: advisor.$("td:nth-child(7) > button")
    }
  }

  getPrincipal(index) {
    // principals table has an empty row at top
    const principal = browser.$(
      `.principalAttendeesTable tbody tr:nth-child(${index + 1})`
    )

    // wait for conflict loader to disappear
    principal
      .$("td:nth-child(6) div.bp3-spinner")
      .waitForExist({ reverse: true })

    return {
      name: principal.$("td:nth-child(2)").getText(),
      conflictButton: principal.$("td:nth-child(6) > span"),
      deleteButton: principal.$("td:nth-child(7) > button")
    }
  }

  selectAttendeeByName(name) {
    this.attendees.click()
    // wait for attendess table loader to disappear
    this.attendeesTable.waitForDisplayed()
    let searchTerm = name
    if (searchTerm.startsWith("CIV") || searchTerm.startsWith("Maj")) {
      searchTerm = name.substr(name.indexOf(" ") + 1)
    }
    browser.keys(searchTerm)
    this.attendeesTable.waitForDisplayed()
    const checkBox = this.attendeesTable.$(
      "tbody tr:first-child td:first-child input.checkbox"
    )
    if (!checkBox.isSelected()) {
      checkBox.click()
    }
    this.title.click()
    this.attendeesTable.waitForDisplayed({ reverse: true })
  }

  fillForm(fields) {
    this.form.waitForClickable()

    if (fields.intent !== undefined) {
      this.intent.setValue(fields.intent)
    }

    this.intentHelpBlock.waitForExist({ reverse: true })

    if (moment.isMoment(fields.engagementDate)) {
      this.engagementDate.waitForClickable()
      this.engagementDate.click()
      this.tomorrow.waitForDisplayed()
      this.tomorrow.waitForClickable()
      browser.pause(300) // wait for calendar popup animation
      this.tomorrow.click()
      browser.waitUntil(() => !!browser.$("#engagementDate").getValue())
      this.hour.waitForDisplayed()
      this.hour.waitForClickable()
      this.hour.click()
      browser.keys(fields.engagementDate.format("HH"))
      this.minute.waitForDisplayed()
{'fraction_non_alphanumeric': 0.15647816750178956, 'fraction_numerical': 0.006299212598425197, 'mean_word_length': 3.1166764879198587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3105099', 'n_tokens_mistral': 2320, 'n_tokens_neox': 2243, 'n_words': 410}