-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(#7670): Ensure objects unsubscribe from staleness when destroyed #7736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6384c0e
clear any staleness subscriptions before viewing a new object
jvigliotta 4b3655a
add checkbox to options for createDomainObjectWithDefaults, update sw…
jvigliotta 886dd1b
revert
jvigliotta 00c5918
modified for simplification and to remove the need to update helper m…
jvigliotta dbd0676
consistent naming convention
jvigliotta 5743b79
Update e2e/tests/functional/staleness.e2e.spec.js
jvigliotta d965a80
adding back vars that were removed
jvigliotta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/***************************************************************************** | ||
* Open MCT, Copyright (c) 2014-2023, United States Government | ||
* as represented by the Administrator of the National Aeronautics and Space | ||
* Administration. All rights reserved. | ||
* | ||
* Open MCT is licensed under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* Open MCT includes source code licensed under additional open source | ||
* licenses. See the Open Source Licenses file (LICENSES.md) included with | ||
* this source code distribution or the Licensing information page available | ||
* at runtime from the About dialog for additional information. | ||
*****************************************************************************/ | ||
|
||
import { createDomainObjectWithDefaults, navigateToObjectWithRealTime } from '../../appActions.js'; | ||
import { expect, test } from '../../pluginFixtures.js'; | ||
|
||
test.describe('Staleness', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||
}); | ||
|
||
test('Does not show staleness after navigating from a stale object', async ({ page }) => { | ||
const objectViewSelector = '.c-object-view'; | ||
|
||
const isStaleClass = 'is-stale'; | ||
const staleSWG = await createDomainObjectWithDefaults(page, { | ||
type: 'Sine Wave Generator', | ||
name: 'SWG', | ||
parent: 'mine', | ||
customParameters: { | ||
'label:has([aria-label="Provide Staleness Updates"]) > input': 'true' | ||
} | ||
}); | ||
const folder = await createDomainObjectWithDefaults(page, { | ||
type: 'Folder', | ||
name: 'Folder 1' | ||
}); | ||
|
||
// Navigate to the stale object | ||
await navigateToObjectWithRealTime(page, staleSWG.url); | ||
|
||
// Wait for staleness to be updated | ||
await page.waitForSelector(`.${isStaleClass}`, { state: 'attached' }); | ||
|
||
// Immediately navigate to the folder | ||
await page.goto(folder.url); | ||
|
||
// Verify that staleness is not shown | ||
const objectView = page.locator(objectViewSelector); | ||
const containsStaleClass = await objectView.evaluate((node, staleClass) => { | ||
return node.classList.contains(staleClass); | ||
}, isStaleClass); | ||
await expect(containsStaleClass).toBeFalsy(); | ||
}); | ||
}); | ||
jvigliotta marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,15 +26,13 @@ export default class SinewaveLimitProvider extends EventEmitter { | |
#openmct; | ||
#observingStaleness; | ||
#watchingTheClock; | ||
#isRealTime; | ||
|
||
constructor(openmct) { | ||
super(); | ||
|
||
this.#openmct = openmct; | ||
this.#observingStaleness = {}; | ||
this.#watchingTheClock = false; | ||
this.#isRealTime = undefined; | ||
} | ||
|
||
supportsStaleness(domainObject) { | ||
|
@@ -61,10 +59,7 @@ export default class SinewaveLimitProvider extends EventEmitter { | |
subscribeToStaleness(domainObject, callback) { | ||
const id = this.#getObjectKeyString(domainObject); | ||
|
||
if (this.#isRealTime === undefined) { | ||
this.#updateRealTime(this.#openmct.time.getMode()); | ||
} | ||
|
||
this.#realtimeCheck(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method name slaps |
||
this.#handleClockUpdate(); | ||
|
||
if (this.#observerExists(id)) { | ||
|
@@ -92,17 +87,15 @@ export default class SinewaveLimitProvider extends EventEmitter { | |
|
||
if (observers && !this.#watchingTheClock) { | ||
this.#watchingTheClock = true; | ||
this.#openmct.time.on('modeChanged', this.#updateRealTime, this); | ||
this.#openmct.time.on('modeChanged', this.#realtimeCheck, this); | ||
} else if (!observers && this.#watchingTheClock) { | ||
this.#watchingTheClock = false; | ||
this.#openmct.time.off('modeChanged', this.#updateRealTime, this); | ||
this.#openmct.time.off('modeChanged', this.#realtimeCheck, this); | ||
} | ||
} | ||
|
||
#updateRealTime(mode) { | ||
this.#isRealTime = mode !== 'fixed'; | ||
|
||
if (!this.#isRealTime) { | ||
#realtimeCheck() { | ||
if (!this.#openmct.time.isRealTime()) { | ||
Object.keys(this.#observingStaleness).forEach((id) => { | ||
this.#updateStaleness(id, false); | ||
}); | ||
|
@@ -140,7 +133,7 @@ export default class SinewaveLimitProvider extends EventEmitter { | |
} | ||
|
||
#providingStaleness(domainObject) { | ||
return domainObject.telemetry?.staleness === true && this.#isRealTime; | ||
return domainObject.telemetry?.staleness === true && this.#openmct.time.isRealTime(); | ||
} | ||
|
||
#getObjectKeyString(object) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.