4343import org .labkey .test .params .FieldDefinition ;
4444import org .labkey .test .params .experiment .DataClassDefinition ;
4545import org .labkey .test .params .experiment .SampleTypeDefinition ;
46+ import org .labkey .test .util .ArtifactCollector ;
4647import org .labkey .test .util .DataRegionTable ;
4748import org .labkey .test .util .LogMethod ;
4849import org .labkey .test .util .PortalHelper ;
@@ -546,7 +547,7 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
546547 {
547548 String subfolder = "samplesWithAssayRunsFolder" ;
548549 String subfolderPath = getProjectName () + "/" + subfolder ;
549- String testSamples = "testSamples " ;
550+ String testSamples = "testSamplesWithFiles " ;
550551 String assayName = "testAssay" ;
551552 String importFolder = "assaySamplesImportFolder" ;
552553
@@ -557,7 +558,7 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
557558 // create a test sampleType
558559 List <FieldDefinition > testFields = SampleTypeAPIHelper .sampleTypeTestFields (true );
559560 SampleTypeDefinition testSampleType = new SampleTypeDefinition (testSamples ).setFields (testFields )
560- .addParentAlias ("SelfParent" ); // to derive from samles in the current type
561+ .addParentAlias ("SelfParent" ); // to derive from samples in the current type
561562
562563 TestDataGenerator parentDgen = SampleTypeAPIHelper .createEmptySampleType (subfolderPath , testSampleType );
563564 parentDgen .addCustomRow (Map .of ("Name" , "sample1" , "intColumn" , 1 , "decimalColumn" , 1.1 , "stringColumn" , "one" ));
@@ -572,14 +573,23 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
572573 portalHelper .addWebPart ("Experiment Runs" );
573574 portalHelper .addWebPart ("Assay List" );
574575
575- // upload a file for a sample's file field
576+ log ( String . format ( "Upload a file '%s' to a sample's file field." , SAMPLE_TXT_FILE . getName ()));
576577 clickAndWait (Locator .linkWithText (testSamples ));
577578 DataRegionTable sourceSamplesTable = new SampleTypeHelper (this ).getSamplesDataRegionTable ();
578579 sourceSamplesTable .clickEditRow (1 );
579580 waitForElementToBeVisible (Locator .tagWithAttribute ("input" , "type" , "file" ));
580581 setFormElement (Locator .tagWithAttribute ("input" , "type" , "file" ), SAMPLE_TXT_FILE );
582+ // setFormElement doesn't check that the form element is set.
583+ // Because this test uses random field names, we should validate that the file was actually uploaded. If the
584+ // file is missing later in the test, we can be sure it was present at this point.
585+ Assert .assertTrue ("File not uploaded to 'add new' form." ,
586+ waitFor (()->!getFormElement (Locator .tagWithAttribute ("input" , "type" , "file" )).isEmpty (), 1_500 ));
581587 clickAndWait (Locator .lkButton ("Submit" ));
582588
589+ waitForElementToBeVisible (Locator .linkContainingText (SAMPLE_TXT_FILE .getName ()));
590+
591+ new ArtifactCollector (this ).dumpPageSnapshot ("File_Attached_Proof" );
592+
583593 goToProjectFolder (getProjectName (), subfolder );
584594
585595 // now define an assay that references it
@@ -644,14 +654,26 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
644654 exportData .add (dataTable .getRowDataAsMap (i ));
645655 }
646656
647- // now export the current folder and import it to importProject
657+ log ( "Now export the current folder and import it to importProject." );
648658 goToFolderManagement ()
649659 .goToExportTab ();
650660
651- Checkbox checkbox = new Checkbox (Locator .tagWithText ("label" , ExportFolderPage .EXPERIMENTS_AND_RUNS )
652- .precedingSibling ("input" ).waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT ));
653- new Checkbox (Locator .tagWithText ("label" , "Files" ).precedingSibling ("input" ).findElement (getDriver ())).check ();
654- checkbox .check ();
661+ new Checkbox (Locator .tagWithText ("label" , ExportFolderPage .EXPERIMENTS_AND_RUNS )
662+ .precedingSibling ("input" ).waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT )).check ();
663+
664+ new Checkbox (Locator .tagWithText ("label" , "Files" )
665+ .precedingSibling ("input" ).waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT )).check ();
666+
667+ Assert .assertTrue ("Experiment and Runs not checked for export." ,
668+ new Checkbox (Locator .tagWithText ("label" , ExportFolderPage .EXPERIMENTS_AND_RUNS )
669+ .precedingSibling ("input" ).waitForElement (getDriver (), WAIT_FOR_JAVASCRIPT )).isChecked ());
670+
671+ Assert .assertTrue ("Files not checked for export." ,
672+ new Checkbox (Locator .tagWithText ("label" , "Files" ).precedingSibling ("input" ).findElement (getDriver ()))
673+ .isChecked ());
674+
675+ log ("'Experiment and Runs' & 'Files' are selected for export." );
676+
655677 File exportedFolderFile = doAndWaitForDownload (()->findButton ("Export" ).click ());
656678
657679 goToProjectFolder (IMPORT_PROJECT_NAME , importFolder );
0 commit comments