<commit_before>import { expect } from "chai"
import CreateReport from "../pages/createReport.page"

const REPORT = "Interior"
const REPORT_VALUE = "Talk to the Interior about things"
const REPORT_COMPLETE = `${REPORT_VALUE}`

const PERSON = "EF 2.1"
const PERSON_VALUE_1 = "<NAME>"
const PERSON_VALUE_2 = "<NAME>"
const PERSON_COMPLETE_1 = `BGen ${PERSON_VALUE_1}`
const PERSON_COMPLETE_2 = `OF-9 ${PERSON_VALUE_2}`

const POSITION = "MOD-FO"
const POSITION_VALUE_1 = "Chief of Staff - MoD"
const POSITION_VALUE_2 = "Executive Assistant to the MoD"
const POSITION_VALUE_3 = "Minister of Defense"
const POSITION_COMPLETE_1 = `${POSITION_VALUE_1}`
const POSITION_COMPLETE_2 = `${POSITION_VALUE_2}`
const POSITION_COMPLETE_3 = `${POSITION_VALUE_3}`

const SHORT_WAIT_MS = 1000

describe("Create report form page", () => {
  describe("When creating a report", () => {
    it("Should be able to load the form", () => {
      CreateReport.open()
      CreateReport.form.waitForExist()
      CreateReport.form.waitForDisplayed()
    })

    it("Should be able to select an ANET object reference", () => {
      CreateReport.testReferenceFieldLabel.waitForExist()
      CreateReport.testReferenceFieldLabel.waitForDisplayed()
      expect(CreateReport.testReferenceFieldLabel.getText()).to.equal(
        "Related report"
      )
      CreateReport.testReferenceFieldHelpText.waitForExist()
      CreateReport.testReferenceFieldHelpText.waitForDisplayed()
      expect(CreateReport.testReferenceFieldHelpText.getText()).to.equal(
        "Here you can link to a related report"
      )

      // Only input type is Reports, so there should be no button to select a type
      expect(
        CreateReport.testReferenceField.getAttribute("placeholder")
      ).to.equal("Find reports")
      // eslint-disable-next-line no-unused-expressions
      expect(
        CreateReport.testReferenceFieldFormGroup
          .$('//button[text()="Reports"]')
          .isExisting()
      ).to.be.false
      CreateReport.testReferenceFieldLabel.click()
      CreateReport.testReferenceField.setValue(REPORT)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.testReferenceFieldAdvancedSelectFirstItem,
        REPORT_COMPLETE
      )
      expect(
        CreateReport.testReferenceFieldAdvancedSelectFirstItem.getText()
      ).to.include(REPORT_COMPLETE)
      CreateReport.testReferenceFieldAdvancedSelectFirstItem.click()
      // Advanced select input gets empty, the selected element shown below the input
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testReferenceFieldLabel.getValue()).to.be.null
      // Value should exist now
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testReferenceFieldValue.isExisting()).to.be.true
      expect(CreateReport.testReferenceFieldValue.getText()).to.include(
        REPORT_VALUE
      )

      // Delete selected value
      CreateReport.testReferenceFieldValue.$("button").click()
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testReferenceFieldValue.isExisting()).to.be.false

      // Select it again
      CreateReport.testReferenceFieldLabel.click()
      CreateReport.testReferenceField.setValue(REPORT)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.testReferenceFieldAdvancedSelectFirstItem,
        REPORT_COMPLETE
      )
      CreateReport.testReferenceFieldAdvancedSelectFirstItem.click()
    })

    it("Should be able to select multiple ANET object references", () => {
      CreateReport.testMultiReferenceFieldLabel.waitForExist()
      CreateReport.testMultiReferenceFieldLabel.waitForDisplayed()
      expect(CreateReport.testMultiReferenceFieldLabel.getText()).to.equal(
        "Additional engagement needed for"
      )
      CreateReport.testMultiReferenceFieldHelpText.waitForExist()
      CreateReport.testMultiReferenceFieldHelpText.waitForDisplayed()
      expect(CreateReport.testMultiReferenceFieldHelpText.getText()).to.equal(
        "Here you can link to people, positions and organizations that need an additional engagement"
      )

      // Default input type is People
      expect(
        CreateReport.testMultiReferenceField.getAttribute("placeholder")
      ).to.equal("Find people")
      CreateReport.testMultiReferenceFieldLabel.click()
      CreateReport.testMultiReferenceField.setValue(PERSON)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(1),
        PERSON_COMPLETE_1
      )
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          1
        ).getText()
      ).to.include(PERSON_COMPLETE_1)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(1).click()
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          2
        ).getText()
      ).to.include(PERSON_COMPLETE_2)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(2).click()
      // Click outside the overlay
      CreateReport.engagementInformationTitle.click()
      // Advanced select input gets empty, the selected element shown below the input
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceFieldLabel.getValue()).to.be.null
      // Value should exist now
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceFieldValue.isExisting()).to.be.true
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(1).getText()
      ).to.include(PERSON_VALUE_1)
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(2).getText()
      ).to.include(PERSON_VALUE_2)

      // Change input type to Positions
      CreateReport.testMultiReferenceFieldFormGroup
        .$('//button[text()="Positions"]')
        .click()
      expect(
        CreateReport.testMultiReferenceField.getAttribute("placeholder")
      ).to.equal("Find positions")
      CreateReport.testMultiReferenceFieldLabel.click()
      CreateReport.testMultiReferenceField.setValue(POSITION)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(1),
        POSITION_COMPLETE_1
      )
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          1
        ).getText()
      ).to.include(POSITION_COMPLETE_1)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(1).click()
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          2
        ).getText()
      ).to.include(POSITION_COMPLETE_2)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(2).click()
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          3
        ).getText()
      ).to.include(POSITION_COMPLETE_3)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(3).click()
      // Click outside the overlay
      CreateReport.engagementInformationTitle.click()
      // Advanced select input gets empty, the selected element shown below the input
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceFieldLabel.getValue()).to.be.null
      // Value should exist now
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceFieldValue.isExisting()).to.be.true
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(3).getText()
      ).to.include(POSITION_VALUE_1)
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(4).getText()
      ).to.include(POSITION_VALUE_2)
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(5).getText()
      ).to.include(POSITION_VALUE_3)<commit_msg>Fix assertions<commit_after>import { expect } from "chai"
