package integration;

import com.codeborne.selenide.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static com.codeborne.selenide.Condition.empty;
import static com.codeborne.selenide.Condition.text;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.WebDriverRunner.isFirefox;
import static com.codeborne.selenide.WebDriverRunner.isHtmlUnit;
import static org.junit.Assume.assumeFalse;

public class AutoCompleteTest extends IntegrationTest {
  @Before
  public void openTestPageWithAutocomplete() {
    openFile("autocomplete.html");
  }

  @After
  public void tearDown() {
    Configuration.fastSetValue = false;
  }

  @Test
  public void setValueTriggersKeyboardEvents() {
    assumeFalse(isHtmlUnit() || isFirefox());
    startTypingForAutocomplete();
  }

  @Test
  public void setValueTriggersKeyboardEvents_fast_mode() {
    assumeFalse(isHtmlUnit() || isFirefox());
    Configuration.fastSetValue = true;
    startTypingForAutocomplete();
  }

  private void startTypingForAutocomplete() {
    $("h4").shouldBe(empty);

    $("#tags").val("javasc");
    $(".ui-autocomplete li").shouldHave(text("JavaScript")).click();
    $("#anyButton").click();

    $("h4").shouldHave(text("This is JavaScript!"));
  }
}

@@ -843,199 +843,8 @@
  %7D%0A%0A
-  @Test%0A  public void setValueTriggersKeyboardEvents_fast_mode() %7B%0A    assumeFalse(isHtmlUnit() %7C%7C isFirefox());%0A    Configuration.fastSetValue = true;%0A    startTypingForAutocomplete();%0A  %7D%0A%0A
   pr

remove test. "fast mode" isn't expected to generate keyup/keydown events.