diff --git a/client/src/actions/competitions.test.ts b/client/src/actions/competitions.test.ts index 52be36acb658576e9b5c1ffc1b40394c338d0f5f..2ebb22b74f7ef7b187c11df9e347988a82e4baf5 100644 --- a/client/src/actions/competitions.test.ts +++ b/client/src/actions/competitions.test.ts @@ -11,25 +11,24 @@ const mockStore = configureMockStore(middlewares) it('dispatches correct actions when getting competitions', async () => { const compRes: any = { - data: { - items: [ - { - id: 21, - name: 'ggff', - year: 2021, - style_id: 1, - city: { name: 'city_name', id: 5 }, - }, - { - id: 22, - name: 'sssss', - year: 2021, - style_id: 1, - city: { name: 'city_name', id: 5 }, - }, - ], - count: 2, - total_count: 3, + data: [ + { + id: 21, + name: 'ggff', + year: 2021, + style_id: 1, + city: { name: 'city_name', id: 5 }, + }, + { + id: 22, + name: 'sssss', + year: 2021, + style_id: 1, + city: { name: 'city_name', id: 5 }, + }, + ], + headers: { + pagination: '{"count": 2,"total": 3, "page_size": 5}', }, } @@ -37,9 +36,9 @@ it('dispatches correct actions when getting competitions', async () => { return Promise.resolve(compRes) }) const expectedActions = [ - { type: Types.SET_COMPETITIONS, payload: compRes.data.items }, - { type: Types.SET_COMPETITIONS_TOTAL, payload: compRes.data.total_count }, - { type: Types.SET_COMPETITIONS_COUNT, payload: compRes.data.count }, + { type: Types.SET_COMPETITIONS, payload: compRes.data }, + { type: Types.SET_COMPETITIONS_TOTAL, payload: 3 }, + { type: Types.SET_COMPETITIONS_COUNT, payload: 2 }, ] const store = mockStore({ competitions: { filterParams: [] } }) await getCompetitions()(store.dispatch, store.getState as any) diff --git a/client/src/actions/competitions.ts b/client/src/actions/competitions.ts index 04ac133c38b53513f7f19bb0d2e290d5430aad94..e934726d8265a2ea88751137c8cc3bbaef9375b1 100644 --- a/client/src/actions/competitions.ts +++ b/client/src/actions/competitions.ts @@ -33,7 +33,7 @@ export const getCompetitions = () => async (dispatch: AppDispatch, getState: () }) dispatch({ type: Types.SET_COMPETITIONS_COUNT, - payload: pagination.total <= pagination.page_size ? pagination.total : pagination.page_size, + payload: res.data.length, }) }) .catch((err) => { diff --git a/client/src/actions/searchUser.test.ts b/client/src/actions/searchUser.test.ts index d9eba40e70922afe2575970614f7893c34dc834a..71d539d5dccab99c065c9c3f899f6ea8a1b61f8d 100644 --- a/client/src/actions/searchUser.test.ts +++ b/client/src/actions/searchUser.test.ts @@ -29,7 +29,7 @@ it('dispatches correct actions when getting users', async () => { }, ], headers: { - pagination: '{"count": 2,"total_count": 3}', + pagination: '{"count": 2,"total": 3, "page_size":5 }', }, } @@ -38,8 +38,8 @@ it('dispatches correct actions when getting users', async () => { }) const expectedActions = [ { type: Types.SET_SEARCH_USERS, payload: userRes.data }, - { type: Types.SET_SEARCH_USERS_TOTAL_COUNT, payload: userRes.headers.pagination.total_count }, - { type: Types.SET_SEARCH_USERS_COUNT, payload: userRes.headers.pagination.count }, + { type: Types.SET_SEARCH_USERS_TOTAL_COUNT, payload: 3 }, + { type: Types.SET_SEARCH_USERS_COUNT, payload: userRes.data.length }, ] const store = mockStore({ searchUsers: { filterParams: [] } }) await getSearchUsers()(store.dispatch, store.getState as any) diff --git a/client/src/actions/searchUser.ts b/client/src/actions/searchUser.ts index 00f88c046c4c4d92afe400b063b4b8bed40cd87a..4197ee188e51e4f2c17a207d9686a25d2cf00b63 100644 --- a/client/src/actions/searchUser.ts +++ b/client/src/actions/searchUser.ts @@ -34,7 +34,7 @@ export const getSearchUsers = () => async (dispatch: AppDispatch, getState: () = }) dispatch({ type: Types.SET_SEARCH_USERS_COUNT, - payload: pagination.total <= pagination.page_size ? pagination.total : pagination.page_size, + payload: res.data.length, }) }) .catch((err) => { diff --git a/client/src/pages/admin/AdminPage.test.tsx b/client/src/pages/admin/AdminPage.test.tsx index 445373a032207faa3f546a0c480fb03a093b1529..61d409733c09d3b7ff1fb2ef902eb8a10ab67e34 100644 --- a/client/src/pages/admin/AdminPage.test.tsx +++ b/client/src/pages/admin/AdminPage.test.tsx @@ -8,35 +8,33 @@ import AdminPage from './AdminPage' it('renders admin view', () => { const cityRes: any = { - data: { - items: [ - { - id: 1, - name: 'Link\u00f6ping', - }, - { - id: 2, - name: 'Stockholm', - }, - ], - count: 2, - total_count: 3, + data: [ + { + id: 1, + name: 'Link\u00f6ping', + }, + { + id: 2, + name: 'Stockholm', + }, + ], + headers: { + pagination: '{"count": 2,"total_count": 3}', }, } const rolesRes: any = { - data: { - items: [ - { - id: 1, - name: 'role1', - }, - { - id: 2, - name: 'role2', - }, - ], - count: 2, - total_count: 3, + data: [ + { + id: 1, + name: 'role1', + }, + { + id: 2, + name: 'role2', + }, + ], + headers: { + pagination: '{"count": 2,"total_count": 3}', }, } ;(mockedAxios.get as jest.Mock).mockImplementation((path: string, params?: any) => { diff --git a/client/src/pages/admin/competitions/CompetitionManager.test.tsx b/client/src/pages/admin/competitions/CompetitionManager.test.tsx index 7af04abb66bba7ded7655398f288cba1c62bf78b..0b270a7df39653567333c06516090c9c0364c900 100644 --- a/client/src/pages/admin/competitions/CompetitionManager.test.tsx +++ b/client/src/pages/admin/competitions/CompetitionManager.test.tsx @@ -8,42 +8,36 @@ import CompetitionManager from './CompetitionManager' it('renders competition manager', () => { const cityRes: any = { - data: { - items: [ - { - id: 1, - name: 'Link\u00f6ping', - }, - { - id: 2, - name: 'Stockholm', - }, - ], - count: 2, - total_count: 3, - }, + data: [ + { + id: 1, + name: 'Link\u00f6ping', + }, + { + id: 2, + name: 'Stockholm', + }, + ], + pagination: '{"count": 2,"total": 3, "page_size": 5}', } const compRes: any = { - data: { - items: [ - { - id: 21, - name: 'ggff', - year: 2021, - style_id: 1, - city: cityRes.data.items[0], - }, - { - id: 22, - name: 'sssss', - year: 2021, - style_id: 1, - city: cityRes.data.items[1], - }, - ], - count: 2, - total_count: 3, - }, + data: [ + { + id: 21, + name: 'ggff', + year: 2021, + style_id: 1, + city: cityRes.data[0], + }, + { + id: 22, + name: 'sssss', + year: 2021, + style_id: 1, + city: cityRes.data[1], + }, + ], + headers: { pagination: '{"count": 2,"total": 3, "page_size": 5}' }, } ;(mockedAxios.get as jest.Mock).mockImplementation((path: string, params?: any) => { diff --git a/client/src/pages/admin/regions/Regions.test.tsx b/client/src/pages/admin/regions/Regions.test.tsx index 7046bff04fc8fc9fc8cb3f08d0d140d0d475b5a3..864001b31dcc9cf17edbaf70af65aac240232663 100644 --- a/client/src/pages/admin/regions/Regions.test.tsx +++ b/client/src/pages/admin/regions/Regions.test.tsx @@ -8,19 +8,18 @@ import RegionManager from './Regions' it('renders region manager', () => { const cityRes: any = { - data: { - items: [ - { - id: 1, - name: 'Link\u00f6ping', - }, - { - id: 2, - name: 'Stockholm', - }, - ], - count: 2, - total_count: 3, + data: [ + { + id: 1, + name: 'Link\u00f6ping', + }, + { + id: 2, + name: 'Stockholm', + }, + ], + headers: { + pagination: '{"count": 2,"total_count": 3}', }, } diff --git a/client/src/pages/admin/users/UserManager.test.tsx b/client/src/pages/admin/users/UserManager.test.tsx index f50cbed8ded2b12d3d487e96f1d185bca2a2cbf8..69117bc5829fc6fca85bc2316c1faf668112d3f7 100644 --- a/client/src/pages/admin/users/UserManager.test.tsx +++ b/client/src/pages/admin/users/UserManager.test.tsx @@ -8,25 +8,24 @@ import UserManager from './UserManager' it('renders user manager', () => { const userRes: any = { - data: { - items: [ - { - id: 1, - name: 'user1', - email: 'user1@email.com', - role_id: 0, - city_id: 0, - }, - { - id: 2, - name: 'Stockholm', - email: 'user2@email.com', - role_id: 0, - city_id: 0, - }, - ], - count: 2, - total_count: 3, + data: [ + { + id: 1, + name: 'user1', + email: 'user1@email.com', + role_id: 0, + city_id: 0, + }, + { + id: 2, + name: 'Stockholm', + email: 'user2@email.com', + role_id: 0, + city_id: 0, + }, + ], + headers: { + pagination: '{"count": 2,"total_count": 3, "page_size": 5}', }, } diff --git a/client/src/pages/admin/users/UserManager.tsx b/client/src/pages/admin/users/UserManager.tsx index ed500dc27f3504d7707ba6b8e831dba4a4e52989..0b32e86893a979c3e37061102e49ab4fb5ed4e7f 100644 --- a/client/src/pages/admin/users/UserManager.tsx +++ b/client/src/pages/admin/users/UserManager.tsx @@ -170,7 +170,7 @@ const UserManager: React.FC = (props: any) => { component="div" rowsPerPageOptions={[]} rowsPerPage={filterParams.pageSize} - count={usersTotal} + count={usersTotal || 0} page={filterParams.page - 1} onChangePage={(event, newPage) => handleFilterChange({ ...filterParams, page: newPage + 1 })} /> diff --git a/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx b/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx index 7254a69d3bdae4e39c6ce1097dc06e753ff333f0..539d54e809926bc7a583ea06b00acddd10084f1e 100644 --- a/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx +++ b/client/src/pages/presentationEditor/PresentationEditorPage.test.tsx @@ -18,14 +18,12 @@ it('renders presentation editor', () => { }, } const citiesRes: any = { - data: { - items: [ - { - name: '', - city_id: 0, - }, - ], - }, + data: [ + { + name: '', + city_id: 0, + }, + ], } const typesRes: any = { data: { diff --git a/client/src/pages/views/OperatorViewPage.test.tsx b/client/src/pages/views/OperatorViewPage.test.tsx index 3259fcfcf07f7f54a725e01b2ea6fa8b69a89b21..f20cb695a695f94ccc519fe1f149ad5d957a86d2 100644 --- a/client/src/pages/views/OperatorViewPage.test.tsx +++ b/client/src/pages/views/OperatorViewPage.test.tsx @@ -15,19 +15,18 @@ it('renders operator view page', async () => { }, } const teamsRes: any = { - data: { - items: [ - { - id: 1, - name: 'team1', - }, - { - id: 2, - name: 'team2', - }, - ], - count: 2, - total_count: 3, + data: [ + { + id: 1, + name: 'team1', + }, + { + id: 2, + name: 'team2', + }, + ], + headers: { + pagination: '{"count": 2,"total_count": 3}', }, }