Skip to content

Commit 263ad97

Browse files
authored
8184 couch requests views failing (#8185)
* All telemetry criteria bug (#8084) * Reference telemetry map as a Map, not associative array * Only normalize once * Another cheeky createNormalizedDatum * Fix unit tests that were broken by removal of createNormalizedDatum * Fixed failing test * Don't double stringify requests to views * Add E2E test to catch 400 errors due to double stringification * Removed files AGAIN * Use design documents in testing
1 parent 896d77a commit 263ad97

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

e2e/tests/functional/plugins/plot/tagging.e2e.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,35 @@ test.describe('Plot Tagging', () => {
118118
await basicTagsTests(page);
119119
});
120120

121+
test('Plots use index to retrieve tags @couchdb @network', async ({ page }) => {
122+
test.info().annotations.push({
123+
type: 'issue',
124+
description: 'https://github.com/nasa/openmct/issues/8184'
125+
});
126+
// Switch to real-time mode
127+
await setRealTimeMode(page);
128+
129+
const tagsRequestPromise = new Promise((resolve) => {
130+
page.on('request', async (request) => {
131+
const isTagsRequest = request.url().endsWith('by_keystring');
132+
if (isTagsRequest) {
133+
const response = await request.response();
134+
resolve(response.status() === 200);
135+
}
136+
});
137+
});
138+
await createDomainObjectWithDefaults(page, {
139+
type: 'Sine Wave Generator'
140+
});
141+
142+
const pauseButton = page.getByLabel('Pause incoming real-time data');
143+
pauseButton.click();
144+
145+
const didUseIndexForTagsRequest = await tagsRequestPromise;
146+
147+
expect(didUseIndexForTagsRequest).toBe(true);
148+
});
149+
121150
test('Tags work with Stacked Plots', async ({ page }) => {
122151
const stackedPlot = await createDomainObjectWithDefaults(page, {
123152
type: 'Stacked Plot'

src/plugins/persistence/couch/CouchObjectProvider.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ class CouchObjectProvider {
463463
{ designDoc, viewName, keysToSearch, startKey, endKey, limit, objectIdField },
464464
abortSignal
465465
) {
466-
let stringifiedKeys = JSON.stringify(keysToSearch);
467466
const url = `${this.url}/_design/${designDoc}/_view/${viewName}`;
468467
const requestBody = {};
469468
let requestBodyString;
@@ -485,7 +484,7 @@ class CouchObjectProvider {
485484
requestBodyString = requestBodyString.replace('$END_KEY', endKey);
486485
/* spell-checker: enable */
487486
} else {
488-
requestBody.keys = stringifiedKeys;
487+
requestBody.keys = keysToSearch;
489488
requestBodyString = JSON.stringify(requestBody);
490489
}
491490

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash -e
22

3-
sed -i'.bak' -e 's/LocalStorage()/CouchDB("http:\/\/localhost:5984\/openmct")/g' index.html
3+
sed -i'.bak' -e 's/LocalStorage()/CouchDB(\{url: "http:\/\/localhost:5984\/openmct", useDesignDocuments: true\})/g' index.html

0 commit comments

Comments
 (0)