Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into qu-auto/SORQA-482
Browse files Browse the repository at this point in the history
  • Loading branch information
hms-sgent committed Sep 13, 2022
2 parents cd9ad35 + 9eb0684 commit 3623546
Show file tree
Hide file tree
Showing 20 changed files with 301 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class EditCasePersonPage {
public static final By SEE_CASES_FOR_THIS_PERSON_BUTTON = By.id("See cases for this person");
public static final By PASSPORT_NUMBER_INPUT = By.cssSelector("#passportNumber");
public static final By NATIONAL_HEALTH_ID_INPUT = By.cssSelector("#nationalHealthId");
public static final By COUNTRY_OF_BIRTH_LABEL_DE = By.xpath("//div[text()=\"Geburtsland\"]");
public static final By CITIZENSHIP_LABEL_DE =
By.xpath("//div[text()=\"Staatsb\u00FCrgerschaft\"]");
public static final By EDUCATION_COMBOBOX =
By.cssSelector("[id='educationType'] [class='v-filterselect-button']");
public static final By COMMUNITY_CONTACT_PERSON_INPUT = By.cssSelector("#details");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class EditEventPage {
By.cssSelector("#tab-events-eventparticipants span");
public static final By UUID_EDIT_EVENT = By.cssSelector("div[location='uuid']");
public static final By FIRST_EVENT_PARTICIPANT = By.xpath("//table/tbody/tr[1]/td[1]//a");
public static final By FIRST_EVENT_PARTICIPANT_AFTER_IMPORT =
By.xpath("//table/tbody/tr[1]/td[2]//a");
public static final By FIRST_RESULT_IN_EVENT_PARTICIPANT_TABLE = By.xpath("//td//a");
public static final By FIRST_ARCHIVED_EVENT_PARTICIPANT = By.xpath("//table/tbody/tr[1]/td[1]");
public static final By EVENT_ACTIONS_TAB = By.cssSelector("#tab-events-eventactions span");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -1074,6 +1075,20 @@ public CaseDirectorySteps(
FilesHelper.waitForFileToDownload(fileName, 20);
FilesHelper.deleteFile(fileName);
});
When(
"I check if citizenship and country of birth is not present in Detailed Case export file",
() -> {
String fileName = "sormas_f\u00E4lle_" + LocalDate.now() + "_.csv";
String[] headers = parseDetailedCaseExportHeaders(userDirPath + "/downloads/" + fileName);
FilesHelper.deleteFile(fileName);
softly.assertFalse(
Arrays.stream(headers).anyMatch("citizenship"::equals),
"Citizenship is present in file");
softly.assertFalse(
Arrays.stream(headers).anyMatch("countryOfBirth"::equals),
"Country of birth is present in file");
softly.assertAll();
});
When(
"I check that ([^\"]*) is visible in Pick or Create Person popup for De",
(String option) -> {
Expand Down Expand Up @@ -1373,4 +1388,24 @@ public static void writeCSVFromMapDetailedCase(
log.error("IOException csvWriter: ", e);
}
}

public String[] parseDetailedCaseExportHeaders(String fileName) {
List<String[]> r = null;
String[] values = new String[] {};
CSVParser csvParser = new CSVParserBuilder().withSeparator(',').build();
try (CSVReader reader =
new CSVReaderBuilder(new FileReader(fileName)).withCSVParser(csvParser).build()) {
r = reader.readAll();
} catch (IOException e) {
log.error("IOException parseDetailedCaseExportHeaders: {}", e.getCause());
} catch (CsvException e) {
log.error("CsvException parseDetailedCaseExportHeaders: {}", e.getCause());
}
try {
values = r.get(1);
} catch (NullPointerException e) {
log.error("Null pointer exception parseDetailedCaseExportHeaders: {}", e.getCause());
}
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public CaseImportExportSteps(
When(
"I click on the Detailed Case Export button",
() -> {
String file_name = "sormas_fälle_" + LocalDate.now().format(formatter) + "_.csv";
String file_name = "sormas_f\u00E4lle_" + LocalDate.now().format(formatter) + "_.csv";
if (webDriverHelpers.isFileExists(
Paths.get(String.format("./downloads/%s", file_name)))) {
FilesHelper.deleteFile(file_name);
}
TimeUnit.SECONDS.sleep(2);
webDriverHelpers.clickOnWebElementBySelector(DETAILED_CASE_EXPORT_BUTTON);
TimeUnit.SECONDS.sleep(2);
FilesHelper.waitForFileToDownload(file_name, 90);
FilesHelper.waitForFileToDownload(file_name, 15);
});

When(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,23 @@ public EditCasePersonSteps(
}
webDriverHelpers.waitUntilIdentifiedElementIsPresent(selector);
});

When(
"I check that ([^\"]*) is not visible in Contact Information section for DE version",
(String option) -> {
webDriverHelpers.waitForPageLoadingSpinnerToDisappear(10);
By selector = null;
switch (option) {
case "Citizenship":
selector = CITIZENSHIP_LABEL_DE;
break;
case "Country of birth":
selector = COUNTRY_OF_BIRTH_LABEL_DE;
break;
}
softly.assertFalse(
webDriverHelpers.isElementVisibleWithTimeout(selector, 3), option + " is visible!");
softly.assertAll();
});
When(
"I set Present condition of person to {string}",
(String option) -> webDriverHelpers.selectFromCombobox(PRESENT_CONDITION_COMBOBOX, option));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.CONFIGURATION_NAME_INPUT;
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.CUSTOM_CASE_DELETE_BUTTON;
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.CUSTOM_CASE_EXPORT_DOWNLOAD_BUTTON;
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.DETAILED_CASE_EXPORT_BUTTON;
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.EXPORT_CONFIGURATION_DATA_DISEASE_CHECKBOX;
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.NEW_EXPORT_CONFIGURATION_BUTTON;
import static org.sormas.e2etests.pages.application.cases.CaseImportExportPage.NEW_EXPORT_CONFIGURATION_SAVE_BUTTON;
import static org.sormas.e2etests.pages.application.contacts.ContactImportExportPage.CUSTOM_CONTACT_EXPORT;
import static org.sormas.e2etests.pages.application.contacts.ContactImportExportPage.EXPORT_CONFIGURATION_DATA_FIRST_NAME_CHECKBOX_CONTACT;
import static org.sormas.e2etests.pages.application.contacts.ContactImportExportPage.EXPORT_CONFIGURATION_DATA_ID_CHECKBOX_CONTACT;
import static org.sormas.e2etests.pages.application.contacts.ContactImportExportPage.EXPORT_CONFIGURATION_DATA_LAST_NAME_CHECKBOX_CONTACT;
import static org.sormas.e2etests.steps.web.application.contacts.EditContactSteps.userDirPath;

import com.opencsv.CSVParser;
import com.opencsv.CSVParserBuilder;
Expand All @@ -44,6 +46,7 @@
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
Expand All @@ -54,6 +57,7 @@
import org.sormas.e2etests.enums.DiseasesValues;
import org.sormas.e2etests.helpers.AssertHelpers;
import org.sormas.e2etests.helpers.WebDriverHelpers;
import org.sormas.e2etests.helpers.files.FilesHelper;
import org.sormas.e2etests.state.ApiState;
import org.testng.Assert;
import org.testng.asserts.SoftAssert;
Expand Down Expand Up @@ -87,6 +91,11 @@ public ContactImportExportSteps(
() -> {
webDriverHelpers.clickOnWebElementBySelector(BASIC_CASE_EXPORT_BUTTON);
});
When(
"I click on the Detailed Contact Export button",
() -> {
webDriverHelpers.clickOnWebElementBySelector(DETAILED_CASE_EXPORT_BUTTON);
});

When(
"I click on the New Export Configuration button in Custom Contact Export popup",
Expand Down Expand Up @@ -168,6 +177,22 @@ public ContactImportExportSteps(
Files.delete(path);
softly.assertAll();
});
When(
"I check if citizenship and country of birth is not present in Detailed Contact export file",
() -> {
String fileName = "sormas_kontakte_" + LocalDate.now() + "_.csv";
FilesHelper.waitForFileToDownload(fileName, 20);
String[] headers =
parseDetailedContactExportHeaders(userDirPath + "/downloads/" + fileName);
FilesHelper.deleteFile(fileName);
softly.assertFalse(
Arrays.stream(headers).anyMatch("citizenship"::equals),
"Citizenship is present in file");
softly.assertFalse(
Arrays.stream(headers).anyMatch("countryOfBirth"::equals),
"Country of birth is present in file");
softly.assertAll();
});

When(
"I delete created custom contact export file",
Expand Down Expand Up @@ -233,4 +258,24 @@ public Contact parseBasicContactExport(String fileName) {
}
return builder;
}

public String[] parseDetailedContactExportHeaders(String fileName) {
List<String[]> r = null;
String[] values = new String[] {};
CSVParser csvParser = new CSVParserBuilder().withSeparator(',').build();
try (CSVReader reader =
new CSVReaderBuilder(new FileReader(fileName)).withCSVParser(csvParser).build()) {
r = reader.readAll();
} catch (IOException e) {
log.error("IOException parseDetailedContactExportHeaders: {}", e.getCause());
} catch (CsvException e) {
log.error("CsvException parseDetailedContactExportHeaders: {}", e.getCause());
}
try {
values = r.get(1);
} catch (NullPointerException e) {
log.error("Null pointer exception parseDetailedContactExportHeaders: {}", e.getCause());
}
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ public CreateNewContactSteps(
fillCaseIdInExternalSystem(contact.getCaseIdInExternalSystem());
selectMultiDayContact();
fillDateOfFirstContact(contact.getDateOfFirstContact(), Locale.ENGLISH);
fillDateOfLastContact(contact.getDateOfLastContact(), Locale.ENGLISH);
fillCaseOrEventInformation(contact.getCaseOrEventInformation());
selectResponsibleRegion(contact.getResponsibleRegion());
selectResponsibleDistrict(contact.getResponsibleDistrict());
selectResponsibleCommunity(contact.getResponsibleCommunity());
fillDateOfLastContact(contact.getDateOfLastContact(), Locale.ENGLISH);
selectTypeOfContact(contact.getTypeOfContact());
// fillAdditionalInformationOnTheTypeOfContact(
// contact.getAdditionalInformationOnContactType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,26 @@
import static org.sormas.e2etests.steps.BaseSteps.locale;

import com.github.javafaker.Faker;
import com.opencsv.CSVParser;
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.opencsv.exceptions.CsvException;
import cucumber.api.java8.En;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
Expand Down Expand Up @@ -236,6 +245,7 @@
import org.testng.Assert;
import org.testng.asserts.SoftAssert;

@Slf4j
public class EditEventSteps implements En {

private final WebDriverHelpers webDriverHelpers;
Expand Down Expand Up @@ -1860,6 +1870,22 @@ public EditEventSteps(
() ->
webDriverHelpers.clickOnWebElementBySelector(
CREATE_CASE_IN_EVENT_PARTICIPANT_LIST_BUTTON));
When(
"I check if citizenship and country of birth is not present in Detailed Event Participant export file",
() -> {
String fileName = "sormas_ereignisteilnehmer_" + LocalDate.now() + "_.csv";
FilesHelper.waitForFileToDownload(fileName, 20);
String[] headers =
parseDetailedEventParticipantExportHeaders(userDirPath + "/downloads/" + fileName);
FilesHelper.deleteFile(fileName);
softly.assertFalse(
Arrays.stream(headers).anyMatch("citizenship"::equals),
"Citizenship is present in file");
softly.assertFalse(
Arrays.stream(headers).anyMatch("countryOfBirth"::equals),
"Country of birth is present in file");
softly.assertAll();
});

And(
"I check event participant filter dropdown on event participant page when event is active",
Expand Down Expand Up @@ -2066,4 +2092,24 @@ private EventGroup collectEventGroupUuid() {
private void selectEventHandoutTemplate(String templateName) {
webDriverHelpers.selectFromCombobox(EVENT_HANDOUT_COMBOBOX, templateName);
}

public String[] parseDetailedEventParticipantExportHeaders(String fileName) {
List<String[]> r = null;
String[] values = new String[] {};
CSVParser csvParser = new CSVParserBuilder().withSeparator(',').build();
try (CSVReader reader =
new CSVReaderBuilder(new FileReader(fileName)).withCSVParser(csvParser).build()) {
r = reader.readAll();
} catch (IOException e) {
log.error("IOException parseDetailedContactExportHeaders: {}", e.getCause());
} catch (CsvException e) {
log.error("CsvException parseDetailedContactExportHeaders: {}", e.getCause());
}
try {
values = r.get(1);
} catch (NullPointerException e) {
log.error("Null pointer exception parseDetailedContactExportHeaders: {}", e.getCause());
}
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static org.sormas.e2etests.pages.application.events.EditEventPage.EVENT_PARTICIPANTS_TAB;
import static org.sormas.e2etests.pages.application.events.EditEventPage.FIRST_ARCHIVED_EVENT_PARTICIPANT;
import static org.sormas.e2etests.pages.application.events.EditEventPage.FIRST_EVENT_PARTICIPANT;
import static org.sormas.e2etests.pages.application.events.EditEventPage.FIRST_EVENT_PARTICIPANT_AFTER_IMPORT;
import static org.sormas.e2etests.pages.application.events.EditEventPage.FIRST_EVENT_PARTICIPANT_FROM_LIST;
import static org.sormas.e2etests.pages.application.events.EditEventPage.FIRST_RESULT_IN_EVENT_PARTICIPANT_TABLE;
import static org.sormas.e2etests.pages.application.events.EditEventPage.NEW_TASK_BUTTON;
Expand Down Expand Up @@ -848,6 +849,10 @@ public EventDirectorySteps(
webDriverHelpers.clickOnWebElementBySelector(FIRST_EVENT_PARTICIPANT);
});

When(
"I click on the first row from event participant after importing event participant",
() -> webDriverHelpers.clickOnWebElementBySelector(FIRST_EVENT_PARTICIPANT_AFTER_IMPORT));

When(
"I click on the first result in table from event participant",
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,34 @@ public EditPersonSteps(
"additionalInformation"));
});

When(
"I check that new edited person is correctly displayed in Edit Person page",
() -> {
TimeUnit.SECONDS.sleep(2); // wait for reaction
webDriverHelpers.waitForPageLoadingSpinnerToDisappear(40);
webDriverHelpers.waitUntilIdentifiedElementIsPresent(PRESENT_CONDITION_INPUT);
collectedPerson = collectPersonData();
TimeUnit.SECONDS.sleep(2); // wait for reaction
ComparisonHelper.compareDifferentFieldsOfEntities(
previousCreatedPerson,
collectedPerson,
List.of(
"firstName",
"lastName",
"dateOfBirth",
"sex",
"street",
"houseNumber",
"city",
"postalCode",
"contactPersonFirstName",
"contactPersonLastName",
"emailAddress",
"phoneNumber",
"facilityNameAndDescription",
"additionalInformation"));
});

Then(
"While on Person edit page, I will edit all fields with new values",
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1798,4 +1798,18 @@ Feature: Case end to end tests
And I apply "Archived cases" to combobox on Case Directory Page
And I check that number of displayed cases results is 1
And I apply "All cases" to combobox on Case Directory Page
And I check that number of displayed cases results is 1
And I check that number of displayed cases results is 1

@tmsLink=SORDEV-12441 @env_de
Scenario: Hide citizenship and country of birth on Edit Case Person page
Given API: I create a new person
And API: I check that POST call body is "OK"
And API: I check that POST call status code is 200
Given API: I create a new case
Then API: I check that POST call body is "OK"
And API: I check that POST call status code is 200
Given I log in as a National User
Then I navigate to the last created case via the url
And I navigate to case person tab
Then I check that Citizenship is not visible in Contact Information section for DE version
And I check that Country of birth is not visible in Contact Information section for DE version
Loading

0 comments on commit 3623546

Please sign in to comment.