-
Notifications
You must be signed in to change notification settings - Fork 9
LKSM: Multivalue text choice automation: Type Conversion #2960
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
Open
DariaBod
wants to merge
13
commits into
develop
Choose a base branch
from
fb_typeConversionMVTC
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4b9f539
sample finder conversion tests
DariaBod 66e4ae6
test cross folder MVTC to TC conversion
DariaBod 55909cd
sample finder tests add mvtc field check after conversions
DariaBod 18c9c1d
Merge branch 'develop' into fb_typeConversionMVTC
DariaBod f860fd4
tests for saved grid type conversion
DariaBod 0712051
Merge branch 'develop' into fb_typeConversionMVTC
DariaBod a0c65e8
small fixes
DariaBod 6dfa7df
Merge branch 'develop' into fb_typeConversionMVTC
DariaBod c4b5608
subfolder test move to LKSM
DariaBod 7196093
fix code style
DariaBod 0c2fcc1
Merge branch 'develop' into fb_typeConversionMVTC
DariaBod 7f49b1e
Merge branch 'develop' into fb_typeConversionMVTC
DariaBod 917b221
fix pr comments
DariaBod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
src/org/labkey/test/tests/MultiValueTextChoiceSampleTypeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| package org.labkey.test.tests; | ||
|
|
||
| import org.junit.Before; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.labkey.remoteapi.CommandException; | ||
| import org.labkey.test.BaseWebDriverTest; | ||
| import org.labkey.test.WebTestHelper; | ||
| import org.labkey.test.categories.Daily; | ||
| import org.labkey.test.components.domain.DomainFieldRow; | ||
| import org.labkey.test.pages.experiment.UpdateSampleTypePage; | ||
| import org.labkey.test.pages.query.UpdateQueryRowPage; | ||
| import org.labkey.test.params.FieldDefinition; | ||
| import org.labkey.test.params.FieldDefinition.ColumnType; | ||
| import org.labkey.test.params.experiment.SampleTypeDefinition; | ||
| import org.labkey.test.util.DataRegionTable; | ||
| import org.labkey.test.util.DomainUtils; | ||
| import org.labkey.test.util.PortalHelper; | ||
| import org.labkey.test.util.PostgresOnlyTest; | ||
| import org.labkey.test.util.TestDataGenerator; | ||
| import org.labkey.test.util.exp.SampleTypeAPIHelper; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
| import static org.labkey.test.util.SampleTypeHelper.beginAtSampleTypesList; | ||
| import static org.labkey.test.util.TestDataGenerator.randomDomainName; | ||
| import static org.labkey.test.util.TestDataGenerator.randomFieldName; | ||
| import static org.labkey.test.util.TestDataGenerator.randomTextChoice; | ||
| import static org.labkey.test.util.TestDataGenerator.shuffleSelect; | ||
|
|
||
| @Category({Daily.class}) | ||
| public class MultiValueTextChoiceSampleTypeTest extends BaseWebDriverTest implements PostgresOnlyTest | ||
| { | ||
| private static final String SUB_FOLDER = "ChildFolder_MultiValueTextChoice_SampleType_Test"; | ||
| private final String SUB_FOLDER_PATH = getProjectName() + "/" + SUB_FOLDER; | ||
|
|
||
| @Override | ||
| public List<String> getAssociatedModules() | ||
| { | ||
| return Arrays.asList("experiment"); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getProjectName() | ||
| { | ||
| return "MultiValueTextChoice_SampleType_Test"; | ||
| } | ||
|
|
||
| @BeforeClass | ||
| public static void setupProject() | ||
| { | ||
| MultiValueTextChoiceSampleTypeTest init = getCurrentTest(); | ||
| init.doSetup(); | ||
| } | ||
|
|
||
| private void doSetup() | ||
| { | ||
| PortalHelper portalHelper = new PortalHelper(this); | ||
| _containerHelper.createProject(getProjectName(), null); | ||
| portalHelper.enterAdminMode(); | ||
| portalHelper.addWebPart("Sample Types"); | ||
| _containerHelper.createSubfolder(getProjectName(), SUB_FOLDER); | ||
| portalHelper.addWebPart("Sample Types"); | ||
| portalHelper.exitAdminMode(); | ||
| } | ||
|
|
||
| @Before | ||
| public void beforeTest() | ||
| { | ||
| goToProjectHome(); | ||
| } | ||
|
|
||
| private TestDataGenerator createSampleType(String sampleTypeName, String sampleNamePrefix, String multiValueTextChoiceFieldName, List<String> multiValueTextChoiceValues) | ||
| { | ||
| log(String.format("Create a new sample type named '%s'.", sampleTypeName)); | ||
| SampleTypeDefinition sampleTypeDefinition = new SampleTypeDefinition(sampleTypeName); | ||
| sampleTypeDefinition.setNameExpression(String.format("%s${genId}", sampleNamePrefix)); | ||
|
|
||
| log(String.format("Add a MultiValueTextChoice field named '%s'.", multiValueTextChoiceFieldName)); | ||
| FieldDefinition textChoiceField = new FieldDefinition(multiValueTextChoiceFieldName, ColumnType.MultiValueTextChoice); | ||
| textChoiceField.setMultiChoiceValues(multiValueTextChoiceValues); | ||
|
|
||
| sampleTypeDefinition.addField(textChoiceField); | ||
|
|
||
| return SampleTypeAPIHelper.createEmptySampleType(getCurrentContainerPath(), sampleTypeDefinition); | ||
| } | ||
|
|
||
| /** | ||
| * Validate cross folder MVTC to TC conversion. | ||
| */ | ||
| @Test | ||
| public void testCrossFolderMVTCtoTCConversion() throws IOException, CommandException | ||
| { | ||
| final String sampleTypeName = randomDomainName("MVTC_Sample_Edit", DomainUtils.DomainKind.SampleSet); | ||
| final String multiValueTextChoiceFieldName = randomFieldName("MultiValueTextChoice_Field"); | ||
| final String namePrefix = "MVTC_"; | ||
| int samplesCount = 3; | ||
| List<String> mvtcValues = randomTextChoice(10); | ||
|
|
||
| // Create Sample type in main folder. | ||
| TestDataGenerator dataGenerator = createSampleType(sampleTypeName, namePrefix, multiValueTextChoiceFieldName, mvtcValues); | ||
|
|
||
| log("Create some samples in child folder. They have MultiValueTextChoice filed filled with random multiple values."); | ||
|
|
||
| for (int i = 1; i <= samplesCount; i++) | ||
| { | ||
| Map<String, Object> sample = new HashMap<>(); | ||
| String sampleName = String.format("%s%d", namePrefix, i); | ||
| sample.put("Name", sampleName); | ||
| sample.put(multiValueTextChoiceFieldName, shuffleSelect(mvtcValues, 2)); | ||
| dataGenerator.addCustomRow(sample); | ||
| } | ||
|
|
||
| dataGenerator.insertRows(WebTestHelper.getRemoteApiConnection(), SUB_FOLDER_PATH); | ||
|
|
||
| // Check that impossible to convert MVTC to TC. | ||
| DomainFieldRow fieldRow = beginAtSampleTypesList(this, getProjectName()) | ||
| .goToEditSampleType(sampleTypeName) | ||
| .getFieldsPanel() | ||
| .getField(multiValueTextChoiceFieldName) | ||
| .expand(); | ||
| checker().wrapAssertion(() -> | ||
| assertThatThrownBy(() -> fieldRow.setAllowMultipleSelections(false)) | ||
| .as("'Allow Multiple Selections' checkbox should not be available") | ||
| .hasMessageContaining("Allow Multiple Selections checkbox isn't enabled") | ||
| ); | ||
|
|
||
| // Edit all MVTC fields to have 1 chosen value. | ||
| DataRegionTable samplesTable = beginAtSampleTypesList(this, SUB_FOLDER_PATH) | ||
| .goToSampleType(sampleTypeName) | ||
| .getSamplesDataRegionTable(); | ||
|
|
||
| for (int i = 0; i < samplesCount; i++) | ||
| { | ||
| UpdateQueryRowPage updateQueryRowPage = samplesTable.clickEditRow(i); | ||
| updateQueryRowPage.setField(multiValueTextChoiceFieldName, shuffleSelect(mvtcValues, 1)); | ||
| updateQueryRowPage.submit(); | ||
| } | ||
|
|
||
| // Convert MVTC to TC. | ||
| UpdateSampleTypePage updateSampleTypePage = beginAtSampleTypesList(this, getProjectName()) | ||
| .goToEditSampleType(sampleTypeName); | ||
| updateSampleTypePage.getFieldsPanel() | ||
| .getField(multiValueTextChoiceFieldName) | ||
| .expand() | ||
| .setAllowMultipleSelections(false); | ||
| updateSampleTypePage.clickSave(); | ||
|
|
||
| // Check that impossible to choose multiple values. | ||
| samplesTable = beginAtSampleTypesList(this, SUB_FOLDER_PATH) | ||
| .goToSampleType(sampleTypeName) | ||
| .getSamplesDataRegionTable(); | ||
| UpdateQueryRowPage updateQueryRowPage = samplesTable.clickEditRow(0); | ||
| checker().wrapAssertion(() -> | ||
| assertThatThrownBy(() -> updateQueryRowPage.setField(multiValueTextChoiceFieldName, shuffleSelect(mvtcValues, 2))) | ||
| .as("MVTC element isn't found on the page.") | ||
| .hasMessageContaining("Unable to find element") | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| protected void doCleanup(boolean afterTest) | ||
| { | ||
| _containerHelper.deleteProject(getProjectName(), false); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add a parameter to explicitly determine whether a confirmation dialog is expected. This is consistent with the
setTypemethod.Without this change, the component might fail to dismiss a dialog that appears a little too slowly.