Skip to content

Commit

Permalink
Close existing details when the generator is changed (#18664)
Browse files Browse the repository at this point in the history
Change-Id: Iae5e70f42c27731ce40c00604ccc6097323faa79
  • Loading branch information
tepi authored and jdahlstrom committed Sep 1, 2015
1 parent 53a4b2c commit 3c9ec4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
4 changes: 4 additions & 0 deletions client/src/com/vaadin/client/widgets/Grid.java
Expand Up @@ -8191,6 +8191,10 @@ public void setDetailsGenerator(DetailsGenerator detailsGenerator)
"Details generator may not be null");
}

for (Integer index : visibleDetails) {
setDetailsVisible(index, false);
}

this.detailsGenerator = detailsGenerator;

// this will refresh all visible spacers
Expand Down
Expand Up @@ -17,7 +17,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -79,16 +78,6 @@ public void applyRendererThenOpenDetails() {
details.getText().startsWith("Row: 1."));
}

@Test
public void openDetailsThenAppyRenderer() {
toggleDetailsFor(1);
selectMenuPath(SET_GENERATOR);

TestBenchElement details = getGridElement().getDetails(1);
assertTrue("Unexpected details content",
details.getText().startsWith("Row: 1."));
}

@Test
public void openHiddenDetailsThenScrollToIt() {
try {
Expand All @@ -114,8 +103,8 @@ public void errorUpdaterShowsErrorNotification() {
assertFalse("No notifications should've been at the start",
$(FixedNotificationElement.class).exists());

toggleDetailsFor(1);
selectMenuPath(SET_FAULTY_GENERATOR);
toggleDetailsFor(1);

ElementQuery<FixedNotificationElement> notification = $(FixedNotificationElement.class);
assertTrue("Was expecting an error notification here",
Expand All @@ -126,17 +115,15 @@ public void errorUpdaterShowsErrorNotification() {
getGridElement().getDetails(1).getText());
}

@Test
public void updaterStillWorksAfterError() {
@Test(expected = NoSuchElementException.class)
public void detailsClosedWhenResettingGenerator() {

selectMenuPath(SET_GENERATOR);
toggleDetailsFor(1);

selectMenuPath(SET_FAULTY_GENERATOR);
$(FixedNotificationElement.class).first().close();
selectMenuPath(SET_GENERATOR);

assertNotEquals(
"New details should've been generated even after error", "",
getGridElement().getDetails(1).getText());
getGridElement().getDetails(1);
}

@Test
Expand Down

0 comments on commit 3c9ec4f

Please sign in to comment.