Teammates: StudentFeedbackQuestionSubmitPageUiTest: prevent failure when run just past midnight

Created on 10 Jun 2016  路  3Comments  路  Source: TEAMMATES/teammates

The specific test case is when student

  • starts editing response after the session closing time but before the grace period end, and
  • submits the edit after the grace period

This is tested by changing the closing time to 20 minutes before current time. When the test is run at around 00:00 -- 00:19, the time will be shifted cross date boundary (i.e., different dates) and HtmlHelper.replaceUnpredictableValuesWithPlaceholders() will not work

Relevant code slice is at StudentFeedbackQuestionSubmitPageUiTest:223:

endDate = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));

submitPage = loginToStudentFeedbackQuestionSubmitPage("Alice", "Open Session", fq.getId());

fs.setTimeZone(0);
endDate.add(Calendar.MINUTE, -20);
fs.setEndTime(endDate.getTime());
fs.setGracePeriod(10);
BackDoor.editFeedbackSession(fs);

submitPage.fillResponseTextBox(1, 0, "this is a response edited during grace period,but submitted after grace period");
submitPage.clickSubmitButton();
submitPage.verifyHtmlMainContent("/studentFeedbackQuestionSubmitPageDeadLineExceeded.html");
a-Testing p.Medium

All 3 comments

This issue is because of the way HtmlHelper's replaceUnpredictableValuesWithPlaceholders() deals with replacing the current datetime with a placeholder.

Essentially, This line in HtmlHelper is responsible as it takes the first part of the date from the current time and then adds a REGEX for the hours, minutes and seconds. I guess a better alternative would be to check for all times within five minutes of the current date. So an implementation of a dynamic REGEX that even allows for different dates _if necessary_ (test runs across midnight), etc. Or perhaps an easier fix would be to just indiscriminately allow a date range of +/- 1 day from the current date and leave the existing mechanism as it is. (I don't think any of our test data otherwise uses dates that might be affected by the latter approach).

@whipermr5 this issue is close to the point you brought up in https://github.com/TEAMMATES/teammates/pull/7715#issuecomment-316595294.

BTW: @damithc Issue should be renamed to StudentFeedbackSubmitPageUiTest: prevent... as the original file no longer exists and this test is doing something similar. And the new relevant lines of code in that UI test are lines 93-97. Also, the test now sets the current time to 1 minute before the current time, NOT 20 minutes as specified in the issue description. (PS: Not sure exactly when in the repo's history the file from the original issue was removed, but I don't think it's present in the current codebase).

I feel if it's just one minute in StudentFeedbackSubmitPageUiTest, then this isn't much of an issue (there's only a one-minute window out of 24 hours in which the test would fail). The original issue was bigger as it had a twenty-minute window. @damithc should I close this issue?

@damithc should I close this issue?

Yes. let's close if that's the case.

Was this page helpful?
0 / 5 - 0 ratings