|
35 | 35 | import org.openqa.selenium.WebElement; |
36 | 36 |
|
37 | 37 | import java.io.IOException; |
| 38 | +import java.text.ParseException; |
| 39 | +import java.text.SimpleDateFormat; |
38 | 40 | import java.util.Arrays; |
39 | 41 | import java.util.Calendar; |
40 | 42 | import java.util.Date; |
41 | 43 | import java.util.List; |
42 | 44 | import java.util.Map; |
| 45 | +import java.util.concurrent.atomic.AtomicBoolean; |
43 | 46 |
|
44 | 47 | import static org.junit.Assert.assertEquals; |
45 | 48 | import static org.junit.Assert.assertTrue; |
@@ -217,12 +220,19 @@ public void testSchedule() throws IOException, CommandException |
217 | 220 | assertTextPresent("When multiple payment methods are used, the percentages must add up to 100% (current total: 110%)."); |
218 | 221 | setFormElement(percentInputs.get(0), "40"); |
219 | 222 |
|
| 223 | + AtomicBoolean twoDayReservationOverWeekend = new AtomicBoolean(false); |
220 | 224 | scheduleInstrument(yearMonth + "-06", false, () -> { |
221 | 225 | // Make it a two-day reservation |
222 | 226 | 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) {} |
223 | 232 | setFormElement(END_DATE_TIME_FIELD.findElement(getDriver()), originalEnd.replace("-06T", "-07T")); |
224 | 233 | }); |
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); |
226 | 236 |
|
227 | 237 | impersonate(LAB_MEMBER_USER); |
228 | 238 | assertEquals("Wrong number of projects for " + LAB_MEMBER_USER, |
@@ -282,10 +292,10 @@ public void testSchedule() throws IOException, CommandException |
282 | 292 | waitAndClickAndWait(Locator.linkWithText("All instrument calendar view")); |
283 | 293 | waitForText(INSTRUMENT_1, INSTRUMENT_2, INACTIVE_INSTRUMENT); |
284 | 294 |
|
285 | | - assertProjectEventCounts(5, 0); |
| 295 | + assertProjectEventCounts(twoDayReservationOverWeekend.get() ? 6 : 5, 0); |
286 | 296 |
|
287 | 297 | selectOptionByText(Locator.id("projectFilter"), PROJECT_2); |
288 | | - assertProjectEventCounts(3, 2); |
| 298 | + assertProjectEventCounts(twoDayReservationOverWeekend.get() ? 4 : 3, 2); |
289 | 299 |
|
290 | 300 | goToDashboard(); |
291 | 301 | waitAndClickAndWait(Locator.linkWithText("Instrument billing report")); |
|
0 commit comments