|
| 1 | +/***************************************************************************** |
| 2 | + * Open MCT, Copyright (c) 2014-2024, 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 } from '../../../../appActions.js'; |
| 24 | +import { expect, test } from '../../../../pluginFixtures.js'; |
| 25 | + |
| 26 | +test.describe('Folder View Persistence', () => { |
| 27 | + let folder; |
| 28 | + let sineWaveGenerator; |
| 29 | + |
| 30 | + test.beforeEach(async ({ page }) => { |
| 31 | + await page.goto('./', { waitUntil: 'domcontentloaded' }); |
| 32 | + |
| 33 | + // Create a folder |
| 34 | + folder = await createDomainObjectWithDefaults(page, { |
| 35 | + type: 'Folder' |
| 36 | + }); |
| 37 | + |
| 38 | + // Create a sine wave generator inside the folder |
| 39 | + sineWaveGenerator = await createDomainObjectWithDefaults(page, { |
| 40 | + type: 'Sine Wave Generator', |
| 41 | + parent: folder.uuid |
| 42 | + }); |
| 43 | + |
| 44 | + // Navigate to the folder |
| 45 | + await page.goto(folder.url); |
| 46 | + }); |
| 47 | + |
| 48 | + test('Folder view persists when navigating away and back', async ({ page }) => { |
| 49 | + // Click the view switcher button to open the menu |
| 50 | + await page.getByLabel('Open the View Switcher Menu').click(); |
| 51 | + |
| 52 | + // Click the List View option from the dropdown menu |
| 53 | + await page.getByRole('menuitem', { name: /List View/ }).click(); |
| 54 | + |
| 55 | + // Verify that we're now in List view by checking for the c-list-view class |
| 56 | + await expect(page.locator('.c-list-view')).toBeVisible(); |
| 57 | + |
| 58 | + // Navigate to the sine wave generator |
| 59 | + await page.goto(sineWaveGenerator.url); |
| 60 | + |
| 61 | + // Verify we're on the sine wave generator page by checking for the object view container |
| 62 | + await expect(page.locator('.c-object-view.is-object-type-generator')).toBeVisible(); |
| 63 | + |
| 64 | + // Navigate back to the folder |
| 65 | + await page.goto(folder.url); |
| 66 | + |
| 67 | + // Verify that the folder is still in List view |
| 68 | + await expect(page.locator('.c-list-view')).toBeVisible(); |
| 69 | + }); |
| 70 | +}); |
0 commit comments