Skip to content

Commit ce8436f

Browse files
committed
commit WIP func tests #2970
1 parent 24aa18a commit ce8436f

8 files changed

+169
-0
lines changed

src/integration-test/groovy/au/org/ala/fieldcapture/ManagementUnitReportingSpec.groovy

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package au.org.ala.fieldcapture
22

33
import com.icegreen.greenmail.util.GreenMail
44
import com.icegreen.greenmail.util.GreenMailUtil
5+
import pages.DownloadReport
6+
import pages.ManagementUnitDownloadReport
57
import pages.ManagementUnitPage
68
import pages.ReportPage
79
import pages.ViewReportPage
@@ -223,4 +225,28 @@ class ManagementUnitReportingSpec extends StubbedCasSpec {
223225
reportsTabPane.reports[1].notRequired()
224226

225227
}
228+
229+
230+
def "A PDF can be genreated from report tab"() {
231+
setup:
232+
String managementUnitId = 'test_mu'
233+
loginAsUser('1', browser)
234+
235+
when: "Display the reporting tab and download the first report"
236+
to ManagementUnitPage, managementUnitId
237+
displayReportsTab()
238+
reportsTabPane.reports[0].downloadReport()
239+
240+
then:
241+
withWindow("print-report", {
242+
at ManagementUnitDownloadReport
243+
waitFor {
244+
printInstructions.displayed
245+
}
246+
closePrintInstructions()
247+
waitFor {
248+
!printInstructions.displayed
249+
}
250+
})
251+
}
226252
}

src/integration-test/groovy/au/org/ala/fieldcapture/OrganisationReportingSpec.groovy

+31
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.icegreen.greenmail.util.GreenMailUtil
55
import geb.module.FormElement
66
import pages.AdminTools
77
import pages.Organisation
8+
import pages.OrganisationDownloadReport
89
import pages.ReportPage
910
import pages.ViewReportPage
1011
import spock.lang.Shared
@@ -198,6 +199,36 @@ class OrganisationReportingSpec extends StubbedCasSpec {
198199

199200
}
200201

