Skip to content

Commit 27dfdf0

Browse files
Merge 25.12 to develop
2 parents 1101bcf + ac52594 commit 27dfdf0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/src/org/labkey/test/tests/targetedms/InstrumentSchedulingTest.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535
import org.openqa.selenium.WebElement;
3636

3737
import java.io.IOException;
38+
import java.text.ParseException;
39+
import java.text.SimpleDateFormat;
3840
import java.util.Arrays;
3941
import java.util.Calendar;
4042
import java.util.Date;
4143
import java.util.List;
4244
import java.util.Map;
45+
import java.util.concurrent.atomic.AtomicBoolean;
4346

4447
import static org.junit.Assert.assertEquals;
4548
import static org.junit.Assert.assertTrue;
@@ -217,12 +220,19 @@ public void testSchedule() throws IOException, CommandException
217220
assertTextPresent("When multiple payment methods are used, the percentages must add up to 100% (current total: 110%).");
218221
setFormElement(percentInputs.get(0), "40");
219222

223+
AtomicBoolean twoDayReservationOverWeekend = new AtomicBoolean(false);
220224
scheduleInstrument(yearMonth + "-06", false, () -> {
221225
// Make it a two-day reservation
222226
String originalEnd = getFormElement(END_DATE_TIME_FIELD.findElement(getDriver()));
227+
try {
228+
Calendar c = Calendar.getInstance();
229+
c.setTime(new SimpleDateFormat(getCurrentDateFormatString()).parse(originalEnd));
230+
twoDayReservationOverWeekend.set(c.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY);
231+
} catch (ParseException ignore) {}
223232
setFormElement(END_DATE_TIME_FIELD.findElement(getDriver()), originalEnd.replace("-06T", "-07T"));
224233
});
225-
assertProjectEventCounts(1, 0);
234+
// If an event spans a weekend, it will be represented by two separate event elements
235+
assertProjectEventCounts(twoDayReservationOverWeekend.get() ? 2 : 1, 0);
226236

227237
impersonate(LAB_MEMBER_USER);
228238
assertEquals("Wrong number of projects for " + LAB_MEMBER_USER,
@@ -282,10 +292,10 @@ public void testSchedule() throws IOException, CommandException
282292
waitAndClickAndWait(Locator.linkWithText("All instrument calendar view"));
283293
waitForText(INSTRUMENT_1, INSTRUMENT_2, INACTIVE_INSTRUMENT);
284294

285-
assertProjectEventCounts(5, 0);
295+
assertProjectEventCounts(twoDayReservationOverWeekend.get() ? 6 : 5, 0);
286296

287297
selectOptionByText(Locator.id("projectFilter"), PROJECT_2);
288-
assertProjectEventCounts(3, 2);
298+
assertProjectEventCounts(twoDayReservationOverWeekend.get() ? 4 : 3, 2);
289299

290300
goToDashboard();
291301
waitAndClickAndWait(Locator.linkWithText("Instrument billing report"));

0 commit comments

Comments
 (0)