Commit 54dedb15 authored by Vadim Nesmashnov's avatar Vadim Nesmashnov

RIHAKB-860, RIHA haldajana soovin, et RIHA manuaalsed funktsionaalsuse testid...

RIHAKB-860, RIHA haldajana soovin, et RIHA manuaalsed funktsionaalsuse testid oleks võimalikult suures ulatuses automatiseeritud
parent 2646b911
......@@ -10,6 +10,7 @@ import org.openqa.selenium.support.ui.Select;
import java.util.stream.Collectors;
import static ee.ria.riha.Timeouts.DISPLAY_ELEMENT_TIMEOUT;
import static ee.ria.riha.Timeouts.TABLE_SORT_TIMEOUT;
import static ee.ria.riha.context.ScenarioContext.*;
import static org.openqa.selenium.Keys.BACK_SPACE;
import static org.openqa.selenium.Keys.RETURN;
......@@ -43,6 +44,9 @@ public class InfosystemPage extends BasePage {
@FindBy(xpath = "//div[@id='dokumentatsioon']/app-producer-details-tech-docs/section/div/button")
private WebElement editDocumentationButton;
@FindBy(xpath = "//div[@id='andmed']/app-producer-details-objects/section/div/button")
private WebElement editDataButton;
@FindBy(xpath = "//div[@id='kontaktid']/app-producer-details-contacts/section/div[2]/table/tr/td[2]/span")
private WebElement contactNameSpan;
......@@ -70,6 +74,12 @@ public class InfosystemPage extends BasePage {
@FindBy(css = "app-producer-details-tech-docs table")
private WebElement techDocTable;
@FindBy(xpath = "//div[@id='andmed']/app-producer-details-objects/section/div[2]/div/table")
private WebElement dataObjectsTable;
@FindBy(xpath = "//div[@id='andmed']/app-producer-details-objects/section/div[2]/div[2]/table")
private WebElement dataUrlsTable;
@FindBy(tagName = "ngb-modal-window")
private WebElement modalContainer;
......@@ -200,15 +210,20 @@ public class InfosystemPage extends BasePage {
modalContainer.findElement(By.cssSelector(".btn-secondary:nth-child(2)")).click();
}
public void clickEditDataButton() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, editDataButton, "editDataButton");
editDataButton.click();
}
public void enterNewTechnicalDocumentationLink(String url, String name) {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, modalContainer, "modalContainer");
modalContainer.findElement(By.id("url")).sendKeys(url);
modalContainer.findElement(By.id("linkName")).sendKeys(name);
Select select = new Select(modalContainer.findElement(By.id("linkType")));
select.selectByValue("DOC_TYPE_OTHER");
wait.sleep(10000);
WebElement linkTypeElement = modalContainer.findElement(By.id("linkType"));
linkTypeElement.click();
new Select(linkTypeElement).selectByValue("DOC_TYPE_OTHER");
modalContainer.findElement(By.cssSelector(".col-12 > .btn")).click();
modalContainer.findElement(By.cssSelector(".btn-success")).click();
......@@ -216,10 +231,84 @@ public class InfosystemPage extends BasePage {
public String getTechDocUrls() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, techDocTable, "techDocTable");
wait.sleep(TABLE_SORT_TIMEOUT);
return techDocTable.findElements(By.cssSelector(".name")).stream()
.map(td -> td.findElement(By.tagName("a")))
.map(WebElement::getText)
.collect(Collectors.joining(","));
}
public void removeLinkToTechnicalDocumentation(String name) {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, modalContainer, "modalContainer");
WebElement techDocLinkDiv = modalContainer.findElement(By.className("expandable-blocks"))
.findElements(By.className("expandable-block"))
.stream()
.filter(div -> div.findElement(By.tagName("a")).getText().equals(name))
.findFirst().get();
techDocLinkDiv.findElement(By.className("btn-danger")).click();
modalContainer.findElement(By.cssSelector(".btn-success")).click();
}
public void addDataObjectFileNadUrlToInfosystem(String dataObject, String url, String urlName) {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, modalContainer, "modalContainer");
//add data object
modalContainer.findElement(By.id("object")).sendKeys(dataObject);
modalContainer.findElement(By.cssSelector(".col-2 > .btn")).click();
//add url
modalContainer.findElement(By.id("url")).sendKeys(url);
modalContainer.findElement(By.id("name")).sendKeys(urlName);
modalContainer.findElement(By.cssSelector(".col-12 > .btn")).click();
modalContainer.findElement(By.cssSelector(".btn-success")).click();
}
public String getDataObjects() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, dataObjectsTable, "dataObjectsTable");
wait.sleep(TABLE_SORT_TIMEOUT);
return dataObjectsTable.findElements(By.tagName("tr"))
.stream()
.map(tr -> tr.findElement(By.cssSelector("td:nth-child(2)")))
.map(WebElement::getText)
.collect(Collectors.joining(","));
}
public String getDataUrls() {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, dataUrlsTable, "dataUrlsTable");
wait.sleep(TABLE_SORT_TIMEOUT);
return dataUrlsTable.findElements(By.tagName("tr"))
.stream()
.map(tr -> tr.findElement(By.cssSelector("td:nth-child(2) > a")))
.map(WebElement::getText)
.collect(Collectors.joining(","));
}
public void removeDataObjectAndUrl(String dataObject, String urlName) {
wait.forElementToBeDisplayed(DISPLAY_ELEMENT_TIMEOUT, modalContainer, "modalContainer");
//remove data object
WebElement dataObjectTr = modalContainer.findElement(By.cssSelector(".details-list-table:nth-child(1)"))
.findElements(By.tagName("tr"))
.stream()
.filter(tr -> tr.findElement(By.cssSelector("td:nth-child(2)")).getText().equals(dataObject))
.findFirst().get();
dataObjectTr.findElement(By.className("btn-danger")).click();
//remove url
WebElement dataUrlTr = modalContainer.findElement(By.cssSelector(".dataTables_wrapper:nth-child(4) > .details-list-table"))
.findElements(By.tagName("tr"))
.stream()
.filter(tr -> tr.findElement(By.cssSelector("td:nth-child(2) > a")).getText().equals(urlName))
.findFirst().get();
dataUrlTr.findElement(By.className("btn-danger")).click();
modalContainer.findElement(By.cssSelector(".btn-success")).click();
}
}
......@@ -38,6 +38,21 @@ public class InfosystemPageSteps {
infosystemPage.clickEditDocumentationButton();
}
@And("InfosystemPage: user clicks on 'edit data' button")
public void userClicksOnEditDataButton() {
infosystemPage.clickEditDataButton();
}
@And("InfosystemPage: user adds data object {string} and url {string} - {string} to infosystem")
public void userAddsDataObjecFileAndUrlToInfosystem(String dataObject, String url, String urlName) {
infosystemPage.addDataObjectFileNadUrlToInfosystem(dataObject, url, urlName);
}
@And("InfosystemPage: user removes data object {string} and url {string}")
public void userRemovesDataObjectAndUrl(String dataObject, String urlName) {
infosystemPage.removeDataObjectAndUrl(dataObject, urlName);
}
@And("InfosystemPage: user changes general description by adding {string} to all fields")
public void userChangesGeneralDescription(String suffix) {
infosystemPage.changeGeneralDescription(suffix);
......@@ -63,6 +78,11 @@ public class InfosystemPageSteps {
infosystemPage.enterNewTechnicalDocumentationLink(url, name);
}
@And("InfosystemPage: user removes link to technical documentation with name {string}")
public void userRemovesLinkToTechnicalDocumentation(String name) {
infosystemPage.removeLinkToTechnicalDocumentation(name);
}
@And("InfosystemPage: user enters new topic {string}")
public void userEntersNewTopic(String topic) {
infosystemPage.enterNewTopic(topic);
......@@ -94,6 +114,13 @@ public class InfosystemPageSteps {
infosystemPage.getTechDocUrls().contains(linkName));
}
@Then("InfosystemPage: link to technical documentation with name {string} not present in 'documentation' block")
public void linkToTechnicalDocumentationNotPresentInDocBlock(String linkName) {
assertFalse("Documentation block have documentation link " + linkName,
Stream.of(infosystemPage.getTechDocUrls().split(","))
.anyMatch(techDocUrl -> techDocUrl.equalsIgnoreCase(linkName)));
}
@Then("InfosytemPage: {string} topic is not present in associated topics list")
public void topicIsNotPresentInAssociatedTopicsList(String topic) {
assertFalse("Associated topic list contains topic " + topic,
......@@ -101,6 +128,21 @@ public class InfosystemPageSteps {
.anyMatch(associatedTopic -> associatedTopic.equalsIgnoreCase(topic)));
}
@Then("InfosystemPage: data object {string} and url {string} present in 'data' block")
public void dataObjectFileAndUrlPresentInDataBlock(String dataObject, String urlName) {
assertTrue("Data block doesn't contain data object " + dataObject, infosystemPage.getDataObjects().contains(dataObject));
assertTrue("Data block doesn't contain url " + urlName, infosystemPage.getDataUrls().contains(urlName));
}
@Then("InfosystemPage: data object {string} and url {string} not present in 'data' block")
public void dataObjectFileAndUrlNotPresentInDataBlock(String dataObject, String urlName) {
assertFalse("Data block contains data object " + dataObject,
Stream.of(infosystemPage.getDataObjects().split(",")).anyMatch(obj -> obj.equalsIgnoreCase(dataObject)));
assertFalse("Data block contains url " + urlName,
Stream.of(infosystemPage.getDataUrls().split(",")).anyMatch(url -> url.equalsIgnoreCase(urlName)));
}
@Then("InfosytemPage: infosystem creation purpose is {string}")
public void infosystemCreationPurposeIs(String purpose) {
assertTrue("Infosystem creation purpose is not " + purpose, purpose.equalsIgnoreCase(infosystemPage.getPurposeText()));
......
......@@ -39,8 +39,17 @@ Feature: My organization infosystems page functionality
And InfosystemPage: user enters new technical documentation link "https://www.riha.ee" with name "RIHA veebileht"
Then InfosystemPage: link to technical documentation with name "RIHA veebileht" presents in 'documentation' block
And InfosystemPage: user clicks on 'edit documentation' button
# And InfosystemPage: user removes link to technical documentation with descr. "RIHA veebileht"
# Then InfosystemPage: link to technical documentation with name "RIHA veebileht" not present in 'documentation' block
And InfosystemPage: user removes link to technical documentation with name "RIHA veebileht"
Then InfosystemPage: link to technical documentation with name "RIHA veebileht" not present in 'documentation' block
Scenario: User can add infosystem data (RIHAKB-356)
Given MyInfosystemsPage: user select "riha-test" infosystem
And InfosystemPage: user clicks on 'edit data' button
And InfosystemPage: user adds data object "Minu andmeobjekti" and url "https://www.riha.ee" - "RIHA testimine" to infosystem
Then InfosystemPage: data object "Minu andmeobjekti" and url "RIHA testimine" present in 'data' block
And InfosystemPage: user clicks on 'edit data' button
And InfosystemPage: user removes data object "Minu andmeobjekti" and url "RIHA testimine"
Then InfosystemPage: data object "Minu andmeobjekti" and url "RIHA testimine" not present in 'data' block
Scenario: User can add contact to infosystem (RIHAKB-357)
Given MyInfosystemsPage: user select "riha-test" infosystem
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment