Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No issue: adding E2E missing javadoc #30072

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ backend: &backend
- 'core-web/pom.xml'
- 'dotCMS/src/main/webapp/html/**/!(*.{css,js})'
- 'dotcms-postman/**'
- 'e2e/**'
- 'dotCMS/!(src/main/webapp/html/)**'
- 'dotcms-integration/**'
- 'independent-projects/**'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.dotcms;

/*
This interface is here as a placeholder of non test code that is part of the dotcms-e2e module
Without something in main to compile tests will not run.
/**
* This interface is here as a placeholder of not test code that is part of the dotcms-e2e-java module
* Without something in main to compile tests will not run.
*
* @author vico
*/
public interface DummyInterface {
public void aMethod();
Expand Down
6 changes: 6 additions & 0 deletions e2e/dotcms-e2e-java/src/test/java/com/dotcms/e2e/E2eKeys.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.dotcms.e2e;

/**
* This class defines a set of constant keys used in the end-to-end tests for the dotCMS application.
* These keys are used to retrieve configuration values such as URLs, browser types, and user credentials.
*
* @author vico
*/
public class E2eKeys {

public static final String CI_KEY = "ci";
Expand Down
19 changes: 17 additions & 2 deletions e2e/dotcms-e2e-java/src/test/java/com/dotcms/e2e/E2eTestSuite.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
package com.dotcms.e2e;

import com.dotcms.e2e.test.ContentPagesTests;
import com.dotcms.e2e.test.ContentSearchTests;
import com.dotcms.e2e.test.LoginTests;
import com.dotcms.e2e.test.SiteLayoutContainersTests;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

/**
* This class defines a test suite for end-to-end tests in the dotCMS application.
* It uses JUnit 5's @Suite and @SelectClasses annotations to specify the test classes
* that should be included in the suite.
*
* To run this suite, simply execute:
* <pre>
* ./mvnw -pl :dotcms-e2e-java verify -De2e.test.skip=false -Dit.test=E2eTestSuite
* </pre>
*
* @author vico
*/
@Suite
@SelectClasses({
LoginTests.class/*,
LoginTests.class,
ContentPagesTests.class,
ContentSearchTests.class,
SiteLayoutContainersTests.class*/
SiteLayoutContainersTests.class
})
public class E2eTestSuite {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

import java.util.stream.Stream;

/**
* Enum representing different types of browsers.
*
* This enum provides a method to get a browser type from a string value.
*
* @author vico
*/
public enum BrowserType {

CHROMIUM, FIREFOX, WEBKIT;

/**
* Returns the BrowserType corresponding to the given string value.
*
* @param value the string representation of the browser type
* @return the BrowserType corresponding to the given value, or null if no match is found
*/
public static BrowserType fromString(final String value) {
return Stream.of(values()).filter(element -> element.name().equals(value)).findFirst().orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,123 @@

import java.util.function.Supplier;

/**
* Logger utility class for logging messages with different levels of severity.
*
* This class provides static methods to log info, warn, and error messages.
*
* @author vico
*/
public class Logger {

private Logger() {
}

/**
* Logs an info message.
*
* @param clazz the class from which the log is made
* @param message the message to log
*/
public static void info(final Class<?> clazz, final String message) {
final org.slf4j.Logger logger = LoggerFactory.getLogger(clazz);
logger.info(message);
}

/**
* Logs an info message.
*
* @param clazz the class from which the log is made
* @param message the supplier of the message to log
*/
public static void info(final Class<?> clazz, final Supplier<String> message) {
info(clazz, message.get());
}

/**
* Logs a warning message.
*
* @param clazz the class from which the log is made
* @param message the message to log
*/
public static void warn(final Class<?> clazz, final String message) {
final org.slf4j.Logger logger = LoggerFactory.getLogger(clazz);
logger.warn(message);
}

/**
* Logs a warning message.
*
* @param clazz the class from which the log is made
* @param message the supplier of the message to log
*/
public static void warn(final Class<?> clazz, final Supplier<String> message) {
warn(clazz, message.get());
}

/**
* Logs a warning message with a throwable.
*
* @param clazz the class from which the log is made
* @param message the message to log
* @param throwable the throwable to log
*/
public static void warn(final Class<?> clazz, final String message, final Throwable throwable) {
final org.slf4j.Logger logger = LoggerFactory.getLogger(clazz);
logger.warn(message, throwable);
}

/**
* Logs a warning message with a throwable.
*
* @param clazz the class from which the log is made
* @param message the supplier of the message to log
* @param throwable the throwable to log
*/
public static void warn(final Class<?> clazz, final Supplier<String> message, final Throwable throwable) {
warn(clazz, message.get(), throwable);
}

/**
* Logs an error message.
*
* @param clazz the class from which the log is made
* @param message the message to log
*/
public static void error(final Class<?> clazz, final String message) {
final org.slf4j.Logger logger = LoggerFactory.getLogger(clazz);
logger.error(message);
}

/**
* Logs an error message.
*
* @param clazz the class from which the log is made
* @param message the supplier of the message to log
*/
public static void error(final Class<?> clazz, final Supplier<String> message) {
error(clazz, message.get());
}

/**
* Logs an error message with a throwable.
*
* @param clazz the class from which the log is made
* @param message the message to log
* @param throwable the throwable to log
*/
public static void error(final Class<?> clazz, final String message, final Throwable throwable) {
final org.slf4j.Logger logger = LoggerFactory.getLogger(clazz);
logger.error(message, throwable);
}

/**
* Logs an error message with a throwable.
*
* @param clazz the class from which the log is made
* @param message the supplier of the message to log
* @param throwable the throwable to log
*/
public static void error(final Class<?> clazz, final Supplier<String> message, final Throwable throwable) {
error(clazz, message.get(), throwable);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.dotcms.e2e.page;

import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.options.AriaRole;

/**
* Page class for interacting with the Containers page.
*
* This class provides methods to fill the containers form, find a container by title,
* and execute workflow actions on a container.
*
* @author vico
*/
public class ContainersPage {

private final Page containersPage;

public ContainersPage(final Page containersPage) {
this.containersPage = containersPage;
}

/**
* Fills the containers form with the provided details.
*
* @param title the title of the container
* @param description the description of the container
* @param maxContents the maximum number of contents
* @param contentType the content type
* @param contentTypeCode the content type code
*/
public void fillContainersForm(final String title,
final String description,
final String maxContents,
final String contentType,
final String contentTypeCode) {
containersPage.getByTestId("title").fill(title);
containersPage.getByTestId("description").fill(description);
containersPage.getByTestId("max-contents").fill(maxContents);
containersPage.getByRole(AriaRole.TAB, new Page.GetByRoleOptions().setName("")).click();
containersPage.getByRole(AriaRole.MENUITEM,
new Page.GetByRoleOptions().setName(contentType)).click();
containersPage.getByRole(AriaRole.TAB, new Page.GetByRoleOptions().setName(contentType))
.click();
containersPage.getByTestId("2a3e91e4-fbbf-4876-8c5b-2233c1739b05")
.getByLabel("Editor content;Press Alt+F1").fill(contentTypeCode + "\n");
containersPage.getByTestId("saveBtn").click();
}

/**
* Finds a container by its title.
*
* @param containerTitle the title of the container to find
* @return the row ID of the container if found, otherwise an empty string
*/
public String findContainer(final String containerTitle) {
String rowId = "";

// Locate the table
Locator table = containersPage.locator("tbody"); // Adjust the selector if necessary

// Locate all rows within the table
Locator rows = table.locator("tr");
// Iterate through each row
int rowCount = rows.count();
for (int i = 0; i < rowCount; i++) {
Locator row = rows.nth(i);

// Locate all cells within the current row
Locator cells = row.locator("td");

// Check the content of each cell
int cellCount = cells.count();
for (int j = 0; j < cellCount; j++) {
String cellText = cells.nth(j).textContent().trim();
if (cellText.equals(containerTitle)) {
rowId = rows.nth(i).getAttribute("data-testrowid");
return rowId;
}
}
}
return rowId;
}

/**
* Executes a workflow action on a container.
*
* @param containerTitle the title of the container
* @param action the workflow action to execute
*/
public void executeContainerWorkflow(final String containerTitle, final String action) {
String rowId = findContainer(containerTitle);
containersPage.getByTestId(rowId)
.getByRole(AriaRole.BUTTON, new Locator.GetByRoleOptions().setName(" p")).click();
containersPage.getByRole(AriaRole.MENUITEM, new Page.GetByRoleOptions().setName(action))
.click();
if (action.equals("Delete")) {
containersPage.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Accept"))
.click();
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.dotcms.e2e.page;

/**
* Enum representing group entries for different menus and layouts.
* This enum provides constants for various group entries and a method to retrieve the group string.
*
* @author vico
*/
public enum GroupEntries {

CONTENT_MENU(":text('format_align_leftContentarrow_drop_up')"),
Expand All @@ -13,9 +19,9 @@ public enum GroupEntries {
}

/**
* Get the group entries
* Retrieves the group string.
*
* @return the group entries
* @return the group string
*/
public String getGroup() {
return group;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import com.dotcms.e2e.service.EnvironmentService;
import com.microsoft.playwright.Page;

/**
* Page class for interacting with the Login page.
*
* This class provides methods to perform login actions and switch the language of the login page.
*
* @author vico
*/
public class LoginPage {

private static final String USERNAME_LOCATOR = "input[id=inputtext]";
Expand All @@ -13,22 +20,26 @@ public class LoginPage {

private final Page loginPage;

/**
* Constructor
*
* @param loginPage the page object
*/
public LoginPage(final Page loginPage) {
this.loginPage = loginPage;
}

/**
* Logs in with the provided username and password.
*
* @param user the username
* @param password the password
*/
public void login(final String user, final String password) {
loginPage.locator(USERNAME_LOCATOR).fill(user);
loginPage.locator(PASSWORD_LOCATOR).click();
loginPage.locator(PASSWORD_LOCATOR).fill(password);
loginPage.getByTestId(LOGIN_BUTTON).click();
}

/**
* Logs in with the default username and password from environment properties.
*/
public void successfulLogin() {
final EnvironmentService environmentService = EnvironmentService.get();
login(
Expand All @@ -37,7 +48,7 @@ public void successfulLogin() {
}

/**
* Switch the language of the login page
* Switches the language of the login page.
*
* @param language the language to switch to
*/
Expand Down
Loading