Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use refind for Nav Bar items #2245

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.labkey.test.components.UpdatingComponent;
import org.labkey.test.components.bootstrap.ModalDialog;
import org.labkey.test.components.html.Checkbox;
import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -391,6 +390,8 @@ public FieldSelectionDialog removeAllSelectedFields()

for (WebElement listItem : allItems)
{
getWrapper().log(String.format("Removing field '%s' from selected fields.", listItem.getText()));

WebElement removeIcon = Locator.tagWithClass("span", "view-field__action").findWhenNeeded(listItem);

// In some usages there may be fields that are not removable.
Expand All @@ -405,7 +406,10 @@ public FieldSelectionDialog removeAllSelectedFields()

// If a non-removable field is encountered, then skip check to see if all fields are removed.
if (removedAll)
WebDriverWrapper.waitFor(()-> getSelectedFields().isEmpty(), "Did not remove all of the selected fields.", 500);
{
WebDriverWrapper.sleep(500);
WebDriverWrapper.waitFor(() -> getSelectedFields().isEmpty(), "Did not remove all of the selected fields.", 1_500);
}

return this;
}
Expand Down
20 changes: 9 additions & 11 deletions src/org/labkey/test/components/ui/navigation/NavBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;

public abstract class NavBar extends WebDriverComponent<NavBar.ElementCache>
{
private final WebDriver _driver;
Expand Down Expand Up @@ -113,14 +111,14 @@ public WebDriver getDriver()

protected abstract class ElementCache extends Component<ElementCache>.ElementCache
{
public WebElement headerLogo = Locator.tagWithClass("a", "header-logo__link").findWhenNeeded(this);
public WebElement headerLogoImage = Locator.tagWithClass("img", "header-logo__image").findWhenNeeded(this);
public WebElement userMenuButton = Locator.tagWithId("a", "user-menu-dropdown").findWhenNeeded(this).withTimeout(WAIT_FOR_JAVASCRIPT);
public WebElement userIcon = Locator.tagWithAttribute("img", "alt", "User Avatar").findWhenNeeded(this);
public WebElement projectNameDisplay = Locator.tagWithClass("span", "project-name").findWhenNeeded(this);
public Input searchBox = Input.Input(Locator.tagWithClass("input", "navbar__search-input"), getDriver()).findWhenNeeded(this);
public MultiMenu searchMenu = new MultiMenu.MultiMenuFinder(getDriver()).withButtonClass("navbar__find-and-search-button").findWhenNeeded(this);
public final ProductMenu productMenu = ProductMenu.finder(getDriver()).timeout(1000).findWhenNeeded(this);
public final ServerNotificationMenu notificationsMenu = ServerNotificationMenu.finder(getDriver()).timeout(1000).findWhenNeeded(this);
public WebElement headerLogo = Locator.tagWithClass("a", "header-logo__link").refindWhenNeeded(this);
public WebElement headerLogoImage = Locator.tagWithClass("img", "header-logo__image").refindWhenNeeded(this);
public WebElement userMenuButton = Locator.tagWithId("a", "user-menu-dropdown").refindWhenNeeded(this);
public WebElement userIcon = Locator.tagWithAttribute("img", "alt", "User Avatar").refindWhenNeeded(this);
public WebElement projectNameDisplay = Locator.tagWithClass("span", "project-name").refindWhenNeeded(this);
public Input searchBox = Input.Input(Locator.tagWithClass("input", "navbar__search-input"), getDriver()).refindWhenNeeded(this);
public MultiMenu searchMenu = new MultiMenu.MultiMenuFinder(getDriver()).withButtonClass("navbar__find-and-search-button").refindWhenNeeded(this);
public final ProductMenu productMenu = ProductMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this);
public final ServerNotificationMenu notificationsMenu = ServerNotificationMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this);
}
}
33 changes: 33 additions & 0 deletions src/org/labkey/test/tests/component/GridPanelViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,39 @@ public void testManageViews()

}

@Test
public void testRemoveAllFields()
{

goToProjectHome();

resetDefaultView(VIEW_DIALOG_ST, DEFAULT_COLUMNS);

QueryGrid grid = beginAtQueryGrid(VIEW_DIALOG_ST);

log("Remove all the fields.");

FieldSelectionDialog customizeModal = grid.customizeView();
customizeModal.removeAllSelectedFields();

checker().verifyTrue("'Undo edits' is not enabled after removing all fields, it should be.",
customizeModal.isUndoEditsEnabled());

checker().verifyFalse("'Update Grid' should not be enabled after all fields are updated.",
customizeModal.isUpdateGridEnabled());

checker().screenShotIfNewError("Remove_All_Dialog_Error");

log("Add a field back and validate.");

customizeModal.selectAvailableField(COL_STRING1)
.clickUpdateGrid();

checker().verifyEquals("Grid columns not as expected after removing all, and adding back a field.",
List.of(COL_STRING1), grid.getColumnNames());

}

/**
* Helper to validate the 'Views' menu.
*
Expand Down