-
Notifications
You must be signed in to change notification settings - Fork 7
LKSM: Multivalue text choice automation: Assays #7511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |||||
|
|
||||||
| package org.labkey.test.tests.study; | ||||||
|
|
||||||
| import org.assertj.core.api.Assertions; | ||||||
| import org.junit.Assume; | ||||||
| import org.junit.Test; | ||||||
| import org.junit.experimental.categories.Category; | ||||||
| import org.labkey.api.util.FileUtil; | ||||||
|
|
@@ -34,6 +36,8 @@ | |||||
| import org.labkey.test.components.domain.DomainFormPanel; | ||||||
| import org.labkey.test.pages.ReactAssayDesignerPage; | ||||||
| import org.labkey.test.pages.assay.AssayBeginPage; | ||||||
| import org.labkey.test.pages.assay.AssayImportPage; | ||||||
| import org.labkey.test.pages.assay.AssayRunsPage; | ||||||
| import org.labkey.test.params.FieldDefinition; | ||||||
| import org.labkey.test.params.FieldInfo; | ||||||
| import org.labkey.test.params.experiment.SampleTypeDefinition; | ||||||
|
|
@@ -46,17 +50,23 @@ | |||||
| import org.labkey.test.util.SampleTypeHelper; | ||||||
| import org.labkey.test.util.StudyHelper; | ||||||
| import org.labkey.test.util.TestDataGenerator; | ||||||
| import org.labkey.test.util.data.TestArrayDataUtils; | ||||||
| import org.labkey.test.util.data.TestDataUtils; | ||||||
|
|
||||||
| import java.io.File; | ||||||
| import java.io.IOException; | ||||||
| import java.util.ArrayList; | ||||||
| import java.util.List; | ||||||
| import java.util.Map; | ||||||
| import java.util.stream.Collectors; | ||||||
| import java.util.stream.Stream; | ||||||
|
|
||||||
| import static org.junit.Assert.assertEquals; | ||||||
| import static org.junit.Assert.assertNotNull; | ||||||
| import static org.junit.Assert.assertTrue; | ||||||
| import static org.labkey.test.util.TestDataGenerator.shuffleSelect; | ||||||
| import static org.labkey.test.util.samplemanagement.SMTestUtils.COL_ASSAY_ID_LABEL; | ||||||
| import static org.labkey.test.util.samplemanagement.SMTestUtils.COL_MULTITEXTCHOICE; | ||||||
| import static org.labkey.test.util.samplemanagement.SMTestUtils.TEXT_MULTI_CHOICE_LIST; | ||||||
|
|
||||||
| @Category({Daily.class, Assays.class}) | ||||||
| public class AssayTest extends AbstractAssayTest | ||||||
|
|
@@ -71,6 +81,8 @@ public class AssayTest extends AbstractAssayTest | |||||
| private static final String ISSUE_53831_PROJECT = "Issue53831Project" + TRICKY_CHARACTERS_FOR_PROJECT_NAMES; | ||||||
| private static final String SAMPLE_FIELD_TEST_ASSAY = "SampleFieldTestAssay"; | ||||||
| private static final String SAMPLE_FIELD_PROJECT_NAME = "Sample Field Test Project" + TRICKY_CHARACTERS_FOR_PROJECT_NAMES; | ||||||
| private static final String MVTC_MULTI_FILE_IMPORT_ASSAY = TestDataGenerator.randomDomainName("MVTCMultiFileImportAssay", DomainUtils.DomainKind.Assay); | ||||||
| private static final String MVTC_MULTI_FILE_IMPORT_PROJECT = "MVTCMultiFileImportAssay" + TRICKY_CHARACTERS_FOR_PROJECT_NAMES; | ||||||
|
|
||||||
| @Override | ||||||
| protected String getProjectName() | ||||||
|
|
@@ -90,6 +102,7 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException | |||||
| _containerHelper.deleteProject(ISSUE_53616_PROJECT, false); | ||||||
| _containerHelper.deleteProject(ISSUE_53625_PROJECT, false); | ||||||
| _containerHelper.deleteProject(ISSUE_53831_PROJECT, false); | ||||||
| _containerHelper.deleteProject(MVTC_MULTI_FILE_IMPORT_PROJECT, false); | ||||||
|
|
||||||
| _userHelper.deleteUsers(false, TEST_ASSAY_USR_PI1, TEST_ASSAY_USR_TECH1); | ||||||
| } | ||||||
|
|
@@ -109,6 +122,62 @@ public void testAssayNameMaxLength() throws Exception | |||||
| assayDesignerPage.clickCancel(); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| public void testAssayMultiFileImportForMVTC() throws Exception | ||||||
| { | ||||||
| Assume.assumeTrue("Multi-choice text fields are only supported on PostgreSQL", WebTestHelper.getDatabaseType() == WebTestHelper.DatabaseType.PostgreSQL); | ||||||
| _containerHelper.createProject(MVTC_MULTI_FILE_IMPORT_PROJECT, "Assay"); | ||||||
| goToProjectHome(MVTC_MULTI_FILE_IMPORT_PROJECT); | ||||||
| log("Create test assay"); | ||||||
| ReactAssayDesignerPage assayDesignerPage = _assayHelper.createAssayDesign("General", MVTC_MULTI_FILE_IMPORT_ASSAY); | ||||||
|
|
||||||
| assayDesignerPage.goToResultsFields() | ||||||
| .removeAllFields(false) | ||||||
| .addField(COL_MULTITEXTCHOICE.getFieldDefinition()); | ||||||
|
|
||||||
| assayDesignerPage.clickFinish(); | ||||||
|
Comment on lines
+132
to
+138
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create this assay via API. |
||||||
|
|
||||||
| String firstFileName = "MVTCAssayImport.tsv"; | ||||||
| String secondFileName = "MVTCAssayImportSecond.tsv"; | ||||||
| List<List<String>> fileDataFirstImport = Stream.generate(() -> shuffleSelect(TEXT_MULTI_CHOICE_LIST)) | ||||||
| .limit(5) | ||||||
| .toList(); | ||||||
| List<List<String>> fileDataSecondImport = Stream.generate(() -> shuffleSelect(TEXT_MULTI_CHOICE_LIST)) | ||||||
| .limit(5) | ||||||
| .toList(); | ||||||
|
|
||||||
| log("Import first and second runs with MVTC data from files"); | ||||||
| AssayImportPage assayImportPage = goToManageAssays() | ||||||
| .clickAssay(MVTC_MULTI_FILE_IMPORT_ASSAY) | ||||||
| .clickImportData(); | ||||||
| assayImportPage.clickNext(); | ||||||
| assayImportPage.setDataFile(TestFileUtils.writeTempFile(firstFileName, buildFileContent(fileDataFirstImport))); | ||||||
|
|
||||||
| assayImportPage = assayImportPage.clickSaveAndImportAnother(); | ||||||
| assayImportPage.setDataFile(TestFileUtils.writeTempFile(secondFileName, buildFileContent(fileDataSecondImport))); | ||||||
| assayImportPage.clickSaveAndFinish(); | ||||||
|
|
||||||
| AssayRunsPage assayRunsPage = new AssayRunsPage(getDriver()); | ||||||
| checker().wrapAssertion(() -> Assertions.assertThat(assayRunsPage.getTable().getColumnDataAsText(COL_ASSAY_ID_LABEL)) | ||||||
| .as("expect both runs to appear in the runs list") | ||||||
| .containsExactlyInAnyOrder(firstFileName, secondFileName)); | ||||||
|
|
||||||
| List<String> expectedValues = Stream.concat(fileDataFirstImport.stream(), fileDataSecondImport.stream()) | ||||||
| .map(values -> TestArrayDataUtils.sortAndJoin(values, " ")) | ||||||
| .toList(); | ||||||
| checker().wrapAssertion(() -> Assertions.assertThat(assayRunsPage.clickViewResults().getDataTable().getColumnDataAsText(COL_MULTITEXTCHOICE.getLabel())) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use column labels as a last resort.
Suggested change
|
||||||
| .as("expect MVTC values to match imported data") | ||||||
| .containsExactlyInAnyOrderElementsOf(expectedValues)); | ||||||
| } | ||||||
|
|
||||||
| private String buildFileContent(List<List<String>> fileData) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method's functionality is much more specialized than the method name implies. The name should reflect the specific purpose of this method. Also, it should just return the file since that's how this is always used.
Suggested change
|
||||||
| { | ||||||
| return Stream.concat( | ||||||
| Stream.of(COL_MULTITEXTCHOICE.getName()), | ||||||
| fileData.stream().map(TestArrayDataUtils::formatMultiValueText) | ||||||
| ).collect(Collectors.joining("\n", "", "\n")); | ||||||
| } | ||||||
|
|
||||||
| // Issue 53616: Assay creation attempt after an error results in "Assay protocol already exists for this name." | ||||||
| @Test | ||||||
| public void testFailedCreation() throws Exception | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there is a matching dependency between the modules themselves, tests for one module shouldn't import anything from tests for another module.
Referring to code in a private repository from code in a public repository is especially unwanted. The community suites can't run with this sort of import present.
This test should just define its own multi-text choice column.