/*
   * ==Display event quick result==
   * ID :104237
   * Step 1: search 3.5
   */
  @Test
  public void test02_DisplayEventQuickResult() {
    String eventName = "Gatein 35 party" + getRandomNumber();
    String researchWord = "35";
    String eventDescription =
        "Gatein 35 has been released! It's time to make a party! Enjoy some good sounds and good sushis!";
    String eventLocation = "Tatakis Suchis bar, San Francisco";
    String spaceName = "Engineering" + getRandomNumber();
    info("Test02 - Display Event quick result");

    /*
     * Pre conditions
     */
    magMember.goToMySpacePage();
    magMember.addNewSpace(spaceName, "");
    info("New space added : " + spaceName);
    click(spaceMag.ELEMENT_SPACE_CALENDAR_PORTLET);
    evt.addQuickEvent(
        eventName,
        eventDescription,
        getDate(1, "MM/dd/yyyy 20:00"),
        getDate(1, "MM/dd/yyyy 23:00"),
        false);
    evt.editEvent(
        eventName,
        eventName,
        eventDescription,
        eventLocation,
        getDate(1, "MM/dd/yyyy 20:00"),
        getDate(1, "MM/dd/yyyy 23:00"),
        false);
    info("New event " + eventName + " create");

    /*
     * Step 1 : In search input 3.5
     */
    Utils.pause(2000);
    click(ELEMENT_QUICK_SEARCH_ICON);
    Utils.pause(2000);
    type(ELEMENT_QUICK_SEARCH_TEXTBOX, researchWord, true);
    waitForAndGetElement(
        By.xpath(
            qsPage
                .ELEMENT_QUICK_SEARCH_BOX_RESULTS
                .replace("{$result}", eventName)
                .replace("{$position}", "1")));

    info("Delete all events and tasks");
    goToCalendarPage();
    goToView(selectViewOption.LIST);
    deleteAllTaskEvent();
  }
  /*
   * ==Display events in quick search by pertinence==
   * ID : 104240
   * step 1 : search diner in quick search
   */
  @Test
  public void test04_DisplayEventsInQuickSearchByPertinence() {

    String eventName2 = "eventName" + getRandomNumber();
    String eventName3 = "eventName" + getRandomNumber();
    String diner = "diner";
    String eventDescription = "Futur event";

    /*
     * pre conditions
     */
    goToCalendarPage();

    info("Add one past and one future event in the perso cal");
    evt.addQuickEvent(
        diner,
        eventDescription,
        getDate(1, "MM/dd/yyyy 15:00"),
        getDate(1, "MM/dd/yyyy 16:00"),
        false);
    driver.navigate().refresh();
    Utils.pause(2000);
    evt.addQuickEvent(
        eventName2, diner, getDate(1, "MM/dd/yyyy 18:00"), getDate(1, "MM/dd/yyyy 19:00"), false);
    Utils.pause(2000);
    driver.navigate().refresh();
    evt.addQuickEvent(
        eventName3,
        eventDescription,
        getDate(1, "MM/dd/yyyy 21:00"),
        getDate(1, "MM/dd/yyyy 22:00"),
        false);
    driver.navigate().refresh();
    Utils.pause(2000);
    /*
     * Step 1 : search diner
     */
    qsPage.quickSearch(diner);
    info("Search for Diner");

    // Look for the order of the elements
    waitForElementNotPresent(
        (qsPage
            .ELEMENT_QUICK_SEARCH_BOX_RESULTS
            .replace("{$result}", diner)
            .replace("{$position}", "1")));
    waitForElementNotPresent(
        (qsPage
            .ELEMENT_QUICK_SEARCH_BOX_RESULTS
            .replace("{$result}", eventName2)
            .replace("{$position}", "2")));
    waitForElementNotPresent(
        (qsPage
            .ELEMENT_QUICK_SEARCH_BOX_RESULTS
            .replace("{$result}", eventName3)
            .replace("{$position}", "3")));
    goToCalendarPage();
    info("Delete all events and tasks");
    goToCalendarPage();
    goToView(selectViewOption.LIST);
    deleteAllTaskEvent();
  }