Commit 4a4b4a2f authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'revert-fc0524ab' into 'master'

Partially revert remove max requests in DA

See merge request gitlab-org/gitlab!63628
parents 1b4edb67 c441ef23
......@@ -8,6 +8,7 @@ import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/u
import {
DEVOPS_ADOPTION_STRINGS,
DEVOPS_ADOPTION_ERROR_KEYS,
MAX_REQUEST_COUNT,
DATE_TIME_FORMAT,
DEFAULT_POLLING_INTERVAL,
DEVOPS_ADOPTION_GROUP_LEVEL_LABEL,
......@@ -61,6 +62,7 @@ export default {
return {
isLoadingGroups: false,
isLoadingEnableGroup: false,
requestCount: 0,
openModal: false,
errors: {
[DEVOPS_ADOPTION_ERROR_KEYS.groups]: false,
......@@ -234,7 +236,8 @@ export default {
nodes: [...this.groups.nodes, ...nodes],
};
if (pageInfo?.nextPage) {
this.requestCount += 1;
if (this.requestCount < MAX_REQUEST_COUNT && pageInfo?.nextPage) {
this.fetchGroups(pageInfo.nextPage);
} else {
this.isLoadingGroups = false;
......
......@@ -2,6 +2,8 @@ import { s__, __ } from '~/locale';
export const DEFAULT_POLLING_INTERVAL = 30000;
export const MAX_REQUEST_COUNT = 10;
export const PER_PAGE = 100;
export const DEVOPS_ADOPTION_SEGMENT_MODAL_ID = 'devopsSegmentModal';
......
......@@ -193,6 +193,20 @@ describe('DevopsAdoptionApp', () => {
});
});
describe('when fetching too many pages of data', () => {
beforeEach(async () => {
// Always send the same page
groupsSpy = jest.fn().mockResolvedValue(initialResponse);
const mockApollo = createMockApolloProvider({ groupsSpy });
wrapper = createComponent({ mockApollo, data: { requestCount: 2 } });
await waitForPromises();
});
it('should fetch data twice', () => {
expect(groupsSpy).toHaveBeenCalledTimes(2);
});
});
describe('when error is thrown in the fetchMore request', () => {
const error = 'Error: foo!';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment