2727import org .labkey .test .util .ApiPermissionsHelper ;
2828import org .labkey .test .util .PermissionsHelper ;
2929import org .labkey .test .util .PortalHelper ;
30+ import org .labkey .test .util .PostgresOnlyTest ;
3031
3132import java .io .IOException ;
3233import java .util .Arrays ;
3637
3738@ Category ({})
3839@ BaseWebDriverTest .ClassTimeout (minutes = 5 )
39- public class InstrumentSchedulingTest extends TargetedMSTest
40+ public class InstrumentSchedulingTest extends TargetedMSTest implements PostgresOnlyTest
4041{
4142 protected static final String SCHEDULER_USER_1 =
"[email protected] " ;
4243 protected static final String SCHEDULER_USER_2 =
"[email protected] " ;
4344
45+ public static final String INSTRUMENT_1 = "Instrument1" ;
46+ public static final String INSTRUMENT_2 = "Instrument2" ;
47+ public static final String INACTIVE_INSTRUMENT = "InactiveInstrument" ;
48+ public static final String PROJECT_1 = "Project1" ;
49+ public static final String PROJECT_2 = "Project2" ;
50+
4451 @ BeforeClass
4552 public static void initProject () throws IOException , CommandException
4653 {
@@ -61,16 +68,16 @@ private void doInit() throws IOException, CommandException
6168
6269 InsertRowsCommand instrumentInsert = new InsertRowsCommand ("targetedms" , "msInstrument" );
6370 instrumentInsert .setRows (Arrays .asList (
64- Map .of ("Name" , "Instrument1" , "Active" , true , "Color" , "#ee0000" ),
65- Map .of ("Name" , "Instrument2" , "Active" , true , "Color" , "#00ee00" ),
66- Map .of ("Name" , "InactiveInstrument" , "Active" , false , "Color" , "#0000ee" )
71+ Map .of ("Name" , INSTRUMENT_1 , "Active" , true , "Color" , "#ee0000" ),
72+ Map .of ("Name" , INSTRUMENT_2 , "Active" , true , "Color" , "#00ee00" ),
73+ Map .of ("Name" , INACTIVE_INSTRUMENT , "Active" , false , "Color" , "#0000ee" )
6774 ));
6875 List <Map <String , Object >> instruments = instrumentInsert .execute (createDefaultConnection (), getProjectName ()).getRows ();
6976
7077 InsertRowsCommand projectInsert = new InsertRowsCommand ("targetedms" , "msProject" );
7178 projectInsert .setRows (Arrays .asList (
72- Map .of ("Affiliation" , "LabKey" , "Title" , "Project1" , "SubmitDate" , "1/1/2025" , "CollaborationWith" , "Mike" , "ScientificQuestion" , "Why do I have to enter this?" , "abstract" , "b" ),
73- Map .of ("Affiliation" , "UW" , "Title" , "Project2" , "SubmitDate" , "2/2/2025" , "CollaborationWith" , "Josh" , "ScientificQuestion" , "Why is the sky blue?" , "abstract" , "a" )
79+ Map .of ("Affiliation" , "LabKey" , "Title" , PROJECT_1 , "SubmitDate" , "1/1/2025" , "CollaborationWith" , "Mike" , "ScientificQuestion" , "Why do I have to enter this?" , "abstract" , "b" ),
80+ Map .of ("Affiliation" , "UW" , "Title" , PROJECT_2 , "SubmitDate" , "2/2/2025" , "CollaborationWith" , "Josh" , "ScientificQuestion" , "Why is the sky blue?" , "abstract" , "a" )
7481 ));
7582 List <Map <String , Object >> projects = projectInsert .execute (createDefaultConnection (), getProjectName ()).getRows ();
7683
@@ -116,8 +123,8 @@ public void testSchedule()
116123 {
117124 goToProjectHome ();
118125 clickAndWait (Locator .linkWithText ("Your project list" ));
119- assertTextPresent ("Project1" , "Project2" );
120- clickAndWait (Locator .linkWithText ("Project1" ));
126+ assertTextPresent (PROJECT_1 , PROJECT_2 );
127+ clickAndWait (Locator .linkWithText (PROJECT_1 ));
121128 waitAndClickAndWait (Locator .linkWithText ("Schedule instrument time" ));
122129
123130 String yearMonth = Calendar .getInstance ().get (Calendar .YEAR ) + "-" ;
@@ -136,7 +143,7 @@ public void testSchedule()
136143 assertProjectEventCounts (2 , 0 );
137144
138145 sleep (1000 ); // Wait for the dialog to clear out of the way
139- doAndWaitForPageToLoad (() -> selectOptionByText (Locator .id ("projectDropDown" ), "Project2" ));
146+ doAndWaitForPageToLoad (() -> selectOptionByText (Locator .id ("projectDropDown" ), PROJECT_2 ));
140147
141148 scheduleInstrument (yearMonth + "-04" );
142149 assertProjectEventCounts (1 , 2 );
@@ -145,24 +152,31 @@ public void testSchedule()
145152 assertProjectEventCounts (2 , 2 );
146153
147154 sleep (1000 ); // Wait for the dialog to clear out of the way
148- doAndWaitForPageToLoad (() -> selectOptionByText (Locator .id ("instrumentDropDown" ), "Instrument2" ));
155+ doAndWaitForPageToLoad (() -> selectOptionByText (Locator .id ("instrumentDropDown" ), INSTRUMENT_2 ));
149156 scheduleInstrument (yearMonth + "-06" );
150157 assertProjectEventCounts (1 , 0 );
151158
152159 goToDashboard ();
153160 clickAndWait (Locator .linkWithText ("All instrument calendar view" ));
154- assertTextPresent ("Instrument1" , "Instrument2" , "InactiveInstrument" );
161+ assertTextPresent (INSTRUMENT_1 , INSTRUMENT_2 , INACTIVE_INSTRUMENT );
155162
156163 waitForElementToBeVisible (Locator .tagWithClass ("div" , "activeProjectEvent" ));
157164 assertProjectEventCounts (5 , 0 );
158165
159- selectOptionByText (Locator .id ("projectFilter" ), "Project2" );
166+ selectOptionByText (Locator .id ("projectFilter" ), PROJECT_2 );
160167 assertProjectEventCounts (3 , 2 );
161168
162169 goToDashboard ();
163170 clickAndWait (Locator .linkWithText ("Instrument billing report" ));
164171 assertTextPresent ("$2,450.00" , 4 );
165172 assertTextPresent ("$2,690.00" , 1 );
173+
174+ // Future test cases:
175+ // Split payment across multiple methods
176+ // Schedule for hours within a day instead of 24-hour periods
177+ // Check billing for individual months, including reservations that span month boundaries with start/end dates
178+ // Ensure that overlapping reservations are rejected
179+ // Ensure that reservations cannot be made for inactive instruments
166180 }
167181
168182 private void assertProjectEventCounts (int expectedActiveCount , int expectedOtherCount )
0 commit comments