Skip to content

Commit

Permalink
fixup! Separate collection API to two endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
siiptuo committed Nov 19, 2024
1 parent f73d8cb commit b6422cd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 35 deletions.
6 changes: 0 additions & 6 deletions backend/tests/integration/parallel/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
});
});
10 changes: 5 additions & 5 deletions frontend/tests/CollectionView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
Expand All @@ -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")) {
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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();
});

Expand Down
45 changes: 21 additions & 24 deletions shared/res/allcollections.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
26 changes: 26 additions & 0 deletions shared/res/collectionfiles.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}

0 comments on commit b6422cd

Please sign in to comment.