From b6422cd7c68db81327c8e6aa1d0c9a7402697329 Mon Sep 17 00:00:00 2001 From: Tuomas Siipola Date: Tue, 19 Nov 2024 16:02:54 +0200 Subject: [PATCH] fixup! Separate collection API to two endpoints --- .../tests/integration/parallel/search.test.ts | 6 --- frontend/tests/CollectionView.test.ts | 10 ++--- shared/res/allcollections.json | 45 +++++++++---------- shared/res/collectionfiles.json | 26 +++++++++++ 4 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 shared/res/collectionfiles.json diff --git a/backend/tests/integration/parallel/search.test.ts b/backend/tests/integration/parallel/search.test.ts index 401338c5f..542280355 100644 --- a/backend/tests/integration/parallel/search.test.ts +++ b/backend/tests/integration/parallel/search.test.ts @@ -385,10 +385,4 @@ describe("/api/search", () => { totalPages: 2, }); }); - - it("filters by collection", async () => { - const res = await axios.get(url, { params: { collection: "48092c00-161d-4ca2-a29d-628cf8e960f6" } }); - const fileUuids = res.data.map((file: any) => file.uuid).sort(); - expect(fileUuids).toEqual(["a5d1d5af-3667-41bc-b952-e684f627d91c", "d21d6a9b-6804-4465-a026-74ec429fe17d"]); - }); }); diff --git a/frontend/tests/CollectionView.test.ts b/frontend/tests/CollectionView.test.ts index 3a21739c6..7159dee5c 100644 --- a/frontend/tests/CollectionView.test.ts +++ b/frontend/tests/CollectionView.test.ts @@ -18,7 +18,9 @@ describe("CollectionView.vue", () => { resources = await readResources(); mockAxios = () => { return (url: string): AxiosPromise => { - if (url.includes("/collection/testuuid")) { + if (url.includes("/collection/48092c00-161d-4ca2-a29d-628cf8e960f6/files")) { + return Promise.resolve(augmentAxiosResponse(resources["collectionfiles"])); + } else if (url.includes("/collection/48092c00-161d-4ca2-a29d-628cf8e960f6")) { return Promise.resolve(augmentAxiosResponse(resources["allcollections"][0])); } else if (url.includes("/search")) { const results = [resources["pagedsearch"].results[1], resources["pagedsearch"].results[9]]; @@ -38,8 +40,6 @@ describe("CollectionView.vue", () => { return Promise.resolve(augmentAxiosResponse(resources["sites"])); } else if (url.includes("/products")) { return Promise.resolve(augmentAxiosResponse(resources["products"])); - } else if (url.includes("/models")) { - return Promise.resolve(augmentAxiosResponse(resources["models"])); } else if (url.includes("/generate-pid")) { return Promise.resolve(augmentAxiosResponse({ pid: "testpid" })); } else if (url.includes("/reference/") && url.includes("/citation?format=html")) { @@ -67,7 +67,7 @@ describe("CollectionView.vue", () => { beforeAll(async () => { wrapper = mount(App, { global: { plugins: [router] } }); - router.push({ name: "Collection", params: { uuid: "testuuid" } }); + router.push({ name: "Collection", params: { uuid: "48092c00-161d-4ca2-a29d-628cf8e960f6" } }); await router.isReady(); }); @@ -117,7 +117,7 @@ describe("CollectionView.vue", () => { beforeAll(async () => { wrapper = mount(App, { global: { plugins: [router] } }); - router.push({ name: "CollectionFiles", params: { uuid: "testuuid" } }); + router.push({ name: "CollectionFiles", params: { uuid: "48092c00-161d-4ca2-a29d-628cf8e960f6" } }); await router.isReady(); }); diff --git a/shared/res/allcollections.json b/shared/res/allcollections.json index db75961f8..29868a977 100644 --- a/shared/res/allcollections.json +++ b/shared/res/allcollections.json @@ -1,32 +1,29 @@ [ { - "files": [ - { - "uuid": "a5d1d5af-3667-41bc-b952-e684f627d91c", - "measurementDate": "2014-12-05", - "siteId": "mace-head", - "site": "Mace Head", - "product": "Model", - "productId": "model", - "modelId": "ecmwf", - "size": 500452, - "volatile": true - }, - { - "uuid": "d21d6a9b-6804-4465-a026-74ec429fe17d", - "measurementDate": "2019-09-01", - "siteId": "hyytiala", - "site": "Hyytiälä", - "product": "Radar", - "productId": "radar", - "size": 16027310, - "volatile": true - } - ], "uuid": "48092c00-161d-4ca2-a29d-628cf8e960f6", "title": "", "pid": "", "createdAt": "2020-09-28T12:45:21.916Z", - "updatedAt": "2020-09-28T12:45:21.916Z" + "updatedAt": "2020-09-28T12:45:21.916Z", + "files": 2, + "size": 16527762, + "sites": [ + { + "id": "hyytiala", + "humanReadableName": "Hyytiälä", + "type": ["cloudnet"], + "latitude": 61.844, + "longitude": 24.288, + "altitude": 174, + "gaw": "SMR", + "country": "Finland" + } + ], + "products": [ + { "id": "model", "humanReadableName": "Model" }, + { "id": "radar", "humanReadableName": "Radar" } + ], + "startDate": "2014-12-05", + "endDate": "2019-09-01" } ] diff --git a/shared/res/collectionfiles.json b/shared/res/collectionfiles.json new file mode 100644 index 000000000..aeb00f983 --- /dev/null +++ b/shared/res/collectionfiles.json @@ -0,0 +1,26 @@ +{ + "pagination": { + "totalItems": 2, + "totalPages": 1, + "currentPage": 1, + "pageSize": 15 + }, + "results": [ + { + "uuid": "a5d1d5af-3667-41bc-b952-e684f627d91c", + "measurementDate": "2014-12-05", + "site": { "id": "mace-head", "humanReadableName": "Mace Head" }, + "product": { "id": "model", "humanReadableName": "Model" }, + "size": 500452, + "volatile": true + }, + { + "uuid": "d21d6a9b-6804-4465-a026-74ec429fe17d", + "measurementDate": "2019-09-01", + "site": { "id": "hyytiala", "humanReadableName": "Hyytiälä" }, + "product": { "id": "radar", "humanReadableName": "Radar" }, + "size": 16027310, + "volatile": true + } + ] +}