-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize zookeeper clusters with UI (#1888)
- Loading branch information
Showing
19 changed files
with
1,134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
hermes-console/src/composables/sync/use-sync/useSync.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
import { afterEach, describe, expect } from 'vitest'; | ||
import { createTestingPinia } from '@pinia/testing'; | ||
import { | ||
expectNotificationDispatched, | ||
notificationStoreSpy, | ||
} from '@/utils/test-utils'; | ||
import { setActivePinia } from 'pinia'; | ||
import { setupServer } from 'msw/node'; | ||
import { | ||
syncGroupHandler, | ||
syncSubscriptionHandler, | ||
syncTopicHandler, | ||
} from '@/mocks/handlers'; | ||
import { useSync } from '@/composables/sync/use-sync/useSync'; | ||
import { waitFor } from '@testing-library/vue'; | ||
|
||
describe('useSync', () => { | ||
const server = setupServer(); | ||
|
||
const pinia = createTestingPinia({ | ||
fakeApp: true, | ||
}); | ||
|
||
beforeEach(() => { | ||
setActivePinia(pinia); | ||
}); | ||
|
||
afterEach(() => { | ||
server.resetHandlers(); | ||
}); | ||
|
||
it('should show error notification when group sync fails', async () => { | ||
// given | ||
const groupName = 'group'; | ||
server.use(syncGroupHandler({ groupName, statusCode: 500 })); | ||
server.listen(); | ||
|
||
const notificationStore = notificationStoreSpy(); | ||
|
||
// when | ||
const { syncGroup } = useSync(); | ||
const result = await syncGroup(groupName, 'DC1'); | ||
|
||
// then | ||
expect(result).toBeFalsy(); | ||
|
||
await waitFor(() => { | ||
expectNotificationDispatched(notificationStore, { | ||
type: 'error', | ||
title: 'notifications.consistency.sync.failure', | ||
}); | ||
}); | ||
}); | ||
|
||
it('should show error notification when topic sync fails', async () => { | ||
// given | ||
const topicName = 'group.topic'; | ||
server.use(syncTopicHandler({ topicName, statusCode: 500 })); | ||
server.listen(); | ||
|
||
const notificationStore = notificationStoreSpy(); | ||
|
||
// when | ||
const { syncTopic } = useSync(); | ||
const result = await syncTopic(topicName, 'DC1'); | ||
|
||
// then | ||
expect(result).toBeFalsy(); | ||
|
||
await waitFor(() => { | ||
expectNotificationDispatched(notificationStore, { | ||
type: 'error', | ||
title: 'notifications.consistency.sync.failure', | ||
}); | ||
}); | ||
}); | ||
|
||
it('should show error notification when subscription sync fails', async () => { | ||
// given | ||
const topicName = 'group.topic'; | ||
const subscriptionName = 'subscription'; | ||
server.use( | ||
syncSubscriptionHandler({ topicName, subscriptionName, statusCode: 500 }), | ||
); | ||
server.listen(); | ||
|
||
const notificationStore = notificationStoreSpy(); | ||
|
||
// when | ||
const { syncSubscription } = useSync(); | ||
const result = await syncSubscription(topicName, subscriptionName, 'DC1'); | ||
|
||
// then | ||
expect(result).toBeFalsy(); | ||
|
||
await waitFor(() => { | ||
expectNotificationDispatched(notificationStore, { | ||
type: 'error', | ||
title: 'notifications.consistency.sync.failure', | ||
}); | ||
}); | ||
}); | ||
|
||
it('should show success notification when group sync is successful', async () => { | ||
const groupName = 'group'; | ||
|
||
server.use(syncGroupHandler({ groupName, statusCode: 200 })); | ||
server.listen(); | ||
|
||
const notificationStore = notificationStoreSpy(); | ||
|
||
// when | ||
const { syncGroup } = useSync(); | ||
const result = await syncGroup(groupName, 'DC1'); | ||
|
||
// then | ||
expect(result).toBeTruthy(); | ||
|
||
await waitFor(() => { | ||
expectNotificationDispatched(notificationStore, { | ||
type: 'success', | ||
text: 'notifications.consistency.sync.success', | ||
}); | ||
}); | ||
}); | ||
|
||
it('should show success notification when topic sync is successful', async () => { | ||
// given | ||
const topicName = 'group.topic'; | ||
server.use(syncTopicHandler({ topicName, statusCode: 200 })); | ||
server.listen(); | ||
|
||
const notificationStore = notificationStoreSpy(); | ||
|
||
// when | ||
const { syncTopic } = useSync(); | ||
const result = await syncTopic(topicName, 'DC1'); | ||
|
||
// then | ||
expect(result).toBeTruthy(); | ||
|
||
await waitFor(() => { | ||
expectNotificationDispatched(notificationStore, { | ||
type: 'success', | ||
text: 'notifications.consistency.sync.success', | ||
}); | ||
}); | ||
}); | ||
|
||
it('should show success notification when subscription sync is successful', async () => { | ||
// given | ||
const topicName = 'group.topic'; | ||
const subscriptionName = 'subscription'; | ||
server.use( | ||
syncSubscriptionHandler({ topicName, subscriptionName, statusCode: 200 }), | ||
); | ||
server.listen(); | ||
|
||
const notificationStore = notificationStoreSpy(); | ||
|
||
// when | ||
const { syncSubscription } = useSync(); | ||
const result = await syncSubscription(topicName, subscriptionName, 'DC1'); | ||
|
||
// then | ||
expect(result).toBeTruthy(); | ||
|
||
await waitFor(() => { | ||
expectNotificationDispatched(notificationStore, { | ||
type: 'success', | ||
text: 'notifications.consistency.sync.success', | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.