|
| 1 | +/***************************************************************************** |
| 2 | + * Open MCT, Copyright (c) 2014-2023, United States Government |
| 3 | + * as represented by the Administrator of the National Aeronautics and Space |
| 4 | + * Administration. All rights reserved. |
| 5 | + * |
| 6 | + * Open MCT is licensed under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0. |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | + * License for the specific language governing permissions and limitations |
| 15 | + * under the License. |
| 16 | + * |
| 17 | + * Open MCT includes source code licensed under additional open source |
| 18 | + * licenses. See the Open Source Licenses file (LICENSES.md) included with |
| 19 | + * this source code distribution or the Licensing information page available |
| 20 | + * at runtime from the About dialog for additional information. |
| 21 | + *****************************************************************************/ |
| 22 | + |
| 23 | +import { createDomainObjectWithDefaults, navigateToObjectWithRealTime } from '../../appActions.js'; |
| 24 | +import { expect, test } from '../../pluginFixtures.js'; |
| 25 | + |
| 26 | +test.describe('Staleness', () => { |
| 27 | + test.beforeEach(async ({ page }) => { |
| 28 | + await page.goto('./', { waitUntil: 'domcontentloaded' }); |
| 29 | + }); |
| 30 | + |
| 31 | + test('Does not show staleness after navigating from a stale object', async ({ page }) => { |
| 32 | + const objectViewSelector = '.c-object-view'; |
| 33 | + const isStaleClass = 'is-stale'; |
| 34 | + const staleSWG = await createDomainObjectWithDefaults(page, { |
| 35 | + type: 'Sine Wave Generator', |
| 36 | + name: 'SWG' |
| 37 | + }); |
| 38 | + |
| 39 | + // edit properties and enable staleness updates |
| 40 | + await page.getByLabel('More actions').click(); |
| 41 | + await page.getByLabel('Edit properties...').click(); |
| 42 | + await page.getByLabel('Provide Staleness Updates', { exact: true }).click(); |
| 43 | + await page.getByLabel('Save').click(); |
| 44 | + |
| 45 | + const folder = await createDomainObjectWithDefaults(page, { |
| 46 | + type: 'Folder', |
| 47 | + name: 'Folder 1' |
| 48 | + }); |
| 49 | + |
| 50 | + // Navigate to the stale object |
| 51 | + await navigateToObjectWithRealTime(page, staleSWG.url); |
| 52 | + |
| 53 | + // Assert that staleness is shown |
| 54 | + await expect(page.locator(`${objectViewSelector} .${isStaleClass}`)).toBeAttached({ |
| 55 | + timeout: 30 * 1000 // Give 30 seconds for the staleness to be updated |
| 56 | + }); |
| 57 | + |
| 58 | + // Immediately navigate to the folder |
| 59 | + await page.goto(folder.url); |
| 60 | + |
| 61 | + // Verify that staleness is not shown |
| 62 | + await expect(page.locator(`${objectViewSelector} .${isStaleClass}`)).not.toBeAttached(); |
| 63 | + }); |
| 64 | +}); |
0 commit comments