Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethnym committed Aug 31, 2023
2 parents 6e7b2cf + ec7d542 commit c768ccb
Show file tree
Hide file tree
Showing 86 changed files with 4,469 additions and 6,410 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: '16.x'
cache: 'yarn'
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add apt repo
run: sudo add-apt-repository universe
- name: Setup Java
Expand All @@ -86,7 +86,7 @@ jobs:

# ICAT Ansible clone and install dependencies
- name: Checkout icat-ansible
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: icatproject-contrib/icat-ansible
ref: master
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
cd /home/runner/install/icat.server/ && ./setup -vv install
- name: Checkout datagateway-api
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: ral-facilities/datagateway-api
path: datagateway-api
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:

# E2E tests
- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: '14.x'
# Cache yarn dependencies/ restore the cached dependencies during future workflows
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add apt repo
run: sudo add-apt-repository universe
- name: Setup Java
Expand All @@ -218,7 +218,7 @@ jobs:

# ICAT Ansible clone and install dependencies
- name: Checkout icat-ansible
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: icatproject-contrib/icat-ansible
ref: master
Expand Down Expand Up @@ -284,7 +284,7 @@ jobs:
run: rm -f login_output

- name: Checkout datagateway-api
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: ral-facilities/datagateway-api
path: datagateway-api
Expand Down Expand Up @@ -313,7 +313,7 @@ jobs:

# E2E tests
- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: '14.x'
# Cache yarn dependencies/ restore the cached dependencies during future workflows
Expand Down Expand Up @@ -349,7 +349,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add apt repo
run: sudo add-apt-repository universe
- name: Setup Java
Expand All @@ -366,7 +366,7 @@ jobs:

# ICAT Ansible clone and install dependencies
- name: Checkout icat-ansible
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: icatproject-contrib/icat-ansible
ref: master
Expand Down Expand Up @@ -414,7 +414,7 @@ jobs:
cd /home/runner/install/icat.server/ && ./setup -vv install
- name: Checkout datagateway-api
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: ral-facilities/datagateway-api
path: datagateway-api
Expand Down Expand Up @@ -461,7 +461,7 @@ jobs:

# E2E tests
- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: '14.x'
# Cache yarn dependencies/ restore the cached dependencies during future workflows
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3

- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: '16.x'
cache: 'yarn'
Expand Down
807 changes: 0 additions & 807 deletions .yarn/releases/yarn-3.3.0.cjs

This file was deleted.

