Skip to content

Commit

Permalink
#3024: Fix tests and import Report issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cemalettin-work committed Nov 26, 2020
1 parent 26cd7af commit 0ec9c17
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
7 changes: 6 additions & 1 deletion client/src/pages/reports/EngagementDateFormPartial.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ const EngagementDatePartialFormWithDuration = ({
disabled={isAllDay}
/>
</Col>
<Col sm={2} style={{ marginTop: "2.2em", maxWidth: "max-content" }}>
<Col
sm={2}
style={{ marginTop: "2.2em", maxWidth: "max-content" }}
id="all-day-col"
>
<Checkbox
checked={isAllDay}
label="All Day"
id="all-day"
onChange={e => {
setIsAllDay(e.target.checked)
if (e.target.checked) {
Expand Down
4 changes: 4 additions & 0 deletions client/tests/webdriver/pages/createReport.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class CreateReport extends Page {
return browser.$("#duration")
}

get allDayCheckbox() {
return browser.$("#all-day-col label")
}

get engagementInformationTitle() {
return browser.$('//span[text()="Engagement information"]')
}
Expand Down
12 changes: 11 additions & 1 deletion client/tests/webdriver/specs/createReport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ describe("Create report form page", () => {
})

it("Should be able to prevent invalid duration values", () => {
// make it not an all day first to enable duration input
CreateReport.allDayCheckbox.click()
CreateReport.duration.waitForClickable()

CreateReport.duration.setValue(INVALID_ENGAGEMENT_DURATION_1)
browser.waitUntil(
() => {
Expand All @@ -48,7 +52,13 @@ describe("Create report form page", () => {
timeoutMsg: "Large positive duration value was not sliced "
}
)
CreateReport.duration.setValue(INVALID_ENGAGEMENT_DURATION_2)

// remove first value, otherwise appends the value
CreateReport.duration.setValue(
"\uE003".repeat(VALID_ENGAGEMENT_DURATION_1) +
INVALID_ENGAGEMENT_DURATION_2
)

browser.waitUntil(
() => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from "chai"
import moment from "moment"
import Settings from "../../../platform/node/settings"
import CreateReport from "../pages/report/createReport.page"
import EditReport from "../pages/report/editReport.page"
import ShowReport from "../pages/report/showReport.page"
Expand All @@ -12,9 +11,7 @@ function isEngagementAllDay(report) {
}

function getEngagementDateFormat() {
return Settings.engagementsIncludeTimeAndDuration
? Settings.dateFormats.forms.displayLong.withTime
: Settings.dateFormats.forms.displayLong.date
return "dddd, D MMMM YYYY @ HH:mm"
}

function getAllDayIndicator(report) {
Expand All @@ -28,10 +25,7 @@ function getFormattedEngagementDate(report) {

const start = moment(report.engagementDate)
if (isEngagementAllDay(report)) {
return Settings.engagementsIncludeTimeAndDuration
? start.format(Settings.dateFormats.forms.displayLong.date) +
getAllDayIndicator(report)
: start.format(getEngagementDateFormat())
return start.format("dddd, D MMMM YYYY") + getAllDayIndicator(report)
}

const end = moment(report.engagementDate).add(report.duration, "minutes")
Expand Down

0 comments on commit 0ec9c17

Please sign in to comment.