Skip to content

Commit

Permalink
Merge pull request #1395 from phac-nml/hotfix-add-associated-project-…
Browse files Browse the repository at this point in the history
…to-cart

Hotfix add associated project to cart
  • Loading branch information
ericenns authored Nov 1, 2022
2 parents 37c1458 + 445a452 commit 76bdf71
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 28 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# Changelog

## [22.09.2]
* [UI]: Fixed bug causing associated project samples to be added to the cart with the wrong project identifier. See [PR 1395](https://github.com/phac-nml/irida/pull/1395)

## [22.09.1] - 2022/10/21
* [UI]: Fixed when sharing or exporting sample on the project sample page, and other minor bugs. See [PR 1382](https://github.com/phac-nml/irida/pull/1382)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group = "ca.corefacility.bioinformatics"
version = "22.09.1"
version = "22.09.2"
description = "irida"

java {
Expand Down
18 changes: 14 additions & 4 deletions src/main/webapp/resources/js/pages/projects/redux/samplesSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,20 @@ const addToCart = createAsyncThunk(
"/samples/table/selected/cart",
async (_, { getState }) => {
const { samples } = getState();
return await putSampleInCart(
samples.projectId,
Object.values(samples.selected)
);
// Sort by project id
const samplesList = Object.values(samples.selected);
const projects = samplesList.reduce((prev, current) => {
if (!prev[current.projectId]) prev[current.projectId] = [];
prev[current.projectId].push(current);
return prev;
}, {});

const promises = [];
for (const projectId in projects) {
promises.push(putSampleInCart(projectId, projects[projectId]));
}

return Promise.all(promises).then((responses) => responses.pop());
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
package ca.corefacility.bioinformatics.irida.ria.integration;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import ca.corefacility.bioinformatics.irida.ria.integration.components.FastQCModal;
import ca.corefacility.bioinformatics.irida.ria.integration.components.SampleDetailsViewer;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.LoginPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.cart.CartPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ProjectSamplesPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.TableSummary;
import ca.corefacility.bioinformatics.irida.ria.integration.utilities.FileUtilities;

import com.github.springtestdbunit.annotation.DatabaseSetup;
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.*;

@DatabaseSetup("/ca/corefacility/bioinformatics/irida/ria/web/CartView.xml")
public class CartPageIT extends AbstractIridaUIITChromeDriver {
Expand Down Expand Up @@ -397,4 +394,35 @@ private void detailsTabInfo(FastQCModal fastQCModal) {
assertEquals(FILE_GC_CONTENT, fastQCModal.getGCContent(), "Displays the gc content");
}

@Test
void addAndRemoveAssociatedProjectSamplesToCart() {
final String PROJECT_NAME = "project5";
final String ASSOCIATED_PROJECT_NAME = "project";
final String SAMPLE_NAME = "sample5fdgr";
final String ASSOCIATED_SAMPLE_NAME = "sample5fg44";

LoginPage.loginAsAdmin(driver());
driver().manage().window().maximize();

ProjectSamplesPage samplesPage = ProjectSamplesPage.goToPage(driver(), 1);
samplesPage.toggleAssociatedProject(PROJECT_NAME);
TableSummary summary = samplesPage.getTableSummary();
assertEquals(22, summary.getTotal(),
"Should have more samples visible with another project selected");
samplesPage.selectSampleByName(ASSOCIATED_SAMPLE_NAME);
samplesPage.selectSampleByName(SAMPLE_NAME);
samplesPage.addSelectedSamplesToCart();

CartPage cartPage = CartPage.goToCart(driver());
assertEquals(2, cartPage.getNumberOfSamplesInCart(), "Should only be 2 samples in the cart");
cartPage.viewSampleDetailsFor(SAMPLE_NAME);
SampleDetailsViewer viewer = SampleDetailsViewer.getSampleDetails(driver());
assertEquals(ASSOCIATED_PROJECT_NAME, viewer.getProjectName(), "Should have the correct project name");

viewer.clickRemoveSampleFromCartButton();

assertFalse(viewer.sampleDetailsViewerVisible(), "The sample details viewer should not be displayed as the sample was removed from the cart");

assertEquals(1, cartPage.getNumberOfSamplesInCart(), "Should only be 1 sample in the cart");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package ca.corefacility.bioinformatics.irida.ria.integration.components;

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

import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
Expand All @@ -13,7 +10,8 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage;
import java.time.Duration;
import java.util.List;

public class SampleDetailsViewer extends AbstractPage {
@FindBy(className = "t-sample-details-modal")
Expand Down Expand Up @@ -361,7 +359,8 @@ public void clickAddSampleToCartButton() {

public void clickRemoveSampleFromCartButton() {
removeSampleFromCartBtn.click();
waitForTime(500);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.invisibilityOf(modal));
}

public int numberOfSequencingObjectsSetAsDefault() {
Expand Down

0 comments on commit 76bdf71

Please sign in to comment.