Skip to content

Commit

Permalink
rewrite ITs to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Jan 27, 2025
1 parent 4498255 commit 5fa0a04
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public ButtonView() {
createImageButtonWithAutofocus();
createImageButtonWithAccessibleLabel();
createButtonsWithTabIndex();
createDisabledButton();
createButtonWithDisableOnClick();
createButtonWithDisableOnClickThatEnablesInSameRoundTrip();
createButtonWithDisableOnClickThatIsHidden();
Expand Down Expand Up @@ -127,6 +128,17 @@ private void createButtonsWithTabIndex() {
button3.setId("button-tabindex-3");
}

private void createDisabledButton() {
Button button = new Button("Disabled");
button.setEnabled(false);

addCard("Disabled button", button);
button.addClickListener(evt -> message.setText("Button "
+ evt.getSource().getText()
+ " was clicked, but the button is disabled and this shouldn't happen!"));
button.setId("disabled-button");
}

private void addVariantsFeature() {
Button button = new Button("Button");
button.setId("button-theme-variants");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,28 @@ public void clickOnTabIndexButtons_textIsDisplayed() {
waitUntilMessageIsChangedForClickedButton("1");
}

@Test
public void clickOnDisabledButton_nothingIsDisplayed() {
WebElement button = layout.findElement(By.id("disabled-button"));
Assert.assertTrue("The button should contain the 'disabled' attribute",
button.getAttribute("disabled").equals("")
|| button.getAttribute("disabled").equals("true"));

// valo theme adds the pointer-events: none CSS property, which makes
// the button unclickable by selenium.
Assert.assertEquals("none", button.getCssValue("pointer-events"));

WebElement message = layout.findElement(By.id("buttonMessage"));
Assert.assertEquals("", message.getText());

// Remove disabled Attribute and click again from client side, click
// message should not been shown in the dom
executeScript("arguments[0].removeAttribute(\"disabled\");"
+ "arguments[0].click();", button);
message = layout.findElement(By.id("buttonMessage"));
Assert.assertEquals("", message.getText());
}

@Test
public void clickDisableOnClickButton_newClickNotRegistered() {
WebElement button = layout
Expand Down

This file was deleted.

Loading

0 comments on commit 5fa0a04

Please sign in to comment.