Skip to content

Commit

Permalink
Enhance UI testing module (#4083)
Browse files Browse the repository at this point in the history
* ABAP - support inline statements

Signed-off-by: Iliyan Velichkov <[email protected]>

* add comment

Signed-off-by: Iliyan Velichkov <[email protected]>

* roolback DatabaseResultSetHelper.java

Signed-off-by: Iliyan Velichkov <[email protected]>

* enhance UI testing module

Signed-off-by: Iliyan Velichkov <[email protected]>

---------

Signed-off-by: Iliyan Velichkov <[email protected]>
  • Loading branch information
iliyan-velichkov authored Jun 28, 2024
1 parent 97e9408 commit 71fe834
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
-->
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" ng-app="welcome" ng-controller="welcomeCtrl">
<html lang="en" ng-app="welcome" ng-controller="welcomeCtrl" xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" sizes="any" href="data:;base64,iVBORw0KGgo=" />
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="data:;base64,iVBORw0KGgo=" rel="icon" sizes="any" />
<title dg-view-title></title>
<script type="text/javascript" src="services/welcome-view.js"></script>
<script type="text/javascript" src="/services/js/resources-core/services/loader.js?id=ide-view-js"></script>
<script type="text/javascript" src="js/welcome.js"></script>
<link type="text/css" rel="stylesheet" href="/services/js/resources-core/services/loader.js?id=ide-view-css" />
<script src="services/welcome-view.js" type="text/javascript"></script>
<script src="/services/js/resources-core/services/loader.js?id=ide-view-js" type="text/javascript"></script>
<script src="js/welcome.js" type="text/javascript"></script>
<link href="/services/js/resources-core/services/loader.js?id=ide-view-css" rel="stylesheet" type="text/css" />
<theme></theme>
</head>

Expand All @@ -32,7 +32,7 @@
<div class="fd-section__header">
<h3 class="fd-section__title">Welcome to Eclipse Dirigible™</h3>
</div>
<p class="fd-text"><a href="http://www.dirigible.io" target="_blank" class="fd-link">Eclipse Dirigible™</a> is a
<p class="fd-text"><a class="fd-link" href="http://www.dirigible.io" target="_blank">Eclipse Dirigible™</a> is a
Cloud
Development
Platform providing development tools and runtime environment. It supports full development
Expand All @@ -45,16 +45,16 @@ <h3 class="fd-section__title">Welcome to Eclipse Dirigible™</h3>
<h4 class="fd-panel__title">Create a new project</h4>
<fd-toolbar dg-type="transparent" no-bottom-border="true" style="min-width: 30%;">
<fd-toolbar-spacer></fd-toolbar-spacer>
<fd-input type="text" id="searchInput" ng-model="search.text" ng-change="search.applyFilter()"
placeholder="Search tempate by name">
<fd-input id="searchInput" ng-change="search.applyFilter()" ng-model="search.text" placeholder="Search template by name"
type="text">
</fd-input>
</fd-toolbar>
</div>
<div role="region" aria-labelledby="jhqDKYrt" class="fd-panel__content">
<div aria-labelledby="jhqDKYrt" class="fd-panel__content" role="region">
<div class="fd-container">
<div class="fd-row">
<span ng-if="templates.length && !filteredTemplates.length">No templates found.</span>
<div ng-if="templates.length" class="fd-col fd-col--12 fd-col-md--6 fd-col-lg--4 fd-col-xl--3"
<div class="fd-col fd-col--12 fd-col-md--6 fd-col-lg--4 fd-col-xl--3" ng-if="templates.length"
ng-repeat="template in filteredTemplates | startFrom:(currentPage-1)*pageSize | limitTo:pageSize">
<fd-card card-type="object">
<fd-card-header ng-click="openCreateProjectDialog(template)">
Expand All @@ -80,20 +80,20 @@ <h4 class="fd-panel__title">Create a new project</h4>
</div>
</div>
<br>
<fd-pagination total-items="filteredTemplates.length" items-per-page="pageSize" current-page="currentPage"
display-total-items="true"></fd-pagination>
<fd-pagination current-page="currentPage" display-total-items="true" items-per-page="pageSize"
total-items="filteredTemplates.length"></fd-pagination>
</div>
</div>
<br>
<p class="fd-text">You can model the database
schema of your web application, create server-side scripting services by using the <a
href="http://www.dirigible.io/api" target="_blank" class="fd-link">Enterprise
class="fd-link" href="http://www.dirigible.io/api" target="_blank">Enterprise
Javascript
API</a> or just design your web pages in HTML5 by using your favorite client-side framework.
<br>
All source code is licensed under the <a href="https://www.eclipse.org/legal/epl-v20.html" target="_blank"
class="fd-link">Eclipse Public License - v 2.0</a> and
maintained at <a href="https://github.com/eclipse/dirigible" target="_blank" class="fd-link">GitHub</a>.
All source code is licensed under the <a class="fd-link" href="https://www.eclipse.org/legal/epl-v20.html"
target="_blank">Eclipse Public License - v 2.0</a> and
maintained at <a class="fd-link" href="https://github.com/eclipse/dirigible" target="_blank">GitHub</a>.
</p>
</section>

Expand Down
9 changes: 7 additions & 2 deletions tests/tests-framework/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand All @@ -25,6 +25,11 @@
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.dirigible</groupId>
<artifactId>dirigible-commons-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.dirigible.integration.tests.ui;
package org.eclipse.dirigible.tests;

import org.eclipse.dirigible.tests.framework.Browser;
import org.eclipse.dirigible.tests.framework.HtmlAttribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@
*
* SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.dirigible.integration.tests.ui;
package org.eclipse.dirigible.tests;

import org.eclipse.dirigible.commons.config.DirigibleConfig;
import org.eclipse.dirigible.tests.framework.Browser;
import org.eclipse.dirigible.tests.framework.HtmlAttribute;
import org.eclipse.dirigible.tests.framework.HtmlElementType;
import org.eclipse.dirigible.tests.restassured.RestAssuredExecutor;
import org.eclipse.dirigible.tests.util.SleepUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;

@Lazy
@Component
public class Dirigible {

private static final Logger LOGGER = LoggerFactory.getLogger(Dirigible.class);
public class IDE {
private static final Logger LOGGER = LoggerFactory.getLogger(IDE.class);

private static final String LOGIN_PAGE_TITLE = "Please sign in";
private static final String ROOT_PATH = "/";
Expand All @@ -34,16 +37,20 @@ public class Dirigible {
private static final String SIGN_IN_BUTTON_TEXT = "Sign in";

private final Browser browser;
private final RestAssuredExecutor restAssuredExecutor;

private final String username;
private final String password;

@Autowired
public Dirigible(Browser browser) {
this(browser, DirigibleConfig.BASIC_ADMIN_USERNAME.getFromBase64Value(), DirigibleConfig.BASIC_ADMIN_PASS.getFromBase64Value());
public IDE(Browser browser, RestAssuredExecutor restAssuredExecutor) {
this(browser, restAssuredExecutor, DirigibleConfig.BASIC_ADMIN_USERNAME.getFromBase64Value(),
DirigibleConfig.BASIC_ADMIN_PASS.getFromBase64Value());
}

public Dirigible(Browser browser, String username, String password) {
public IDE(Browser browser, RestAssuredExecutor restAssuredExecutor, String username, String password) {
this.browser = browser;
this.restAssuredExecutor = restAssuredExecutor;
this.username = username;
this.password = password;
}
Expand Down Expand Up @@ -76,9 +83,34 @@ public void login() {
login(true);
}

public DirigibleWorkbench openWorkbench() {
public Workbench openWorkbench() {
browser.clickElementByAttributeValue(HtmlElementType.ANCHOR, HtmlAttribute.TITLE, "Workbench");
return new DirigibleWorkbench(browser);
return new Workbench(browser);
}

public void assertPublishingProjectMessage(String projectName) {
String publishingMessage = "Publishing '/" + projectName + "'...";
assertStatusBarMessage(publishingMessage);
}

public void assertStatusBarMessage(String expectedMessage) {
browser.assertElementExistsByTypeAndTextPattern(HtmlElementType.SPAN, expectedMessage);
}

public void assertPublishedProjectMessage(String projectName) {
String publishedMessage = "Published '/" + projectName + "'";
assertStatusBarMessage(publishedMessage);
}

public void assertJSHttpResponse(String projectName, String fileRelativePath, int expectedStatusCode, String expectedBody) {
String path = "/services/js/" + projectName + "/" + fileRelativePath;
restAssuredExecutor.execute( //
() -> given().when()
.get(path)
.then()
.statusCode(expectedStatusCode)
.body(containsString(expectedBody)),
username, password);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2024 Eclipse Dirigible contributors
*
* All rights reserved. This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.dirigible.tests;

import org.eclipse.dirigible.tests.framework.Browser;
import org.eclipse.dirigible.tests.framework.HtmlAttribute;
import org.eclipse.dirigible.tests.framework.HtmlElementType;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Lazy
@Component
public class WelcomeView {

private final Browser browser;

public WelcomeView(Browser browser) {
this.browser = browser;
}

public void expandProject(String projectName) {
browser.doubleClickOnElementContainingText(HtmlElementType.ANCHOR, projectName);
}

public void openFile(String fileName) {
browser.doubleClickOnElementContainingText(HtmlElementType.ANCHOR, fileName);
}

public void searchForTemplate(String template) {
browser.enterTextInElementByAttributePattern(HtmlElementType.INPUT, HtmlAttribute.PLACEHOLDER, "Search template by name", template);
}

public void selectTemplate(String templateTitle) {
browser.clickOnElementContainingText(HtmlElementType.ANCHOR, templateTitle);
}

public void typeProjectName(String projectName) {
browser.enterTextInElementByAttributePattern(HtmlElementType.INPUT, HtmlAttribute.ID, "projectName", projectName);
}

public void typeFileName(String fileName) {
browser.enterTextInElementByAttributePattern(HtmlElementType.INPUT, HtmlAttribute.ID, "fileName", fileName);
}

public void confirmTemplate() {
browser.clickOnElementContainingText(HtmlElementType.BUTTON, "Ok");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.dirigible.integration.tests.ui;
package org.eclipse.dirigible.tests;

import org.eclipse.dirigible.tests.framework.Browser;
import org.eclipse.dirigible.tests.framework.HtmlAttribute;
Expand All @@ -17,11 +17,11 @@

@Lazy
@Component
public class DirigibleWorkbench {
public class Workbench {

private final Browser browser;

DirigibleWorkbench(Browser browser) {
public Workbench(Browser browser) {
this.browser = browser;
}

Expand All @@ -34,7 +34,22 @@ public void openFile(String fileName) {
}

public void publishAll() {
browser.clickElementByAttributePattern(HtmlElementType.BUTTON, HtmlAttribute.TITLE, "Publish all");
clickPublishAll();
browser.assertElementExistsByTypeAndTextPattern(HtmlElementType.SPAN, "Published all projects in");
}

public void clickPublishAll() {
browser.clickElementByAttributePattern(HtmlElementType.BUTTON, HtmlAttribute.TITLE, "Publish all");
}

public WelcomeView openWelcomeView() {
focusOnOpenedFile("Welcome");
return new WelcomeView(browser);
}

public WelcomeView focusOnOpenedFile(String fileName) {
browser.clickOnElementContainingText(HtmlElementType.ANCHOR, fileName);
return new WelcomeView(browser);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface Browser {

void doubleClickOnElementContainingText(HtmlElementType htmlElementType, String text);

void clickOnElementContainingText(HtmlElementType htmlElementType, String text);

void clickElementByAttributePattern(HtmlElementType htmlElementType, HtmlAttribute htmlAttribute, String pattern);

void assertElementExistsByTypeAndTextPattern(HtmlElementType htmlElementType, String textPattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public enum HtmlAttribute {
ID("id"), //
TYPE("type"), //
PLACEHOLDER("placeholder"), //
TITLE("title");

private final String attribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum HtmlElementType {
IFRAME("iframe"), //
SPAN("span"), //
HEADER3("h3"), //
DIV("div"), //
FD_MESSAGE_PAGE_TITLE("fd-message-page-title");

private final String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ public void doubleClickOnElementContainingText(HtmlElementType elementType, Stri
handleElementInAllFrames(element, e -> e.doubleClick());
}

@Override
public void clickOnElementContainingText(HtmlElementType elementType, String text) {
String textPattern = Pattern.quote(text);
SelenideElement element = getElementByAttributeAndTextPattern(elementType, textPattern);
handleElementInAllFrames(element, e -> e.click());
}

@Override
public void clickElementByAttributePattern(HtmlElementType elementType, HtmlAttribute attribute, String pattern) {
SelenideElement element = getElementByAttributePattern(elementType, attribute, pattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.restassured.authentication.AuthenticationScheme;
import io.restassured.filter.log.RequestLoggingFilter;
import io.restassured.filter.log.ResponseLoggingFilter;
import org.eclipse.dirigible.commons.config.DirigibleConfig;
import org.eclipse.dirigible.tests.DirigibleTestTenant;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.annotation.Lazy;
Expand Down Expand Up @@ -81,6 +82,12 @@ public void execute(CallableNoResultAndNoException callable, String host) {
}
}

public void execute(CallableNoResultAndNoException callable) {
String user = DirigibleConfig.BASIC_ADMIN_USERNAME.getFromBase64Value();
String pass = DirigibleConfig.BASIC_ADMIN_PASS.getFromBase64Value();
this.execute(callable, "localhost", user, pass);
}

public void execute(CallableNoResultAndNoException callable, String user, String password) {
this.execute(callable, "localhost", user, password);
}
Expand Down
Loading

0 comments on commit 71fe834

Please sign in to comment.