874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.3.0.cjs
yarnPath: .yarn/releases/yarn-3.6.0.cjs
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"resolutions": {
"@types/react": "17.0.39",
"@typescript-eslint/eslint-plugin": "5.49.0",
"@typescript-eslint/parser": "5.49.0"
"@typescript-eslint/eslint-plugin": "5.61.0",
"@typescript-eslint/parser": "5.61.0"
},
"scripts": {
"build": "yarn workspaces foreach --interlaced --verbose --parallel --jobs 3 --exclude datagateway-common run build",
Expand All @@ -25,5 +25,5 @@
"datagateway-search": "yarn workspace datagateway-search start",
"postinstall": "husky install"
},
"packageManager": "yarn@3.3.0"
"packageManager": "yarn@3.6.0"
}
28 changes: 14 additions & 14 deletions packages/datagateway-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"main": "./lib/index.js",
"dependencies": {
"@date-io/date-fns": "2.16.0",
"@emotion/react": "11.10.0",
"@emotion/styled": "11.10.0",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@mui/x-date-pickers": "5.0.9",
"@types/lodash.debounce": "4.0.6",
"axios": "0.27.2",
"connected-react-router": "6.9.1",
"date-fns": "2.29.1",
"date-fns": "2.30.0",
"hex-to-rgba": "2.0.1",
"history": "4.10.1",
"i18next": "22.0.3",
"lodash.debounce": "4.0.8",
"loglevel": "1.8.0",
"prettier": "2.8.0",
"react-draggable": "4.4.3",
"react-i18next": "12.1.1",
"react-i18next": "12.3.1",
"react-query": "3.39.2",
"react-redux": "8.0.4",
"react-scripts": "5.0.0",
Expand All @@ -31,7 +31,7 @@
"redux-mock-store": "1.5.4",
"redux-thunk": "2.4.1",
"resize-observer-polyfill": "1.5.1",
"tslib": "2.4.0",
"tslib": "2.6.0",
"typescript": "4.9.3",
"use-deep-compare-effect": "1.8.1"
},
Expand All @@ -43,26 +43,26 @@
"react-router-dom": ">= 5.2.0 < 6"
},
"devDependencies": {
"@babel/eslint-parser": "7.22.5",
"@mui/icons-material": "5.11.0",
"@mui/material": "5.11.0",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.3",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.4.1",
"@types/jest": "29.4.0",
"@types/node": "18.11.9",
"@types/jest": "29.5.2",
"@types/node": "18.16.18",
"@types/react": "17.0.39",
"@types/react-router-dom": "5.3.3",
"@types/react-virtualized": "9.21.10",
"@typescript-eslint/eslint-plugin": "5.49.0",
"@typescript-eslint/parser": "5.49.0",
"babel-eslint": "10.1.0",
"eslint": "8.32.0",
"eslint-config-prettier": "8.5.0",
"@typescript-eslint/eslint-plugin": "5.61.0",
"@typescript-eslint/parser": "5.61.0",
"eslint": "8.44.0",
"eslint-config-prettier": "8.8.0",
"eslint-config-react-app": "7.0.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-cypress": "2.13.3",
"eslint-plugin-prettier": "4.2.1",
"lint-staged": "13.1.0",
"lint-staged": "13.2.3",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-router-dom": "5.3.0",
Expand Down
28 changes: 25 additions & 3 deletions packages/datagateway-common/src/api/dataPublications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('data publications api functions', () => {
];
history = createMemoryHistory({
initialEntries: [
'/?sort={"name":"asc"}&filters={"name":{"value":"test","type":"include"}}&page=2&results=20',
'/?sort={"name":"asc","title":"desc"}&filters={"name":{"value":"test","type":"include"}}&page=2&results=20',
],
});
params = new URLSearchParams();
Expand All @@ -53,7 +53,7 @@ describe('data publications api functions', () => {
data: mockData,
});

const { result, waitFor } = renderHook(
const { result, waitFor, rerender } = renderHook(
() =>
useDataPublicationsPaginated([
{
Expand All @@ -74,6 +74,7 @@ describe('data publications api functions', () => {
await waitFor(() => result.current.isSuccess);

params.append('order', JSON.stringify('name asc'));
params.append('order', JSON.stringify('title desc'));
params.append('order', JSON.stringify('id asc'));
params.append(
'where',
Expand Down Expand Up @@ -103,6 +104,16 @@ describe('data publications api functions', () => {
params.toString()
);
expect(result.current.data).toEqual(mockData);

// test that order of sort object triggers new query
history.push(
'/?sort={"title":"desc", "name":"asc"}&filters={"name":{"value":"test","type":"include"}}&page=2&results=20'
);
rerender();

await waitFor(() => expect(result.current.isSuccess).toBe(true));

expect(axios.get as jest.Mock).toHaveBeenCalledTimes(2);
});

it('sends axios request to fetch paginated data publications and calls handleICATError on failure', async () => {
Expand Down Expand Up @@ -143,7 +154,7 @@ describe('data publications api functions', () => {
: Promise.resolve({ data: mockData[1] })
);

const { result, waitFor } = renderHook(
const { result, waitFor, rerender } = renderHook(
() =>
useDataPublicationsInfinite([
{
Expand All @@ -164,6 +175,7 @@ describe('data publications api functions', () => {
await waitFor(() => result.current.isSuccess);

params.append('order', JSON.stringify('name asc'));
params.append('order', JSON.stringify('title desc'));
params.append('order', JSON.stringify('id asc'));
params.append(
'where',
Expand Down Expand Up @@ -219,6 +231,16 @@ describe('data publications api functions', () => {
mockData[0],
mockData[1],
]);

// test that order of sort object triggers new query
history.push(
'/?sort={"title":"desc", "name":"asc"}&filters={"name":{"value":"test","type":"include"}}'
);
rerender();

await waitFor(() => expect(result.current.isSuccess).toBe(true));

expect(axios.get as jest.Mock).toHaveBeenCalledTimes(3);
});

it('sends axios request to fetch infinite data publications and calls handleICATError on failure', async () => {
Expand Down
25 changes: 14 additions & 11 deletions packages/datagateway-common/src/api/dataPublications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useDataPublicationsPaginated = (
[
string,
{
sort: SortType;
sort: string;
filters: FiltersType;
page: number;
results: number;
Expand All @@ -77,11 +77,16 @@ export const useDataPublicationsPaginated = (
>(
[
'dataPublication',
{ sort, filters, page: page ?? 1, results: results ?? 10 },
{
sort: JSON.stringify(sort), // need to stringify sort as property order is important!
filters,
page: page ?? 1,
results: results ?? 10,
},
additionalFilters,
],
(params) => {
const { sort, filters, page, results } = params.queryKey[1];
const { page, results } = params.queryKey[1];
const startIndex = (page - 1) * results;
const stopIndex = startIndex + results - 1;
return fetchDataPublications(
Expand Down Expand Up @@ -110,15 +115,13 @@ export const useDataPublicationsInfinite = (
const location = useLocation();
const { filters, sort } = parseSearchToQuery(location.search);

return useInfiniteQuery<
DataPublication[],
AxiosError,
DataPublication[],
[string, { sort: SortType; filters: FiltersType }, AdditionalFilters?]
>(
['dataPublication', { sort, filters }, additionalFilters],
return useInfiniteQuery(
[
'dataPublication',
{ sort: JSON.stringify(sort), filters }, // need to stringify sort as property order is important!
additionalFilters,
],
(params) => {
const { sort, filters } = params.queryKey[1];
const offsetParams = params.pageParam ?? { startIndex: 0, stopIndex: 49 };
return fetchDataPublications(
apiUrl,
Expand Down
Loading

0 comments on commit c768ccb

Please sign in to comment.