Skip to content

Commit 465e189

Browse files
committed
Renamed variable for clarity
1 parent d420782 commit 465e189

File tree

3 files changed

+94
-11
lines changed

3 files changed

+94
-11
lines changed

e2e/baseFixtures.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const extendedTest = test.extend({
119119
messages = messages.filter(msg => {
120120
let keep = true;
121121

122-
if (msg.text().match(/404 \(Object Not Found\)/) !== null) {
122+
if (msg.text().match(/404 \((Object )?Not Found\)/) !== null) {
123123
keep = ignore404s.every(ignoreRule => {
124124
return msg.location().url.match(ignoreRule) === null;
125125
});
@@ -131,7 +131,7 @@ const extendedTest = test.extend({
131131

132132
// Assert against console errors during teardown
133133
if (failOnConsoleError) {
134-
messages.forEach(async (msg) => {
134+
messages.forEach((msg) => {
135135
// eslint-disable-next-line playwright/no-standalone-expect
136136
expect
137137
.soft(msg.type(), `Console error detected: ${_consoleMessageToString(msg)}`)

e2e/tests/functional/search.e2e.spec.js

+87-4
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,93 @@ test.describe('Grand Search', () => {
193193
await expect(searchResults).toContainText(folderName);
194194
});
195195

196+
test.describe('Search will test for the presence of the object_names index, and', () => {
197+
test('use index if available @couchdb @network', async ({ page }) => {
198+
await createObjectsForSearch(page);
199+
200+
let isObjectNamesViewAvailable = false;
201+
let isObjectNamesUsedForSearch = false;
202+
203+
page.on('request', async (request) => {
204+
const isObjectNamesRequest =
205+
request.url().endsWith('_view/object_names')
206+
const isHeadRequest = request.method().toLowerCase() === 'head';
207+
208+
if (isObjectNamesRequest && isHeadRequest) {
209+
const response = await request.response();
210+
isObjectNamesViewAvailable = response.status() === 200;
211+
}
212+
});
213+
214+
page.on('request', async (request) => {
215+
const isObjectNamesRequest =
216+
request.url().endsWith('_view/object_names');
217+
const isPostRequest = request.method().toLowerCase() === 'post';
218+
219+
if (isObjectNamesRequest && isPostRequest) {
220+
isObjectNamesUsedForSearch = true;
221+
}
222+
});
223+
224+
225+
// Full search for object
226+
await grandSearchInput.pressSequentially('Clock', { delay: 100 });
227+
228+
// Wait for search to finish
229+
await waitForSearchCompletion(page);
230+
231+
expect(isObjectNamesViewAvailable).toBe(true);
232+
expect(isObjectNamesUsedForSearch).toBe(true);
233+
234+
});
235+
236+
test('fall-back on base index if index not available @couchdb @network', async ({ page }) => {
237+
await page.route('**/_view/object_names', (route) => {
238+
route.fulfill({
239+
status: 404
240+
});
241+
});
242+
await createObjectsForSearch(page);
243+
244+
let isObjectNamesViewAvailable = false;
245+
let isFindUsedForSearch = false;
246+
247+
page.on('request', async (request) => {
248+
const isObjectNamesRequest =
249+
request.url().endsWith('_view/object_names')
250+
const isHeadRequest = request.method().toLowerCase() === 'head';
251+
252+
if (isObjectNamesRequest && isHeadRequest) {
253+
const response = await request.response();
254+
isObjectNamesViewAvailable = response.status() === 200;
255+
}
256+
});
257+
258+
page.on('request', async (request) => {
259+
const isFindRequest =
260+
request.url().endsWith('_find');
261+
const isPostRequest = request.method().toLowerCase() === 'post';
262+
263+
if (isFindRequest && isPostRequest) {
264+
isFindUsedForSearch = true;
265+
}
266+
});
267+
268+
269+
// Full search for object
270+
await grandSearchInput.pressSequentially('Clock', { delay: 100 });
271+
272+
// Wait for search to finish
273+
await waitForSearchCompletion(page);
274+
console.info(`isObjectNamesViewAvailable: ${isObjectNamesViewAvailable} | isFindUsedForSearch: ${isFindUsedForSearch}`);
275+
expect(isObjectNamesViewAvailable).toBe(false);
276+
expect(isFindUsedForSearch).toBe(true);
277+
});
278+
})
279+
196280
test('Search results are debounced @couchdb @network', async ({ page }) => {
197-
//Unfortunately 404s are always logged to the JavaScript console and can't be surpressed
198-
//A 404 is now thrown when we test for the presence of the object names view used by search.
281+
// Unfortunately 404s are always logged to the JavaScript console and can't be surpressed
282+
// A 404 is now thrown when we test for the presence of the object names view used by search.
199283
test.info().annotations.push({
200284
type: 'issue',
201285
description: 'https://github.com/nasa/openmct/issues/6179'
@@ -209,9 +293,8 @@ test.describe('Grand Search', () => {
209293
request.url().endsWith('object_names') ||
210294
request.url().endsWith('_find') ||
211295
request.url().includes('by_keystring');
212-
213296
const isFetchRequest = request.resourceType() === 'fetch';
214-
//CouchDB search results in a one-time head request to test for the presence of an index.
297+
// CouchDB search results in a one-time head request to test for the presence of an index.
215298
const isHeadRequest = request.method().toLowerCase() === 'head';
216299

217300
if (isSearchRequest && isFetchRequest && !isHeadRequest) {

src/api/composition/CompositionCollection.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@ export default class CompositionCollection {
211211
this.#cleanUpMutables();
212212
const children = await this.#provider.load(this.domainObject);
213213
const childObjects = await Promise.all(
214-
children.map((c) => {
215-
if (isIdentifier(c)) {
216-
return this.#publicAPI.objects.get(c, abortSignal);
214+
children.map((child) => {
215+
if (isIdentifier(child)) {
216+
return this.#publicAPI.objects.get(child, abortSignal);
217217
} else {
218-
return Promise.resolve(c);
218+
return Promise.resolve(child);
219219
}
220220
})
221221
);
222-
childObjects.forEach((c) => this.add(c, true));
222+
childObjects.forEach((child) => this.add(child, true));
223223
this.#emit('load');
224224

225225
return childObjects;

0 commit comments

Comments
 (0)