Skip to content

Commit

Permalink
fix: Set book form button initial states and assert
Browse files Browse the repository at this point in the history
  • Loading branch information
TatuJLund committed Oct 4, 2024
1 parent baa9c6d commit 672dd7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public BookForm(BooksPresenter presenter) {
var hasChanges = binder.hasChanges();
saveButton.setEnabled(hasChanges && isValid);
discardButton.setEnabled(hasChanges);

});

saveButton.addClickListener(event -> handleSave());
Expand Down Expand Up @@ -330,6 +329,8 @@ public void editProduct(Product product) {
deleteButton.setEnabled(product.getId() != null);
currentProduct = product;
binder.readBean(product);
saveButton.setEnabled(false);
discardButton.setEnabled(false);

// Scroll to the top
// As this is not a Panel, using JavaScript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private void verifySelectedCategoriesAreTheFirst() {
@SuppressWarnings("unchecked")
public void crossValidationAndDiscard() {
test($(view, Button.class).id("new-product")).click();
assertFalse($(form, Button.class).id("discard-button").isEnabled());
assertFalse($(form, Button.class).id("save-button").isEnabled());

test($(form, TextField.class).id("product-name")).setValue("Te");
test($(form, AvailabilitySelector.class).id("availability"))
Expand Down

0 comments on commit 672dd7e

Please sign in to comment.