Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lomakyselyraportin tuki ryhmäkohtaisille tuloksille #6046

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/src/e2e-test/pages/employee/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,13 @@ export class PreschoolApplicationReport {
}

export class HolidayPeriodAttendanceReport {
constructor(private page: Page) {}
sendButton: Element
groupSelector: MultiSelect

constructor(private page: Page) {
this.sendButton = this.page.findByDataQa('send-button')
this.groupSelector = new MultiSelect(this.page.findByDataQa('group-select'))
}

async selectUnit(unitName: string) {
const unitSelector = new Combobox(this.page.findByDataQa('unit-select'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {
createDefaultServiceNeedOptions,
resetServiceState
} from '../../generated/api-clients'
import { DevDaycare, DevEmployee, DevPerson } from '../../generated/api-types'
import {
DevDaycare,
DevDaycareGroup,
DevEmployee,
DevPerson
} from '../../generated/api-types'
import EmployeeNav from '../../pages/employee/employee-nav'
import ReportsPage from '../../pages/employee/reports'
import { Page } from '../../utils/page'
Expand All @@ -23,7 +28,9 @@ import { employeeLogin } from '../../utils/user'
const mockedToday = LocalDate.of(2024, 9, 9)
let period: HolidayPeriod
let child: DevPerson
let child2: DevPerson
let unit: DevDaycare
let group: DevDaycareGroup
const dailyTime = new TimeRange(LocalTime.of(8, 0), LocalTime.of(18, 0))

beforeEach(async () => {
Expand Down Expand Up @@ -52,20 +59,48 @@ beforeEach(async () => {
],
enabledPilotFeatures: ['MESSAGING', 'MOBILE', 'RESERVATIONS']
}).save()

group = await Fixture.daycareGroup({
daycareId: unit.id,
name: 'Testgroup'
}).save()

child = await Fixture.person({
firstName: 'Lasse',
lastName: 'Lomailija',
dateOfBirth: mockedToday.subDays(2).subYears(2)
}).saveChild()

await Fixture.placement({
child2 = await Fixture.person({
firstName: 'Riku',
lastName: 'Ryhmätön',
ssn: null,
dateOfBirth: mockedToday.subDays(2).subYears(4)
}).saveChild()

const placement = await Fixture.placement({
type: 'DAYCARE',
childId: child.id,
unitId: unit.id,
startDate: period.reservationsOpenOn,
endDate: period.period.end
}).save()

await Fixture.placement({
type: 'DAYCARE',
childId: child2.id,
unitId: unit.id,
startDate: period.reservationsOpenOn,
endDate: period.period.end
}).save()

await Fixture.groupPlacement({
daycarePlacementId: placement.id,
startDate: placement.startDate,
endDate: placement.endDate,
daycareGroupId: group.id
}).save()

await Fixture.assistanceFactor({
childId: child.id,
capacityFactor: 2.5,
Expand All @@ -77,12 +112,19 @@ beforeEach(async () => {
validDuring: period.period
}).save()

//Lasse
await Fixture.absence({
absenceType: 'OTHER_ABSENCE',
absenceCategory: 'BILLABLE',
date: mockedToday,
childId: child.id
}).save()
await Fixture.absence({
absenceType: 'OTHER_ABSENCE',
absenceCategory: 'BILLABLE',
date: mockedToday.addDays(4),
childId: child.id
}).save()
await Fixture.attendanceReservationRaw({
childId: child.id,
date: mockedToday.addDays(1),
Expand All @@ -93,16 +135,28 @@ beforeEach(async () => {
date: mockedToday.addDays(3),
range: null
}).save()

//Riku
await Fixture.attendanceReservationRaw({
childId: child2.id,
date: mockedToday.addDays(1),
range: null
}).save()
await Fixture.attendanceReservationRaw({
childId: child2.id,
date: mockedToday.addDays(2),
range: null
}).save()
await Fixture.absence({
absenceType: 'OTHER_ABSENCE',
absenceCategory: 'BILLABLE',
date: mockedToday.addDays(4),
childId: child.id
date: mockedToday,
childId: child2.id
}).save()
})

describe('Holiday period attendance report', () => {
test('correct report data is shown', async () => {
test('correct report data is shown for full unit', async () => {
const admin = await Fixture.employee().admin().save()

const page = await Page.open({
Expand All @@ -112,6 +166,74 @@ describe('Holiday period attendance report', () => {
const report = await navigateToReport(page, admin)
await report.selectUnit(unit.name)
await report.selectPeriod(period.period.format())
await report.sendButton.click()

const childName = `${child.lastName} ${child.firstName.split(' ')[0]}`
const childName2 = `${child2.lastName} ${child2.firstName.split(' ')[0]}`
const initialExpectation = [
{
date: 'Ma 09.09.2024',
presentChildren: [],
assistanceChildren: [],
coefficientSum: '0,00',
staffCount: '0',
absenceCount: '2',
noResponseChildren: []
},
{
date: 'Ti 10.09.2024',
presentChildren: [childName, childName2],
assistanceChildren: [childName],
coefficientSum: '5,38',
staffCount: '1',
absenceCount: '0',
noResponseChildren: []
},
{
date: 'Ke 11.09.2024',
presentChildren: [childName2],
assistanceChildren: [],
coefficientSum: '1,00',
staffCount: '1',
absenceCount: '0',
noResponseChildren: [childName]
},
{
date: 'To 12.09.2024',
presentChildren: [childName],
assistanceChildren: [childName],
coefficientSum: '4,38',
staffCount: '1',
absenceCount: '0',
noResponseChildren: [childName2]
},
{
date: 'Pe 13.09.2024',
presentChildren: [],
assistanceChildren: [],
coefficientSum: '0,00',
staffCount: '0',
absenceCount: '1',
noResponseChildren: [childName2]
}
]

await report.assertRows(initialExpectation)
})

test('correct report data is shown for selected group', async () => {
const admin = await Fixture.employee().admin().save()

const page = await Page.open({
mockedTime: mockedToday.toHelsinkiDateTime(LocalTime.of(8, 0))
})

const report = await navigateToReport(page, admin)
await report.selectUnit(unit.name)
await report.selectPeriod(period.period.format())
await report.groupSelector.fillAndSelectFirst(group.name)
await report.sendButton.click()

const childName = `${child.lastName} ${child.firstName.split(' ')[0]}`
const initialExpectation = [
{
Expand Down
Loading
Loading