Skip to content

Commit

Permalink
Merge pull request #6178 from espoon-voltti/child-documents-report
Browse files Browse the repository at this point in the history
Pedagogiset asiakirjat-raportti
  • Loading branch information
Joosakur authored Jan 8, 2025
2 parents 0432360 + 1fa16b6 commit f18c4d9
Show file tree
Hide file tree
Showing 16 changed files with 787 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/e2e-test/pages/citizen/citizen-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class CitizenMessageEditor extends Element {
for (const recipient of recipients) {
await this.#recipientSelection.fillAndSelectFirst(recipient)
}
await this.#recipientSelection.click()
await this.#recipientSelection.close()
}

async assertNoRecipients() {
Expand Down
44 changes: 43 additions & 1 deletion frontend/src/e2e-test/pages/employee/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import assert from 'assert'

import { ApplicationStatus } from 'lib-common/generated/api-types/application'
import { DaycareId, GroupId } from 'lib-common/generated/api-types/shared'
import LocalDate from 'lib-common/local-date'

import { captureTextualDownload } from '../../browser'
Expand All @@ -20,7 +21,8 @@ import {
StaticChip,
TextInput,
Element,
ElementCollection
ElementCollection,
TreeDropdown
} from '../../utils/page'

export default class ReportsPage {
Expand Down Expand Up @@ -745,6 +747,46 @@ export class ChildAttendanceReservationByChildReport {
}
}

export class ChildDocumentsReport {
unitSelector: MultiSelect
templateSelector: TreeDropdown

constructor(private page: Page) {
this.unitSelector = new MultiSelect(page.findByDataQa('unit-select'))
this.templateSelector = new TreeDropdown(
page.findByDataQa('template-select')
)
}

getUnitRow(id: DaycareId) {
const row = this.page.findByDataQa(`unit-row-${id}`)
return {
name: row.findByDataQa('name'),
drafts: row.findByDataQa('drafts-count'),
prepared: row.findByDataQa('prepared-count'),
completed: row.findByDataQa('completed-count'),
noDocuments: row.findByDataQa('no-documents-count'),
total: row.findByDataQa('total-count')
}
}

async toggleUnitRowGroups(id: DaycareId) {
await this.page.findByDataQa(`unit-${id}-toggle-groups`).click()
}

getGroupRow(id: GroupId) {
const row = this.page.findByDataQa(`group-row-${id}`)
return {
name: row.findByDataQa('name'),
drafts: row.findByDataQa('drafts-count'),
prepared: row.findByDataQa('prepared-count'),
completed: row.findByDataQa('completed-count'),
noDocuments: row.findByDataQa('no-documents-count'),
total: row.findByDataQa('total-count')
}
}
}

export class StartingPlacementsReport {
constructor(private page: Page) {}

Expand Down
80 changes: 80 additions & 0 deletions frontend/src/e2e-test/specs/5_employee/child-documents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
DocumentTemplatesListPage
} from '../../pages/employee/documents/document-templates'
import EmployeeNav from '../../pages/employee/employee-nav'
import { ChildDocumentsReport } from '../../pages/employee/reports'
import { waitUntilEqual } from '../../utils'
import { Page } from '../../utils/page'
import { employeeLogin } from '../../utils/user'
Expand Down Expand Up @@ -236,4 +237,83 @@ describe('Employee - Child documents', () => {
await childDocument.editButton.click()
await childDocument.previewButton.click()
})

test('Child documents report shows document status', async () => {
const daycareGroup = await Fixture.daycareGroup({
daycareId: testDaycare.id
}).save()
const template = await Fixture.documentTemplate({
type: 'VASU',
published: true,
name: 'Vasu 2022-2023',
placementTypes: ['DAYCARE']
}).save()

const child1 = await Fixture.person().saveChild()
const placement1 = await Fixture.placement({
childId: child1.id,
unitId: testDaycare.id,
type: 'DAYCARE',
startDate: now.toLocalDate().subYears(1),
endDate: now.toLocalDate().addYears(1)
}).save()
await Fixture.groupPlacement({
daycareGroupId: daycareGroup.id,
daycarePlacementId: placement1.id,
startDate: now.toLocalDate().subYears(1),
endDate: now.toLocalDate().addYears(1)
}).save()

const child2 = await Fixture.person({
ssn: null
}).saveChild()
const placement2 = await Fixture.placement({
childId: child2.id,
unitId: testDaycare.id,
type: 'DAYCARE',
startDate: now.toLocalDate().subYears(1),
endDate: now.toLocalDate().addYears(1)
}).save()
await Fixture.groupPlacement({
daycareGroupId: daycareGroup.id,
daycarePlacementId: placement2.id,
startDate: now.toLocalDate().subYears(1),
endDate: now.toLocalDate().addYears(1)
}).save()

await Fixture.childDocument({
childId: child1.id,
templateId: template.id,
status: 'DRAFT'
}).save()

page = await Page.open({ mockedTime: now })
await employeeLogin(page, unitSupervisor)
await page.goto(`${config.employeeUrl}/reports/child-documents`)

const report = new ChildDocumentsReport(page)
await report.unitSelector.fillAndSelectFirst(testDaycare.name)
await report.unitSelector.close()
await report.templateSelector.open()
await report.templateSelector.expandAll()
await report.templateSelector.option(template.id).check()
await report.templateSelector.close()

const unitRow = report.getUnitRow(testDaycare.id)
await unitRow.name.assertTextEquals(testDaycare.name)
await unitRow.drafts.assertTextEquals('1')
await unitRow.prepared.assertTextEquals('0')
await unitRow.completed.assertTextEquals('0')
await unitRow.noDocuments.assertTextEquals('1')
await unitRow.total.assertTextEquals('2')

await report.toggleUnitRowGroups(testDaycare.id)
const groupRow = report.getGroupRow(daycareGroup.id)
await groupRow.name.assertTextEquals(daycareGroup.name)
await groupRow.drafts.assertTextEquals('1')
await groupRow.prepared.assertTextEquals('0')
await groupRow.completed.assertTextEquals('0')
await groupRow.noDocuments.assertTextEquals('1')
await groupRow.total.assertTextEquals('2')
})
})
2 changes: 1 addition & 1 deletion frontend/src/e2e-test/utils/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class MultiSelect extends Element {
}

async close() {
await this.#input.click()
await this.locator.page().keyboard.press('Escape')
}

async selectFirst() {
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/employee-frontend/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import AttendanceReservation from './components/reports/AttendanceReservation'
import AttendanceReservationByChild from './components/reports/AttendanceReservationByChild'
import ReportChildAgeLanguage from './components/reports/ChildAgeLanguage'
import ChildAttendanceReport from './components/reports/ChildAttendanceReport'
import ReportChildDocuments from './components/reports/ChildDocumentsReport'
import ReportChildrenInDifferentAddress from './components/reports/ChildrenInDifferentAddress'
import ReportCustomerFees from './components/reports/CustomerFees'
import ReportDecisions from './components/reports/Decisions'
Expand Down Expand Up @@ -615,6 +616,14 @@ export default createBrowserRouter(
</EmployeeRoute>
)
},
{
path: '/reports/child-documents',
element: (
<EmployeeRoute title="reports">
<ReportChildDocuments />
</EmployeeRoute>
)
},
{
path: '/reports/assistance-needs-and-actions',
element: (
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/employee-frontend/components/Reports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,20 @@ export default React.memo(function Reports() {
/>
)
}
: null,
reports.has('CHILD_DOCUMENTS')
? {
name: i18n.reports.childDocuments.title,
item: (
<Report
data-qa="report-child-documents"
path="/reports/child-documents"
color={colors.main.m2}
icon={faFileAlt}
i18n={i18n.reports.childDocuments}
/>
)
}
: null
]

Expand Down
Loading

0 comments on commit f18c4d9

Please sign in to comment.