Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ad77915f authored by Adolfo Han's avatar Adolfo Han Committed by rui rodrigues
Browse files

Check if the JSON file is downloaded

parent 0688dcea
No related branches found
No related tags found
No related merge requests found
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://www.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.comission-european</groupId>
<artifactId>pso-testing</artifactId>
......@@ -11,7 +11,7 @@
<maven.compiler.source.version>11</maven.compiler.source.version>
<maven.compiler.target.version>11</maven.compiler.target.version>
<maven-atf-reports.version>1.0.0</maven-atf-reports.version>
<playwrigh.version>1.43.0</playwrigh.version>
<playwright.version>1.43.0</playwright.version>
<cucumber.java.version>7.16.1</cucumber.java.version>
<cucumber.junit.version>7.16.1</cucumber.junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......@@ -64,21 +64,14 @@
</goals>
<configuration>
<projectName>PSO</projectName>
<!-- optional, per documentation set this to "true" to bypass generation of ATF Reports entirely, defaults to false if not specified -->
<skip>false</skip>
<!-- output directory for the generated report -->
<outputDirectory>${project.build.directory}</outputDirectory>
<!-- optional, defaults to outputDirectory if not specified -->
<inputDirectory>${project.build.directory}/cucumber-reports</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>**/*.json</param>
</jsonFiles>
<!-- optional, defaults to outputDirectory if not specified -->
<classificationDirectory>${project.build.directory}</classificationDirectory>
<!-- optional, adds a column on the reports with the name of the json (full name or substring after "-") used for the test, defaults to false -->
<showPlatform>false</showPlatform>
<!-- optional, set true to fail build on test failures -->
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
......@@ -105,7 +98,7 @@
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>${playwrigh.version}</version>
<version>${playwright.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
......
......@@ -12,6 +12,7 @@ public class UiSetup {
public static Scenario scenario;
private static Browser browser;
private static Page page;
private String suggestedFilename;
public static Page getPage() {
return page;
......@@ -48,4 +49,29 @@ public class UiSetup {
page.close();
browser.close();
}
<<<<<<< HEAD:src/main/java/framework/ui/helpers/UiSetup.java
=======
/**
* Returns a LocatorOptions object with the specified text filter.
*
* @param text The text to filter the locator by.
* @return LocatorOptions with the text filter applied.
*/
public static Page.LocatorOptions getLocatorOptionsWithText(String text) {
return new Page.LocatorOptions().setHasText(text);
}
/**
* Returns a Locator object that filters by the specified text.
*
* @param page The Playwright Page object.
* @param selector The CSS selector to locate the element.
* @param text The text to filter the locator by.
* @return Locator with the text filter applied.
*/
public static Locator getLocatorWithText(Page page, String selector, String text) {
return page.locator(selector).filter(new Locator.FilterOptions().setHasText(text));
}
>>>>>>> 0c1dc5c (Check if the JSON file is downloaded):src/main/java/framework/ui/UiSetup.java
}
package framework.ui.pages;
public class WizardPage {
private String suggestedFilename;
public void setSuggestedFilename(String suggestedFilename) {
this.suggestedFilename = suggestedFilename;
}
public String getSuggestedFilename() {
return suggestedFilename;
}
}
......@@ -53,4 +53,18 @@ Feature: Wizard
And the user selects a .tll file
And the file name is visible in the upload widget
When the user clicks the upload button from the Upload Shape
Then the Complete Person Form is displayed
\ No newline at end of file
Then the Complete Person Form is displayed
@TCW06 @SIMPL-1050
Scenario: Check if the JSON file is downloaded
Given the file selection dialog box is visible
And the user clicks the Upload button from the widget
And the user clicks the Choose file button
And the user selects a .tll file
And the file name is visible in the upload widget
When the user clicks the upload button from the Upload Shape
And the Complete Person Form is displayed
And the user fills in the Compliance Review Body Form
And the Save button is enabled
Then the user clicks the Save button
And the JSON file is downloaded
\ No newline at end of file
package stepDefinitions.ui.simplOpen;
import com.microsoft.playwright.Download;
import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;
<<<<<<< HEAD
import framework.ui.helpers.UiSetup;
=======
import framework.ui.UiSetup;
import framework.ui.pages.WizardPage;
>>>>>>> 201be9d (update)
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
......@@ -21,7 +27,7 @@ import static configuration.ui.data.simplOpen.Wizard.*;
public class WizardSteps {
private final Page page = UiSetup.getPage();
private Path downloadDir;
private WizardPage wizardPage = new WizardPage();
@Given("the user is on the SD Wizard")
public void theUserIsOnTheSDWizard() {
......@@ -140,8 +146,29 @@ public class WizardSteps {
@Then("the user clicks the Save button")
public void theUserClicksTheSaveButton() {
page.locator(SAVE_BUTTON).click();
Download download = page.waitForDownload(() -> {
page.locator(SAVE_BUTTON).click();
});
<<<<<<< HEAD
UiSetup.attachScreenshot();
=======
uiSetup.attachScreenshot();
wizardPage.setSuggestedFilename(download.suggestedFilename());
}
@And("the JSON file is downloaded")
public void theJSONFileIsDownloaded() {
String suggestedFilename = wizardPage.getSuggestedFilename();
if (!suggestedFilename.endsWith(".json")) {
throw new AssertionError("Downloaded file is not a JSON file: " + suggestedFilename);
}
if (!suggestedFilename.contains("Person-instance")) {
throw new AssertionError("Downloaded file name does not contain 'Person-instance': " + suggestedFilename);
}
>>>>>>> 0c1dc5c (Check if the JSON file is downloaded)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment