use of com.github.mvysny.kaributesting.v8.LocatorJ._find in project ANNIS by korpling.
the class AnnisUITest method openSourceWindow.
@Test
void openSourceWindow() {
UI.getCurrent().getNavigator().navigateTo("");
_click(_get(Button.class, spec -> spec.withCaption("Help us make ANNIS better!")));
// Check that the windows has opened
assertNotNull(_get(Window.class, spec -> spec.withCaption("Help us make ANNIS better!")));
// Close the window again
Button btClose = _get(Button.class, spec -> spec.withCaption("Close"));
assertNotNull(btClose);
_click(btClose);
// Window should be closed
assertEquals(0, _find(Window.class, spec -> spec.withCaption("Help us make ANNIS better!")).size());
}
use of com.github.mvysny.kaributesting.v8.LocatorJ._find in project ANNIS by korpling.
the class AnnisUITest method shareSingleResult.
@Test
void shareSingleResult() throws Exception {
executeTokenSearch("pcc2", 399, 2);
// Activate the share window
SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
_click(_get(resultPanel, Button.class, spec -> spec.withPredicate((b) -> "Share match reference".equals(b.getDescription()))));
// Get the window which shows all the different links
Window shareWindow = _get(Window.class, spec -> spec.withCaption("Match reference link"));
TextArea linkTextField = _get(shareWindow, TextArea.class, spec -> spec.withCaption("Link for publications"));
URI shortUrl = URI.create(linkTextField.getValue());
List<NameValuePair> paramsShortUrl = URLEncodedUtils.parse(shortUrl.getQuery(), StandardCharsets.UTF_8);
assertEquals(1, paramsShortUrl.size());
assertEquals("id", paramsShortUrl.get(0).getName());
// Un-shorten the URL and examine its parts
Optional<URI> originalUrl = ui.getUrlShortener().unshorten(UUID.fromString(paramsShortUrl.get(0).getValue()));
assertTrue(originalUrl.isPresent());
if (originalUrl.isPresent()) {
List<NameValuePair> paramsOriginalUrl = URLEncodedUtils.parse(originalUrl.get().getRawQuery(), StandardCharsets.UTF_8);
assertFalse(paramsOriginalUrl.isEmpty());
assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_LEFT.equals(p.getName()) && "5".equals(p.getValue())));
assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_RIGHT.equals(p.getName()) && "5".equals(p.getValue())));
assertFalse(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_INSTANCE.equals(p.getName())));
assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_SEARCH_INTERFACE.equals(p.getName()) && p.getValue().startsWith("http://localhost:8080#_q=")));
assertTrue(paramsOriginalUrl.stream().anyMatch(p -> EmbeddedVisUI.KEY_MATCH.equals(p.getName()) && "pcc2/11299#tok_1".equals(p.getValue())));
}
}
use of com.github.mvysny.kaributesting.v8.LocatorJ._find in project ANNIS by korpling.
the class AnnisUITest method openVisualizerPcc2.
@Test
void openVisualizerPcc2() throws Exception {
executeTokenSearch("pcc2", 399, 2);
SingleResultPanel resultPanel = _find(SingleResultPanel.class).get(0);
_get(resultPanel, KWICComponent.class);
// Open the coreference visualizer and check that IFrame component is loaded
Button btOpenCorefVisualizer = _get(resultPanel, Button.class, spec -> spec.withCaption("coreference (discourse)"));
_click(btOpenCorefVisualizer);
awaitCondition(120, () -> !_find(resultPanel, AutoHeightIFrame.class).isEmpty());
AutoHeightIFrame iframe = _get(resultPanel, AutoHeightIFrame.class, spec -> spec.withCount(1));
assertTrue(iframe.getState().getUrl().startsWith("/vis-iframe-res/"));
// Close the visualizer again
_click(btOpenCorefVisualizer);
awaitCondition(60, () -> _find(resultPanel, AutoHeightIFrame.class).isEmpty());
// Open a HTML visualizer
Button btOpenHtmlVisualizer = _get(resultPanel, Button.class, spec -> spec.withCaption("information structure (document)"));
_click(btOpenHtmlVisualizer);
awaitCondition(240, () -> !_find(resultPanel, Panel.class, spec -> spec.withPredicate(p -> p.getStyleName().startsWith("annis-wrapped-htmlvis-"))).isEmpty());
Panel htmlPanel = _get(resultPanel, Panel.class, spec -> spec.withPredicate(p -> p.getStyleName().startsWith("annis-wrapped-htmlvis-")));
Label htmlLabel = _get(htmlPanel, Label.class);
assertEquals(ContentMode.HTML, htmlLabel.getContentMode());
assertTrue(htmlLabel.getValue().startsWith("<span class=\"tok\" style=\" color:\" >Feigenblatt<"));
}
use of com.github.mvysny.kaributesting.v8.LocatorJ._find in project ANNIS by korpling.
the class AnnisUITest method searchPccCorpusMatches.
@Test
void searchPccCorpusMatches() throws Exception {
selectCorpus("pcc2");
// Set the query and submit query
_get(AqlCodeEditor.class).getPropertyDataSource().setValue("URL");
MockVaadin.INSTANCE.clientRoundtrip();
awaitCondition(5, () -> "URL".equals(ui.getQueryState().getAql().getValue()));
awaitCondition(5, () -> "Valid query, click on \"Search\" to start searching.".equals(ui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus()));
Button searchButton = _get(Button.class, spec -> spec.withCaption("Search"));
_click(searchButton);
// Wait until the count is displayed
String expectedStatus = "1 match\nin 1 document";
awaitCondition(60, () -> expectedStatus.equals(ui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus()), () -> "Waited for status \"" + expectedStatus + "\" but was \"" + ui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus() + "\"");
// Test that the special corpus result panel visualizer is shown
awaitCondition(30, () -> _find(SingleCorpusResultPanel.class).size() == 1);
List<SingleCorpusResultPanel> results = _find(SingleCorpusResultPanel.class);
assertNotNull(_get(results.get(0), Label.class, spec -> spec.withValue("Path: pcc2")));
assertNotNull(_get(results.get(0), Button.class, spec -> spec.withPredicate(b -> b.getIcon() == VaadinIcons.INFO_CIRCLE)));
// / The standard SingleResult panel should not be visible
assertEquals(0, _find(SingleResultPanel.class).size());
}
use of com.github.mvysny.kaributesting.v8.LocatorJ._find in project ANNIS by korpling.
the class EmbeddedVisTest method regression509.
@Test
void regression509() throws Exception {
EmbeddedVisUI ui = (EmbeddedVisUI) UI.getCurrent();
MockRequest request = MockVaadinKt.getMock(VaadinRequest.getCurrent());
request.setParameter("embedded_ns", "exmaralda");
request.setParameter("embedded_instance", "");
request.setParameter("embedded_match", "pcc2/11299#tok_1");
request.setParameter("embedded_left", "5");
request.setParameter("embedded_right", "5");
request.setParameter("embedded_interface", "http://localhost:5712/#_q=dG9r&ql=aql&_c=cGNjMg&cl=5&cr=5&s=0&l=10&m=0");
ui.attachToPath("/embeddedvis/grid", VaadinRequest.getCurrent());
awaitCondition(30, () -> !_find(Link.class, spec -> spec.withCaption("Show in ANNIS search interface")).isEmpty());
Link link = _get(Link.class, spec -> spec.withCaption("Show in ANNIS search interface"));
assertEquals("dontprint", link.getStyleName());
}
Aggregations