diff --git a/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.cy.ts b/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.cy.ts index fec582882b..76653c00c1 100644 --- a/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.cy.ts +++ b/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.cy.ts @@ -51,12 +51,14 @@ describe('', () => { method: 'GET', url: `${baseConfigKM.apiBaseUrl}/${baseConfigKM.workspace}/consumer_groups*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getConsumerGroups') } @@ -70,12 +72,14 @@ describe('', () => { method: 'GET', url: `${baseConfigKM.apiBaseUrl}/${configConsumerKM.workspace}/consumers/${configConsumerKM.consumerId}/consumer_groups*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getGroups') } @@ -674,12 +678,14 @@ describe('', () => { method: 'GET', url: `${baseConfigKonnect.apiBaseUrl}/api/runtime_groups/${baseConfigKonnect.controlPlaneId}/consumer_groups*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getConsumerGroups') } @@ -692,12 +698,14 @@ describe('', () => { method: 'GET', url: `${configConsumerKonnect.apiBaseUrl}/api/runtime_groups/${configConsumerKonnect.controlPlaneId}/consumers/${configConsumerKonnect.consumerId}/consumer_groups*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getGroups') } diff --git a/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.vue b/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.vue index e1c214a8f5..8fb3eca417 100644 --- a/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.vue +++ b/packages/entities/entities-consumer-groups/src/components/ConsumerGroupList.vue @@ -324,8 +324,7 @@ const filterConfig = computed['$props']['confi } as FuzzyMatchFilterConfig }) -const dataKeyName = computed((): string | undefined => isConsumerPage.value ? 'consumer_groups' : undefined) -const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value, dataKeyName.value) +const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value) const clearFilter = (): void => { filterQuery.value = '' diff --git a/packages/entities/entities-consumers/src/components/ConsumerList.cy.ts b/packages/entities/entities-consumers/src/components/ConsumerList.cy.ts index 92493a1b6f..786b43fa0f 100644 --- a/packages/entities/entities-consumers/src/components/ConsumerList.cy.ts +++ b/packages/entities/entities-consumers/src/components/ConsumerList.cy.ts @@ -51,12 +51,14 @@ describe('', () => { method: 'GET', url: `${baseConfigKM.apiBaseUrl}/${baseConfigKM.workspace}/consumers*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getConsumers') } @@ -70,12 +72,14 @@ describe('', () => { method: 'GET', url: `${baseConfigKM.apiBaseUrl}/${configGroupKM.workspace}/consumer_groups/${configGroupKM.consumerGroupId}/consumers*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getGroupConsumers') } @@ -674,12 +678,14 @@ describe('', () => { method: 'GET', url: `${baseConfigKonnect.apiBaseUrl}/api/runtime_groups/${baseConfigKonnect.controlPlaneId}/consumers*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getConsumers') } @@ -692,12 +698,14 @@ describe('', () => { method: 'GET', url: `${configGroupKonnect.apiBaseUrl}/api/runtime_groups/${configGroupKonnect.controlPlaneId}/consumer_groups/${configGroupKonnect.consumerGroupId}/consumers*`, }, - { - statusCode: 200, - body: { - data: params?.mockData ?? [], - total: params?.mockData?.length ?? 0, - }, + (req) => { + const size = req.query.size ? Number(req.query.size) : 30 + const offset = req.query.offset ? Number(req.query.offset) : 0 + + req.reply({ + statusCode: 200, + body: paginate(params?.mockData ?? [], size, offset), + }) }, ).as(params?.alias ?? 'getGroupConsumers') } diff --git a/packages/entities/entities-consumers/src/components/ConsumerList.vue b/packages/entities/entities-consumers/src/components/ConsumerList.vue index ba205ae106..be224805c2 100644 --- a/packages/entities/entities-consumers/src/components/ConsumerList.vue +++ b/packages/entities/entities-consumers/src/components/ConsumerList.vue @@ -316,8 +316,7 @@ const filterConfig = computed['$props']['confi schema: props.config.filterSchema, } as FuzzyMatchFilterConfig }) -const dataKeyName = computed((): string | undefined => isConsumerGroupPage.value ? 'consumers' : undefined) -const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value, dataKeyName.value) +const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value) const clearFilter = (): void => { filterQuery.value = ''