Skip to content

Commit

Permalink
chore: add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rgwozdz committed Mar 27, 2024
1 parent e6ff8fa commit 7b7ea49
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 5 deletions.
6 changes: 1 addition & 5 deletions packages/winnow/src/query/standard-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ function standardQuery(features, sqlString, options = {}) {

// 1) For GeoService API queries there is always a limit
// 2) options.limit is incremented by one in normalizeOptions.js; if filtered.length === options.limit, original limit option has been exceeded
if (
options.skipLimitHandling ||
!options.limit ||
filtered.length !== limit
) {
if (options.skipLimitHandling || !limit || filtered.length !== limit) {
return packageFeatures(filtered, options);
}

Expand Down
62 changes: 62 additions & 0 deletions test/geoservice-query.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,68 @@ describe('koop', () => {
}
});
});

describe('exceededTransferLimit', () => {
test('should be calculated by Koop and equal true', async () => {
try {
const response = await request(koop.server).get(
'/file-geojson/rest/services/points-w-objectid/FeatureServer/0/query?resultRecordCount=2',
);
expect(response.status).toBe(200);
const { features, exceededTransferLimit } = response.body;
expect(features.length).toBe(2);
expect(exceededTransferLimit).toBe(true);
} catch (error) {
console.error(error);
throw error;
}
});

test('should be calculated by Koop and equal false', async () => {
try {
const response = await request(koop.server).get(
'/file-geojson/rest/services/points-w-objectid/FeatureServer/0/query',
);
expect(response.status).toBe(200);
const { features, exceededTransferLimit } = response.body;
expect(features.length).toBe(3);
expect(exceededTransferLimit).toBe(false);
} catch (error) {
console.error(error);
throw error;
}
});

test('should be acquired from provider metadata', async () => {
try {
const response = await request(koop.server).get(
'/file-geojson/rest/services/points-w-metadata-exceeded-transfer-limit/FeatureServer/0/query?resultRecordCount=2',
);
expect(response.status).toBe(200);
const { features, exceededTransferLimit } = response.body;
expect(features.length).toBe(2);
expect(exceededTransferLimit).toBe(true);
} catch (error) {
console.error(error);
throw error;
}
});

test('should be acquired from provider metadata', async () => {
try {
const response = await request(koop.server).get(
'/file-geojson/rest/services/points-w-metadata-exceeded-transfer-limit/FeatureServer/0/query',
);
expect(response.status).toBe(200);
const { features, exceededTransferLimit } = response.body;
expect(features.length).toBe(3);
expect(exceededTransferLimit).toBe(true);
} catch (error) {
console.error(error);
throw error;
}
});
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"type": "FeatureCollection",
"metadata": {
"idField": "id",
"exceededTransferLimit": true
},
"features": [
{
"type": "Feature",
"properties": {
"id": "aaa",
"timestamp": "2023-04-10T16:15:30.000Z",
"label": "White Leg",
"category": "pinto"
},
"geometry": {
"type": "Point",
"coordinates": [-80, 25]
}
},
{
"type": "Feature",
"properties": {
"id": "bbb",
"timestamp": "2020-04-12T16:15:30.000Z",
"label": "Fireman",
"category": "pinto"
},
"geometry": {
"type": "Point",
"coordinates": [-120, 45]
}
},
{
"type": "Feature",
"properties": {
"id": "ccc",
"timestamp": "2015-04-11T16:15:30.000Z",
"label": "Workhorse",
"category": "draft"
},
"geometry": {
"type": "Point",
"coordinates": [-100, 40]
}
}
]
}

0 comments on commit 7b7ea49

Please sign in to comment.