-
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.
Implemented groups and topic groups Co-authored-by: Karol Szapsza <[email protected]>
- Loading branch information
1 parent
6e514ef
commit ec27914
Showing
72 changed files
with
1,930 additions
and
589 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
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
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
51 changes: 51 additions & 0 deletions
51
hermes-console-vue/src/composables/constraints/use-constraints/useConstraints.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,51 @@ | ||
import { computed, ref } from 'vue'; | ||
import { fetchConstraints as getConstraints } from '@/api/hermes-client'; | ||
import type { Constraint, ConstraintsConfig } from '@/api/constraints'; | ||
import type { Ref } from 'vue'; | ||
|
||
export interface UseConstraints { | ||
topicConstraints: Ref<Record<string, Constraint> | undefined>; | ||
subscriptionConstraints: Ref<Record<string, Constraint> | undefined>; | ||
loading: Ref<boolean>; | ||
error: Ref<UseConstraintsErrors>; | ||
} | ||
|
||
export interface UseConstraintsErrors { | ||
fetchConstraints: Error | null; | ||
} | ||
|
||
export function useConstraints(): UseConstraints { | ||
const constraints = ref<ConstraintsConfig>(); | ||
const error = ref<UseConstraintsErrors>({ | ||
fetchConstraints: null, | ||
}); | ||
const loading = ref(false); | ||
|
||
const topicConstraints = computed((): Record<string, Constraint> => { | ||
return constraints.value?.topicConstraints ?? {}; | ||
}); | ||
|
||
const subscriptionConstraints = computed((): Record<string, Constraint> => { | ||
return constraints.value?.subscriptionConstraints ?? {}; | ||
}); | ||
|
||
const fetchConstraints = async () => { | ||
try { | ||
loading.value = true; | ||
constraints.value = (await getConstraints()).data; | ||
} catch (e) { | ||
error.value.fetchConstraints = e as Error; | ||
} finally { | ||
loading.value = false; | ||
} | ||
}; | ||
|
||
fetchConstraints(); | ||
|
||
return { | ||
topicConstraints, | ||
subscriptionConstraints, | ||
loading, | ||
error, | ||
}; | ||
} |
69 changes: 69 additions & 0 deletions
69
...console-vue/src/composables/consumer-groups/use-consumer-groups/useConsumerGroups.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,69 @@ | ||
import { afterEach } from 'vitest'; | ||
import { dummyConsumerGroups } from '@/dummy/consumerGroups'; | ||
import { dummySubscription } from '@/dummy/subscription'; | ||
import { dummyTopic } from '@/dummy/topic'; | ||
import { | ||
fetchConsumerGroupsErrorHandler, | ||
fetchConsumerGroupsHandler, | ||
} from '@/mocks/handlers'; | ||
import { setupServer } from 'msw/node'; | ||
import { useConsumerGroups } from '@/composables/consumer-groups/use-consumer-groups/useConsumerGroups'; | ||
import { waitFor } from '@testing-library/vue'; | ||
|
||
describe('useConsumerGroups', () => { | ||
const topicName = dummyTopic.name; | ||
const subscriptionName = dummySubscription.name; | ||
|
||
const server = setupServer( | ||
fetchConsumerGroupsHandler({ | ||
consumerGroups: dummyConsumerGroups, | ||
topicName, | ||
subscriptionName, | ||
}), | ||
); | ||
|
||
afterEach(() => { | ||
server.resetHandlers(); | ||
}); | ||
|
||
it('should fetch consumerGroups details from Hermes API', async () => { | ||
// given | ||
server.listen(); | ||
|
||
// when | ||
const { consumerGroups, loading, error } = useConsumerGroups( | ||
topicName, | ||
subscriptionName, | ||
); | ||
|
||
// then | ||
expect(loading.value).toBeTruthy(); | ||
|
||
await waitFor(() => { | ||
expect(loading.value).toBeFalsy(); | ||
expect(error.value.fetchConsumerGroups).toBeNull(); | ||
expect(consumerGroups.value).toEqual(consumerGroups.value); | ||
}); | ||
}); | ||
|
||
it('should set error to true on consumerGroups endpoint failure', async () => { | ||
// given | ||
server.use( | ||
fetchConsumerGroupsErrorHandler({ | ||
errorCode: 500, | ||
topicName, | ||
subscriptionName, | ||
}), | ||
); | ||
server.listen(); | ||
|
||
// when | ||
const { loading, error } = useConsumerGroups(topicName, subscriptionName); | ||
|
||
// then | ||
await waitFor(() => { | ||
expect(loading.value).toBeFalsy(); | ||
expect(error.value.fetchConsumerGroups).not.toBeNull(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.