import CreateReport from "../pages/createReport.page"

const REPORT = "Interior"
const REPORT_VALUE = "Talk to the Interior about things"
const REPORT_COMPLETE = `${REPORT_VALUE}`

const PERSON = "EF 2.1"
const PERSON_VALUE_1 = "<NAME>"
const PERSON_VALUE_2 = "<NAME>"
const PERSON_COMPLETE_1 = `BGen ${PERSON_VALUE_1}`
const PERSON_COMPLETE_2 = `OF-9 ${PERSON_VALUE_2}`

const POSITION = "MOD-FO"
const POSITION_VALUE_1 = "Chief of Staff - MoD"
const POSITION_VALUE_2 = "Executive Assistant to the MoD"
const POSITION_VALUE_3 = "Minister of Defense"
const POSITION_COMPLETE_1 = `${POSITION_VALUE_1}`
const POSITION_COMPLETE_2 = `${POSITION_VALUE_2}`
const POSITION_COMPLETE_3 = `${POSITION_VALUE_3}`

const SHORT_WAIT_MS = 1000

describe("Create report form page", () => {
  describe("When creating a report", () => {
    it("Should be able to load the form", () => {
      CreateReport.open()
      CreateReport.form.waitForExist()
      CreateReport.form.waitForDisplayed()
    })

    it("Should be able to select an ANET object reference", () => {
      CreateReport.testReferenceFieldLabel.waitForExist()
      CreateReport.testReferenceFieldLabel.waitForDisplayed()
      expect(CreateReport.testReferenceFieldLabel.getText()).to.equal(
        "Related report"
      )
      CreateReport.testReferenceFieldHelpText.waitForExist()
      CreateReport.testReferenceFieldHelpText.waitForDisplayed()
      expect(CreateReport.testReferenceFieldHelpText.getText()).to.equal(
        "Here you can link to a related report"
      )

      // Only input type is Reports, so there should be no button to select a type
      expect(
        CreateReport.testReferenceField.getAttribute("placeholder")
      ).to.equal("Find reports")
      // eslint-disable-next-line no-unused-expressions
      expect(
        CreateReport.testReferenceFieldFormGroup
          .$('//button[text()="Reports"]')
          .isExisting()
      ).to.be.false
      CreateReport.testReferenceFieldLabel.click()
      CreateReport.testReferenceField.setValue(REPORT)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.testReferenceFieldAdvancedSelectFirstItem,
        REPORT_COMPLETE
      )
      expect(
        CreateReport.testReferenceFieldAdvancedSelectFirstItem.getText()
      ).to.include(REPORT_COMPLETE)
      CreateReport.testReferenceFieldAdvancedSelectFirstItem.click()
      // Advanced select input gets empty, the selected element shown below the input
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testReferenceField.getValue()).to.be.empty
      // Value should exist now
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testReferenceFieldValue.isExisting()).to.be.true
      expect(CreateReport.testReferenceFieldValue.getText()).to.include(
        REPORT_VALUE
      )

      // Delete selected value
      CreateReport.testReferenceFieldValue.$("button").click()
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testReferenceFieldValue.isExisting()).to.be.false

      // Select it again
      CreateReport.testReferenceFieldLabel.click()
      CreateReport.testReferenceField.setValue(REPORT)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.testReferenceFieldAdvancedSelectFirstItem,
        REPORT_COMPLETE
      )
      CreateReport.testReferenceFieldAdvancedSelectFirstItem.click()
    })

    it("Should be able to select multiple ANET object references", () => {
      CreateReport.testMultiReferenceFieldLabel.waitForExist()
      CreateReport.testMultiReferenceFieldLabel.waitForDisplayed()
      expect(CreateReport.testMultiReferenceFieldLabel.getText()).to.equal(
        "Additional engagement needed for"
      )
      CreateReport.testMultiReferenceFieldHelpText.waitForExist()
      CreateReport.testMultiReferenceFieldHelpText.waitForDisplayed()
      expect(CreateReport.testMultiReferenceFieldHelpText.getText()).to.equal(
        "Here you can link to people, positions and organizations that need an additional engagement"
      )

      // Default input type is People
      expect(
        CreateReport.testMultiReferenceField.getAttribute("placeholder")
      ).to.equal("Find people")
      CreateReport.testMultiReferenceFieldLabel.click()
      CreateReport.testMultiReferenceField.setValue(PERSON)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(1),
        PERSON_COMPLETE_1
      )
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          1
        ).getText()
      ).to.include(PERSON_COMPLETE_1)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(1).click()
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          2
        ).getText()
      ).to.include(PERSON_COMPLETE_2)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(2).click()
      // Click outside the overlay
      CreateReport.engagementInformationTitle.click()
      // Advanced select input gets empty, the selected element shown below the input
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceField.getValue()).to.be.empty
      // Value should exist now
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceFieldValue.isExisting()).to.be.true
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(1).getText()
      ).to.include(PERSON_VALUE_1)
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(2).getText()
      ).to.include(PERSON_VALUE_2)

      // Change input type to Positions
      CreateReport.testMultiReferenceFieldFormGroup
        .$('//button[text()="Positions"]')
        .click()
      expect(
        CreateReport.testMultiReferenceField.getAttribute("placeholder")
      ).to.equal("Find positions")
      CreateReport.testMultiReferenceFieldLabel.click()
      CreateReport.testMultiReferenceField.setValue(POSITION)
      CreateReport.waitForAdvancedSelectToChange(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(1),
        POSITION_COMPLETE_1
      )
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          1
        ).getText()
      ).to.include(POSITION_COMPLETE_1)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(1).click()
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          2
        ).getText()
      ).to.include(POSITION_COMPLETE_2)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(2).click()
      expect(
        CreateReport.getTestMultiReferenceFieldAdvancedSelectItemLabel(
          3
        ).getText()
      ).to.include(POSITION_COMPLETE_3)
      CreateReport.getTestMultiReferenceFieldAdvancedSelectItem(3).click()
      // Click outside the overlay
      CreateReport.engagementInformationTitle.click()
      // Advanced select input gets empty, the selected element shown below the input
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceField.getValue()).to.be.empty
      // Value should exist now
      // eslint-disable-next-line no-unused-expressions
      expect(CreateReport.testMultiReferenceFieldValue.isExisting()).to.be.true
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(3).getText()
      ).to.include(POSITION_VALUE_1)
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(4).getText()
      ).to.include(POSITION_VALUE_2)
      expect(
        CreateReport.getTestMultiReferenceFieldValueRow(5).getText()
      ).to.include(POSITION_VALUE_3)
{'fraction_non_alphanumeric': 0.09083381107076884, 'fraction_numerical': 0.006497229122874069, 'mean_word_length': 3.5613015688553165, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3394481', 'n_tokens_mistral': 4258, 'n_tokens_neox': 4235, 'n_words': 708}