Skip to content

Commit bab63a0

Browse files
committed
Fixed EventConfigSourceTable test
1 parent 7116f95 commit bab63a0

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

ui/tests/components/EventConfiguration/EventConfigSourceTable.test.ts

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ describe('EventConfigSourceTable.vue', () => {
2828

2929
beforeEach(async () => {
3030
vi.clearAllMocks()
31-
// vi.useFakeTimers()
3231

3332
const pinia = createTestingPinia({
3433
createSpy: vi.fn,
@@ -90,45 +89,19 @@ describe('EventConfigSourceTable.vue', () => {
9089
})
9190

9291
afterEach(async () => {
93-
const startTime = Date.now()
94-
console.log('[afterEach] Starting cleanup...')
95-
96-
// // Run any pending timers before cleanup
97-
// if (vi.isFakeTimers()) {
98-
// console.log('[afterEach] Running pending timers...')
99-
// const timerStart = Date.now()
100-
// vi.runOnlyPendingTimers()
101-
// console.log(`[afterEach] Timers completed in ${Date.now() - timerStart}ms`)
102-
// }
103-
10492
// Unmount wrapper to clean up watchers and event listeners
10593
if (wrapper) {
106-
console.log('[afterEach] Unmounting wrapper...')
107-
const unmountStart = Date.now()
10894
wrapper.unmount()
109-
console.log(`[afterEach] Unmount completed in ${Date.now() - unmountStart}ms`)
11095
}
11196

11297
// Flush any remaining promises
113-
console.log('[afterEach] Flushing promises...')
114-
const flushStart = Date.now()
11598
await flushPromises()
116-
console.log(`[afterEach] Promises flushed in ${Date.now() - flushStart}ms`)
11799

118100
// Additional nextTick to ensure all updates are processed
119-
console.log('[afterEach] Waiting for nextTick...')
120-
const nextTickStart = Date.now()
121101
await nextTick()
122-
console.log(`[afterEach] nextTick completed in ${Date.now() - nextTickStart}ms`)
123102

124103
// Restore mocks and timers
125-
console.log('[afterEach] Restoring mocks and timers...')
126-
const restoreStart = Date.now()
127104
vi.restoreAllMocks()
128-
// vi.useRealTimers()
129-
console.log(`[afterEach] Restore completed in ${Date.now() - restoreStart}ms`)
130-
131-
console.log(`[afterEach] Total cleanup time: ${Date.now() - startTime}ms`)
132105
})
133106

134107
it('renders correctly and calls fetchEventConfigs on mount', () => {
@@ -231,21 +204,24 @@ describe('EventConfigSourceTable.vue', () => {
231204
expect(rows[1].text()).toContain('Disabled')
232205
})
233206

234-
// it('handles search input changes with debouncing and calls onChangeSourcesSearchTerm', async () => {
235-
// vi.useFakeTimers()
207+
// This test is skipped because it relies on debouncing which can be tricky to test reliably.
208+
// Consider refactoring the search input handling to make it more testable or use a library like
209+
// @vue/test-utils' `setValue` with `flushPromises` to handle the debounce timing.
210+
it.skip('handles search input changes with debouncing and calls onChangeSourcesSearchTerm', async () => {
211+
vi.useFakeTimers()
236212

237-
// store.sources = [mockSource]
238-
// await wrapper.vm.$nextTick()
213+
store.sources = [mockSource]
214+
await wrapper.vm.$nextTick()
239215

240-
// const searchInput = wrapper.get('[data-test="search-input"] .feather-input')
241-
// await searchInput.setValue('test')
242-
// vi.advanceTimersByTime(500)
243-
// await wrapper.vm.$nextTick()
216+
const searchInput = wrapper.get('[data-test="search-input"] .feather-input')
217+
await searchInput.setValue('test')
218+
vi.advanceTimersByTime(500)
219+
await wrapper.vm.$nextTick()
244220

245-
// expect(store.onChangeSourcesSearchTerm).toHaveBeenCalledWith('test')
221+
expect(store.onChangeSourcesSearchTerm).toHaveBeenCalledWith('test')
246222

247-
// vi.useRealTimers()
248-
// })
223+
vi.useRealTimers()
224+
})
249225

250226
it('clicks view details button in row and navigates correctly', async () => {
251227
store.sources = [mockSource]

0 commit comments

Comments
 (0)