202+
def "A PDF can be generated from report tab"() {
203+
setup:
204+
loginAsReadOnlyUser(browser)
205+
206+
when:
207+
to Organisation, orgId
208+
209+
waitFor {
210+
reportingTab.click()
211+
}
212+
213+
then:
214+
waitFor { reportsTabPane.displayed }
215+
216+
when:
217+
reportsTabPane.reports[0].downloadReport()
218+
219+
then:
220+
withWindow("print-report", {
221+
at OrganisationDownloadReport
222+
waitFor {
223+
printInstructions.displayed
224+
}
225+
closePrintInstructions()
226+
waitFor {
227+
!printInstructions.displayed
228+
}
229+
})
230+
}
231+
201232
def "A user with the grant manager role can approve and return reports"() {
202233
setup:
203234
loginAsGrantManager(browser)

src/integration-test/groovy/au/org/ala/fieldcapture/RlpReportingSpec.groovy

+35
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package au.org.ala.fieldcapture
22

33
import com.icegreen.greenmail.util.GreenMail
44
import com.icegreen.greenmail.util.GreenMailUtil
5+
import pages.ProjectDownloadReport
56
import pages.ProjectIndex
67
import pages.RlpProjectPage
78
import pages.ReportPage
@@ -236,6 +237,40 @@ class RlpReportingSpec extends StubbedCasSpec {
236237
!projectReports.reports[0].notRequired()
237238
}
238239

240+
def "A PDF can be genreated from report tab"() {
241+
setup:
242+
String projectId = '1'
243+
loginAsUser('1', browser)
244+
245+
when:
246+
to RlpProjectPage, projectId
247+
248+
then:
249+
waitFor { at RlpProjectPage }
250+
251+
when:
252+
reportingTab.click()
253+
254+
then:
255+
waitFor { projectReports.displayed }
256+
257+
when:
258+
projectReports.reports[0].downloadReport()
259+
260+
then:
261+
withWindow("print-report", {
262+
at ProjectDownloadReport
263+
waitFor {
264+
printInstructions.displayed
265+
}
266+
closePrintInstructions()
267+
waitFor {
268+
!printInstructions.displayed
269+
}
270+
})
271+
272+
}
273+
239274
def "A project admin can submit the report"() {
240275
setup:
241276
String projectId = '1'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package pages
2+
3+
4+
import geb.Page
5+
6+
class ManagementUnitDownloadReport extends Page {
7+
static at = { title.startsWith("Core services report 1") }
8+
static url = "managementUnit/printableReport"
9+
10+
static content = {
11+
groundCoverPercentage { $("span[data-bind*=groundCoverPercent]") }
12+
printInstructions { $("#print-instructions") }
13+
}
14+
15+
def closePrintInstructions() {
16+
$("#print-instructions .btn-secondary").click()
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package pages
2+
3+
4+
import geb.Page
5+
6+
class OrganisationDownloadReport extends Page {
7+
static at = { title.startsWith("Regional capacity report 1") }
8+
static url = "organisation/printableReport"
9+
10+
static content = {
11+
groundCoverPercentage { $("span[data-bind*=groundCoverPercent]") }
12+
printInstructions { $("#print-instructions") }
13+
}
14+
15+
def closePrintInstructions() {
16+
$("#print-instructions .btn-secondary").click()
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package pages
2+
3+
4+
import geb.Page
5+
6+
class ProjectDownloadReport extends Page {
7+
static at = { title.startsWith("Year 2018/2019 - Quarter 1 Outputs Report") }
8+
static url = "project/printableReport"
9+
10+
static content = {
11+
groundCoverPercentage { $("span[data-bind*=groundCoverPercent]") }
12+
printInstructions { $("#print-instructions") }
13+
}
14+
15+
def closePrintInstructions() {
16+
$("#print-instructions .btn-secondary").click()
17+
}
18+
}

src/integration-test/groovy/pages/modules/ReportSummaryLine.groovy

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ReportSummaryLine extends Module {
1010
toDate { $('.report-end').text() }
1111
editLink { $('td.report-actions [data-bind*=editUrl]')}
1212
viewLink { $('td.report-actions [data-bind*=viewUrl]')}
13+
downloadLink { $('td.report-actions [data-bind*=downloadUrl]')}
1314
submitButton(required:false) { $('button[data-bind*="submitReport"]') }
1415
approveButton(required:false) { $('button[data-bind*=approveReport]') }
1516
returnButton(required:false) { $('button[data-bind*=rejectReport]') }
@@ -24,6 +25,10 @@ class ReportSummaryLine extends Module {
2425
viewLink.click()
2526
}
2627

28+
def downloadReport() {
29+
downloadLink.click()
30+
}
31+
2732
def markedAsComplete() {
2833
$('.badge[data-bind*="finished"]').displayed
2934
}

src/integration-test/resources/dataset_mu/loadDataSet.js

+18
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,23 @@ var orgReport1 = {
249249
"progress" : "started"
250250
}
251251

252+
var orgPerfReport = {
253+
"reportId" : "a02a527a-4377-40f0-86de-8eabe6weeknd",
254+
"dateCreated" : ISODate("2016-06-22T01:13:26.944Z"),
255+
"lastUpdated" : ISODate("2017-07-16T05:38:41.463Z"),
256+
"type" : "Performance Management Framework - Self Assessment",
257+
"organisationId" : "test_organisation",
258+
"name" : "2015 / 2016 Performance Management Framework - Self Assessment",
259+
"publicationStatus" : "unpublished",
260+
"status" : "active",
261+
"progress" : "finished",
262+
"fromDate" : ISODate("2015-07-01T14:00:00.000Z"),
263+
"toDate" : ISODate("2016-07-01T14:00:00.000Z"),
264+
"dueDate" : ISODate("2016-08-15T14:00:00.000Z"),
265+
"submissionDate" : ISODate("2016-07-01T14:00:00.000Z"),
266+
"category": "Performance Management Framework"
267+
}
268+
252269
var activity2 = {
253270
"activityId" : "xyz254bf-b4fe-481c-9324-6d65d9c7c0d8",
254271
"assessment" : false,
@@ -271,6 +288,7 @@ var activity2 = {
271288

272289

273290
db.report.insert(orgReport1);
291+
db.report.insert(orgPerfReport);
274292
db.activity.insert(activity2);
275293

276294
addSetting('meritfielddata.rlp.cs_report.submitted.emailSubject', 'Report submitted subject');

0 commit comments

Comments
 (0)