Skip to content

Commit 07210ef

Browse files
aaronlee777jeffredodd
authored andcommitted
fix: fix tests
1 parent 2e29ef6 commit 07210ef

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/components/Terminations/TerminationSummary/TerminationSummary.test.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('TerminationSummary', () => {
135135
renderWithProviders(<TerminationSummary {...defaultProps} />)
136136

137137
await waitFor(() => {
138-
expect(screen.getByRole('button', { name: 'Edit dismissal' })).toBeInTheDocument()
138+
expect(screen.getByRole('button', { name: 'Edit termination' })).toBeInTheDocument()
139139
})
140140
})
141141

@@ -152,7 +152,7 @@ describe('TerminationSummary', () => {
152152
expect(screen.getByText('John Doe has been successfully terminated')).toBeInTheDocument()
153153
})
154154

155-
expect(screen.queryByRole('button', { name: 'Edit dismissal' })).not.toBeInTheDocument()
155+
expect(screen.queryByRole('button', { name: 'Edit termination' })).not.toBeInTheDocument()
156156
})
157157

158158
it('shows run payroll button when dismissal payroll was selected', async () => {
@@ -165,7 +165,7 @@ describe('TerminationSummary', () => {
165165
renderWithProviders(<TerminationSummary {...defaultProps} />)
166166

167167
await waitFor(() => {
168-
expect(screen.getByRole('button', { name: 'Run dismissal payroll' })).toBeInTheDocument()
168+
expect(screen.getByRole('button', { name: 'Run termination payroll' })).toBeInTheDocument()
169169
})
170170
})
171171

@@ -183,7 +183,7 @@ describe('TerminationSummary', () => {
183183
})
184184

185185
expect(
186-
screen.queryByRole('button', { name: 'Run dismissal payroll' }),
186+
screen.queryByRole('button', { name: 'Run termination payroll' }),
187187
).not.toBeInTheDocument()
188188
})
189189
})
@@ -207,6 +207,12 @@ describe('TerminationSummary', () => {
207207

208208
await user.click(screen.getByRole('button', { name: 'Cancel termination' }))
209209

210+
await waitFor(() => {
211+
expect(screen.getByRole('button', { name: 'Yes, cancel termination' })).toBeInTheDocument()
212+
})
213+
214+
await user.click(screen.getByRole('button', { name: 'Yes, cancel termination' }))
215+
210216
await waitFor(() => {
211217
expect(onEvent).toHaveBeenCalledWith(
212218
componentEvents.EMPLOYEE_TERMINATION_CANCELLED,
@@ -227,10 +233,10 @@ describe('TerminationSummary', () => {
227233
renderWithProviders(<TerminationSummary {...defaultProps} />)
228234

229235
await waitFor(() => {
230-
expect(screen.getByRole('button', { name: 'Edit dismissal' })).toBeInTheDocument()
236+
expect(screen.getByRole('button', { name: 'Edit termination' })).toBeInTheDocument()
231237
})
232238

233-
await user.click(screen.getByRole('button', { name: 'Edit dismissal' }))
239+
await user.click(screen.getByRole('button', { name: 'Edit termination' }))
234240

235241
expect(onEvent).toHaveBeenCalledWith(
236242
componentEvents.EMPLOYEE_TERMINATION_EDIT,
@@ -250,10 +256,10 @@ describe('TerminationSummary', () => {
250256
renderWithProviders(<TerminationSummary {...defaultProps} />)
251257

252258
await waitFor(() => {
253-
expect(screen.getByRole('button', { name: 'Run dismissal payroll' })).toBeInTheDocument()
259+
expect(screen.getByRole('button', { name: 'Run termination payroll' })).toBeInTheDocument()
254260
})
255261

256-
await user.click(screen.getByRole('button', { name: 'Run dismissal payroll' }))
262+
await user.click(screen.getByRole('button', { name: 'Run termination payroll' }))
257263

258264
expect(onEvent).toHaveBeenCalledWith(
259265
componentEvents.EMPLOYEE_TERMINATION_RUN_PAYROLL,

src/test/setup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ afterAll(() => {
5050
// Mock scrollIntoView
5151
Element.prototype.scrollIntoView = vi.fn()
5252

53+
// Mock HTMLDialogElement methods (jsdom doesn't support them)
54+
HTMLDialogElement.prototype.showModal = vi.fn(function (this: HTMLDialogElement) {
55+
this.open = true
56+
})
57+
HTMLDialogElement.prototype.close = vi.fn(function (this: HTMLDialogElement) {
58+
this.open = false
59+
})
60+
5361
expect.extend(toHaveNoViolations)
5462

5563
// Make accessibility testing utilities globally available

0 commit comments

Comments
 (0)