Skip to content

Instantly share code, notes, and snippets.

@yabetancourt
Created December 29, 2022 20:14
Show Gist options
  • Save yabetancourt/d1761cdd8cfb8294b3e40ff08c3b2b64 to your computer and use it in GitHub Desktop.
Save yabetancourt/d1761cdd8cfb8294b3e40ff08c3b2b64 to your computer and use it in GitHub Desktop.
Testing visual components in vaadin
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.testbench.unit.SpringUIUnit4Test;
import cu.uclv.postgrade.Application;
import cu.uclv.postgrade.ui.view.course.program.CourseProgramListView;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(classes = {Application.class})
public class CourseProgramListViewTest extends SpringUIUnit4Test {
@Test
public void test() {
final CourseProgramListView courseProgramListView = navigate(CourseProgramListView.class);
Grid grid = $view(Grid.class).first();
Assertions.assertNotNull(grid.getLazyDataView().getItems());
LoggerFactory.getLogger("Test").info("hay " + grid.getLazyDataView().getItemCountEstimate());
}
@Test
public void test2() {
final CourseProgramListView courseProgramListView = navigate(CourseProgramListView.class);
Button button = $view(Button.class).withPropertyValue(Button::getText, "Crear")
.single();
Assertions.assertNotNull(button);
}
@Override
public boolean printTree() {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment