Skip to content

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 7 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions e2e/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,8 @@ async function createDomainObjectWithDefaults(
// If there are any further parameters, fill them in
for (const [key, value] of Object.entries(customParameters)) {
const input = page.locator(`form[name="mctForm"] ${key}`);
const inputType = await input.getAttribute('type');

if (inputType === 'checkbox') {
// Locate the slider span associated with the checkbox
const slider = input.locator('+ .c-toggle-switch__slider');
const isChecked = await input.isChecked();
if ((value === 'true' && !isChecked) || (value === 'false' && isChecked)) {
await slider.click();
}
} else {
await input.fill('');
await input.fill(value);
}
await input.fill('');
await input.fill(value);
}

// Click OK button and wait for Navigate event
Expand Down
13 changes: 8 additions & 5 deletions e2e/tests/functional/staleness.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ test.describe('Staleness', () => {
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'
}
name: 'SWG'
});

// edit properties and enable staleness updates
await page.getByLabel('More actions').click();
await page.getByLabel('Edit properties...').click();
await page.getByLabel('Provide Staleness Updates', { exact: true }).click();
await page.getByLabel('Save').click();
Comment on lines +39 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌


const folder = await createDomainObjectWithDefaults(page, {
type: 'Folder',
name: 'Folder 1'
Expand Down
8 changes: 4 additions & 4 deletions example/generator/SinewaveStalenessProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class SinewaveLimitProvider extends EventEmitter {
subscribeToStaleness(domainObject, callback) {
const id = this.#getObjectKeyString(domainObject);

this.#realtimeCheck();
this.#realTimeCheck();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoomp there it is

this.#handleClockUpdate();

if (this.#observerExists(id)) {
Expand Down Expand Up @@ -87,14 +87,14 @@ export default class SinewaveLimitProvider extends EventEmitter {

if (observers && !this.#watchingTheClock) {
this.#watchingTheClock = true;
this.#openmct.time.on('modeChanged', this.#realtimeCheck, this);
this.#openmct.time.on('modeChanged', this.#realTimeCheck, this);
} else if (!observers && this.#watchingTheClock) {
this.#watchingTheClock = false;
this.#openmct.time.off('modeChanged', this.#realtimeCheck, this);
this.#openmct.time.off('modeChanged', this.#realTimeCheck, this);
}
}

#realtimeCheck() {
#realTimeCheck() {
if (!this.#openmct.time.isRealTime()) {
Object.keys(this.#observingStaleness).forEach((id) => {
this.#updateStaleness(id, false);
Expand Down
Loading