Skip to content

Commit bba0c57

Browse files
committed
feat: adding test for create e-service page + add submit for step two
1 parent 87b9078 commit bba0c57

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

src/pages/ProviderEServiceCreatePage/__test__/ProviderEServiceCreate.test.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mockUseJwt, renderWithApplicationContext } from '@/utils/testing.utils'
22
import ProviderEServiceCreatePage from '../ProviderEServiceCreate.page'
3-
import { screen } from '@testing-library/react'
3+
import { screen, waitFor } from '@testing-library/react'
4+
import userEvent from '@testing-library/user-event'
45

56
mockUseJwt()
67

@@ -15,4 +16,31 @@ describe('Provider E-service create page', () => {
1516
expect(screen.getByText('create.step1.delegationSection.title'))
1617
expect(screen.getByText('create.step1.isSignalHubEnabled.title'))
1718
})
19+
20+
it('Should navigate steps', () => {
21+
const user = userEvent.setup()
22+
renderWithApplicationContext(<ProviderEServiceCreatePage />, {
23+
withRouterContext: true,
24+
withReactQueryContext: true,
25+
})
26+
27+
const nameInput = screen.getByLabelText(/eserviceNameField/i)
28+
user.type(nameInput, 'My test eservice')
29+
30+
const descriptionInput = screen.getByLabelText(/eserviceTechnologyField/i)
31+
user.type(descriptionInput, 'This is a test description for the eservice')
32+
33+
// const noPersonalDataRadio = screen.getByLabelText(/eservicePersonalDataField.*.option.false/i)
34+
// user.click(noPersonalDataRadio)
35+
//
36+
// expect(noPersonalDataRadio).toBeChecked()
37+
38+
const nextButton = screen.getByText(/forwardWithSaveBtn/i)
39+
40+
user.click(nextButton)
41+
42+
waitFor(() => {
43+
expect(screen.getByText(/step2.thresholdSection.title/i)).toBeInTheDocument()
44+
})
45+
})
1846
})

src/pages/ProviderEServiceCreatePage/components/EServiceCreateStepThresholds/EServiceCreateStepThresholds.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ export const EServiceCreateStepThresholds: React.FC<ActiveStepProps> = () => {
130130

131131
const newDescriptorData: ProducerEServiceDescriptor = {
132132
...descriptor,
133-
dailyCallsPerConsumer: values.dailyCallsPerConsumer,
134-
dailyCallsTotal: values.dailyCallsTotal,
133+
dailyCallsPerConsumer: values.dailyCallsPerConsumer ?? 1,
134+
dailyCallsTotal: values.dailyCallsTotal ?? 1,
135135
attributes,
136136
}
137137

@@ -141,22 +141,23 @@ export const EServiceCreateStepThresholds: React.FC<ActiveStepProps> = () => {
141141
return
142142
}
143143

144-
// TODO: Update the eservide
145-
//
146-
// const payload: UpdateEServiceDescriptorSeed & {
147-
// eserviceId: string
148-
// descriptorId: string
149-
// } = {
150-
// dailyCallsPerConsumer: descriptor.dailyCallsPerConsumer,
151-
// dailyCallsTotal: descriptor.dailyCallsTotal,
152-
// agreementApprovalPolicy: descriptor.agreementApprovalPolicy,
153-
// description: descriptor.description,
154-
// attributes: remapDescriptorAttributesToDescriptorAttributesSeed(attributes),
155-
// eserviceId: descriptor.eservice.id,
156-
// descriptorId: descriptor.id,
157-
// }
158-
//
159-
// updateVersionDraft(payload, { onSuccess: forward })
144+
// TODO: Check if it is correct to default some fields
145+
const payload: UpdateEServiceDescriptorSeed & {
146+
eserviceId: string
147+
descriptorId: string
148+
} = {
149+
audience: [],
150+
voucherLifespan: 0,
151+
dailyCallsPerConsumer: descriptor.dailyCallsPerConsumer,
152+
dailyCallsTotal: descriptor.dailyCallsTotal,
153+
agreementApprovalPolicy: descriptor.agreementApprovalPolicy,
154+
description: descriptor.description,
155+
attributes: remapDescriptorAttributesToDescriptorAttributesSeed(attributes),
156+
eserviceId: descriptor.eservice.id,
157+
descriptorId: descriptor.id,
158+
}
159+
160+
updateVersionDraft(payload, { onSuccess: forward })
160161
}
161162

162163
return (

0 commit comments

Comments
 (0)