Skip to content

Commit

Permalink
fix: Ensure that the release date is set properly
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsadam committed Jan 23, 2023
1 parent c4c04c5 commit 8046499
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
import ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles;
import ca.corefacility.bioinformatics.irida.model.project.Project;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile;
import ca.corefacility.bioinformatics.irida.model.user.User;
import ca.corefacility.bioinformatics.irida.ria.web.ajax.dto.NcbiExportSubmissionTableModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiBioSampleModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiExportSubmissionAdminTableModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiSubmissionRequest;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiSubmissionModel;
import ca.corefacility.bioinformatics.irida.ria.web.models.export.NcbiSubmissionRequest;
import ca.corefacility.bioinformatics.irida.ria.web.models.tables.TableRequest;
import ca.corefacility.bioinformatics.irida.ria.web.models.tables.TableResponse;
import ca.corefacility.bioinformatics.irida.service.ProjectService;
Expand Down Expand Up @@ -89,22 +88,8 @@ public TableResponse<NcbiExportSubmissionAdminTableModel> getNCBIExportsForAdmin
*/
public NcbiSubmissionModel getExportDetails(Long exportId) {
NcbiExportSubmission submission = ncbiService.read(exportId);
Project project = projectService.read(submission.getProject()
.getId());

List<NcbiBioSampleModel> bioSamples = submission.getBioSampleFiles()
.stream()
.map(bioSampleFile -> {
List<SequencingObject> pairs = bioSampleFile.getPairs()
.stream()
.peek(pair -> uiSampleService.enhanceQcEntries(pair, project))
.collect(Collectors.toList());
List<SequencingObject> singles = bioSampleFile.getFiles()
.stream()
.peek(single -> uiSampleService.enhanceQcEntries(single, project))
.collect(Collectors.toList());
return new NcbiBioSampleModel(bioSampleFile);
})
List<NcbiBioSampleModel> bioSamples = submission.getBioSampleFiles().stream().map(NcbiBioSampleModel::new)
.collect(Collectors.toList());

return new NcbiSubmissionModel(submission, bioSamples);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ import ExportUploadStateTag from "../ExportUploadStateTag";
export const formatNcbiSubmissionDetails = (
submission: Omit<NcbiSubmission, "bioSamples">
): BasicListItem[] => {
const LOCALE = window.TL?.LANGUAGE_TAG || "en";
const releaseDate = submission.releaseDate
? formatInternationalizedDateTime(submission.releaseDate)
? new Date(submission.releaseDate).toLocaleDateString(LOCALE, {
month: "short",
year: "numeric",
day: "numeric",
timeZone: "UTC", // ignoring timezone
})
: i18n("NcbiExportDetailsView.not-released");

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function CreateNcbiExport(): JSX.Element {
bioProject,
namespace,
organization,
releaseDate: releaseDate.valueOf(),
releaseDate: releaseDate.endOf("day").valueOf(),
samples: Object.values(_samples).map(
({
pairs = [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand All @@ -30,6 +31,9 @@ public class NcbiExportPage extends AbstractPage {
@FindBy(xpath = "//*[@id=\"namespace\"]")
private WebElement namespaceInput;

@FindBy(xpath = "//*[@id=\"releaseDate\"]")
private WebElement releaseDateInput;

@FindBy(className = "t-defaults-panel")
private WebElement defaultsPanel;

Expand Down Expand Up @@ -73,6 +77,12 @@ public void enterNamespace(String value) {
namespaceInput.sendKeys(value);
}

public void setReleaseDateInput(String value) {
releaseDateInput.sendKeys(Keys.chord(Keys.CONTROL, "a"));
releaseDateInput.sendKeys(value);
releaseDateInput.sendKeys(Keys.ENTER);
}

public void toggleDefaultsPanel() {
defaultsPanel.click();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package ca.corefacility.bioinformatics.irida.ria.integration.pages.projects;

import java.time.Duration;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage;

Expand All @@ -25,4 +29,11 @@ public static NcbiExportsListingPage goTo(WebDriver driver) {
public int getNumberOfBioSampleIdsDisplayed() {
return biodamplesIds.size();
}

public void gotoSubmissionPage(String bioprojectId) {
WebElement link = driver.findElement(By.xpath("//table/tbody//a[text() = '" + bioprojectId + "']"));
link.click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.urlMatches("/projects/\\d+/export/\\d+"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import ca.corefacility.bioinformatics.irida.ria.integration.AbstractIridaUIITChromeDriver;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.LoginPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ExportDetailsPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.NcbiExportPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.NcbiExportsListingPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ProjectSamplesPage;

import com.github.springtestdbunit.annotation.DatabaseSetup;
Expand All @@ -22,6 +24,7 @@ void testCreateNcbiSubmission() throws Exception {
String SAMPLE_3 = "sample3";
String BIOPROJECT = "BIOPROJECT-1";
String NAMESPACE = "NAMESPACE-FOOBAR";
String RELEASE_DATE = "2030-06-15";
String ORGANIZATION = "ORGANIZATION-FOOBAR";
String PROTOCOL = "AMAZING_PROTOCOL";
String DEFAULT_PROTOCOL = "DEFAULT_PROTOCOL";
Expand All @@ -40,6 +43,7 @@ void testCreateNcbiSubmission() throws Exception {
page.enterBioProject(BIOPROJECT);
page.enterNamespace(NAMESPACE);
page.enterOrganization(ORGANIZATION);
page.setReleaseDateInput(RELEASE_DATE);

// Test default sample settings.
page.toggleDefaultsPanel();
Expand Down Expand Up @@ -84,5 +88,16 @@ void testCreateNcbiSubmission() throws Exception {
assertTrue(page.isSuccessAlertDisplayed(), "Success notification should be displayed");
assertTrue(page.isUserRedirectedToProjectSamplesPage(PROJECT_ID),
"User should be redirected within 5 seconds of submission");

// Make sure all fields submitted successfully
NcbiExportsListingPage listingPage = NcbiExportsListingPage.goTo(driver());
listingPage.gotoSubmissionPage(BIOPROJECT);

ExportDetailsPage detailsPage = ExportDetailsPage.initPage(driver());
assertEquals(BIOPROJECT, detailsPage.getBioproject());
assertEquals(NAMESPACE, detailsPage.getNamespace());

assertEquals(ORGANIZATION, detailsPage.getOrganization());
assertTrue(detailsPage.getReleaseDate().equals("Jun 15, 2030"));
}
}

0 comments on commit 8046499

Please sign in to comment.