mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
Handle aborted get requests and null domain objects when using ObjectAPI (#7276)
* handle null domain objects * add some test coverage for aborting search results * to make test independent
This commit is contained in:
parent
2d9c0414f7
commit
93e5219917
@ -198,6 +198,32 @@ test.describe('Grand Search', () => {
|
|||||||
await expect(searchResultDropDown).toContainText('Clock A');
|
await expect(searchResultDropDown).toContainText('Clock A');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Slowly typing after search debounce will abort requests @couchdb', async ({ page }) => {
|
||||||
|
let requestWasAborted = false;
|
||||||
|
await createObjectsForSearch(page);
|
||||||
|
page.on('requestfailed', (request) => {
|
||||||
|
// check if the request was aborted
|
||||||
|
if (request.failure().errorText === 'net::ERR_ABORTED') {
|
||||||
|
requestWasAborted = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Intercept and delay request
|
||||||
|
const delayInMs = 100;
|
||||||
|
|
||||||
|
await page.route('**', async (route, request) => {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, delayInMs));
|
||||||
|
route.continue();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Slowly type after search delay
|
||||||
|
const searchInput = page.getByRole('searchbox', { name: 'Search Input' });
|
||||||
|
await searchInput.pressSequentially('Clock', { delay: 200 });
|
||||||
|
await expect(page.getByText('Clock B').first()).toBeVisible();
|
||||||
|
|
||||||
|
expect(requestWasAborted).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
test('Validate multiple objects in search results return partial matches', async ({ page }) => {
|
test('Validate multiple objects in search results return partial matches', async ({ page }) => {
|
||||||
test.info().annotations.push({
|
test.info().annotations.push({
|
||||||
type: 'issue',
|
type: 'issue',
|
||||||
|
@ -232,6 +232,10 @@ export default class ObjectAPI {
|
|||||||
.get(identifier, abortSignal)
|
.get(identifier, abortSignal)
|
||||||
.then((domainObject) => {
|
.then((domainObject) => {
|
||||||
delete this.cache[keystring];
|
delete this.cache[keystring];
|
||||||
|
if (!domainObject && abortSignal.aborted) {
|
||||||
|
// we've aborted the request
|
||||||
|
return;
|
||||||
|
}
|
||||||
domainObject = this.applyGetInterceptors(identifier, domainObject);
|
domainObject = this.applyGetInterceptors(identifier, domainObject);
|
||||||
|
|
||||||
if (this.supportsMutation(identifier)) {
|
if (this.supportsMutation(identifier)) {
|
||||||
@ -791,6 +795,9 @@ export default class ObjectAPI {
|
|||||||
*/
|
*/
|
||||||
async getOriginalPath(identifier, path = [], abortSignal = null) {
|
async getOriginalPath(identifier, path = [], abortSignal = null) {
|
||||||
const domainObject = await this.get(identifier, abortSignal);
|
const domainObject = await this.get(identifier, abortSignal);
|
||||||
|
if (!domainObject) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
path.push(domainObject);
|
path.push(domainObject);
|
||||||
const { location } = domainObject;
|
const { location } = domainObject;
|
||||||
if (location && !this.#pathContainsDomainObject(location, path)) {
|
if (location && !this.#pathContainsDomainObject(location, path)) {
|
||||||
|
@ -180,7 +180,7 @@ define(['uuid'], function ({ v4: uuid }) {
|
|||||||
{
|
{
|
||||||
check(domainObject) {
|
check(domainObject) {
|
||||||
return (
|
return (
|
||||||
domainObject.type === 'layout' &&
|
domainObject?.type === 'layout' &&
|
||||||
domainObject.configuration &&
|
domainObject.configuration &&
|
||||||
domainObject.configuration.layout
|
domainObject.configuration.layout
|
||||||
);
|
);
|
||||||
@ -201,7 +201,7 @@ define(['uuid'], function ({ v4: uuid }) {
|
|||||||
{
|
{
|
||||||
check(domainObject) {
|
check(domainObject) {
|
||||||
return (
|
return (
|
||||||
domainObject.type === 'telemetry.fixed' &&
|
domainObject?.type === 'telemetry.fixed' &&
|
||||||
domainObject.configuration &&
|
domainObject.configuration &&
|
||||||
domainObject.configuration['fixed-display']
|
domainObject.configuration['fixed-display']
|
||||||
);
|
);
|
||||||
@ -246,7 +246,7 @@ define(['uuid'], function ({ v4: uuid }) {
|
|||||||
{
|
{
|
||||||
check(domainObject) {
|
check(domainObject) {
|
||||||
return (
|
return (
|
||||||
domainObject.type === 'table' &&
|
domainObject?.type === 'table' &&
|
||||||
domainObject.configuration &&
|
domainObject.configuration &&
|
||||||
domainObject.configuration.table
|
domainObject.configuration.table
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user