/*
 * Copyright 2015-2016 Red Hat, Inc, and individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.hal.testsuite.fragment;

import org.jboss.arquillian.graphene.fragment.Root;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import static org.jboss.arquillian.graphene.Graphene.waitAjax;
import static org.jboss.arquillian.graphene.Graphene.waitGui;

/** Fragment for the vertical navigation. Provides methods to select primary and secondary items. */
public class VerticalNavigationFragment {

    @Root private WebElement root;

    public void selectPrimary(String id) {
        selectItem(id);
    }

    public void selectSecondary(String primaryId, String secondaryId) {
        root.findElement(By.cssSelector("#" + primaryId + " > a")).click();
        waitGui().until().element(By.id(primaryId + "-secondary")).is().visible();
        selectItem(secondaryId);
    }

    private void selectItem(String id) {
        root.findElement(By.cssSelector("#" + id + " > a")).click();
        waitAjax().until().element(By.cssSelector("[data-vn-item-for=" + id + "]")).is().visible();
    }
}

@@ -659,24 +659,80 @@
 .fragment;%0A%0A
+import org.jboss.arquillian.drone.api.annotation.Drone;%0A
 import org.j
@@ -832,23 +832,110 @@
 nium.Web
-Element
+Driver;%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.interactions.Actions
 ;%0A%0Aimpor
@@ -1233,16 +1233,54 @@
 nt root;
+%0A    @Drone private WebDriver browser;
 %0A%0A    pu
@@ -1418,32 +1418,61 @@
 aryId) %7B%0A       
+ WebElement primaryMenuItem =
  root.findElemen
@@ -1506,32 +1506,128 @@
 aryId + %22 %3E a%22))
+;%0A        new Actions(browser).moveToElement(primaryMenuItem).perform();%0A        primaryMenuItem
 .click();%0A      

Add hover action when navigating left vertical menu.