Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions e2e/helper/addInitExampleUserMultipleRoles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2024, 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.
*****************************************************************************/

// This should be used to install the Example User with multiple roles
document.addEventListener('DOMContentLoaded', () => {
const openmct = window.openmct;
openmct.install(
openmct.plugins.example.ExampleUser({
autoLoginUser: 'mct-user',
statusRoles: ['flight', 'driver'],
roles: ['flight', 'driver']
})
);
});
4 changes: 3 additions & 1 deletion e2e/tests/functional/missionStatus.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ test.describe('Mission Status @addInit', () => {
test.beforeEach(async ({ page }) => {
// FIXME: determine if plugins will be added to index.html or need to be injected
await page.addInitScript({
path: fileURLToPath(new URL('../../helper/addInitExampleUser.js', import.meta.url))
path: fileURLToPath(
new URL('../../helper/addInitExampleUserMultipleRoles.js', import.meta.url)
)
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Select Role')).toBeVisible();
Expand Down
265 changes: 140 additions & 125 deletions e2e/tests/functional/plugins/operatorStatus/operatorStatus.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,145 +33,160 @@ Precondition: Inject Example User, Operator Status Plugins
Verify that user 1 sees updates from user/role 2 (Not possible without openmct-yamcs implementation)

Clear Role Status of single user test
STUB (test.fixme) Rolling through each

*/

test.describe('Operator Status', () => {
test.beforeEach(async ({ page }) => {
// FIXME: determine if plugins will be added to index.html or need to be injected
await page.addInitScript({
path: fileURLToPath(new URL('../../../../helper/addInitExampleUser.js', import.meta.url))
test.describe('as user with status and poll permissions', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: fileURLToPath(
new URL('../../../../helper/addInitExampleUserMultipleRoles.js', import.meta.url)
)
});
await page.addInitScript({
path: fileURLToPath(new URL('../../../../helper/addInitOperatorStatus.js', import.meta.url))
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Select Role')).toBeVisible();
// Description should be empty https://github.com/nasa/openmct/issues/6978
await expect(page.locator('.c-message__action-text')).toBeHidden();
// set role
await page.getByRole('button', { name: 'Select', exact: true }).click();
// dismiss role confirmation popup
await page.getByRole('button', { name: 'Dismiss' }).click();
});
await page.addInitScript({
path: fileURLToPath(new URL('../../../../helper/addInitOperatorStatus.js', import.meta.url))

// verify that operator status is visible
test('operator status is visible and expands when clicked', async ({ page }) => {
await expect(page.locator('div[title="Set my operator status"]')).toBeVisible();
await page.locator('div[title="Set my operator status"]').click();
await expect(page.locator('.c-status-poll-panel')).toBeVisible();
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Select Role')).toBeVisible();
// Description should be empty https://github.com/nasa/openmct/issues/6978
await expect(page.locator('.c-message__action-text')).toBeHidden();
// set role
await page.getByRole('button', { name: 'Select', exact: true }).click();
// dismiss role confirmation popup
await page.getByRole('button', { name: 'Dismiss' }).click();
});

// verify that operator status is visible
test('operator status is visible and expands when clicked', async ({ page }) => {
await expect(page.locator('div[title="Set my operator status"]')).toBeVisible();
await page.locator('div[title="Set my operator status"]').click();
test('poll question indicator remains when blank poll set', async ({ page }) => {
await expect(page.locator('div[title="Set the current poll question"]')).toBeVisible();
await page.locator('div[title="Set the current poll question"]').click();
// set to blank
await page.getByRole('button', { name: 'Update' }).click();

// expect default status to be 'GO'
await expect(page.locator('.c-status-poll-panel')).toBeVisible();
});
// should still be visible
await expect(page.locator('div[title="Set the current poll question"]')).toBeVisible();
});

test('poll question indicator remains when blank poll set', async ({ page }) => {
await expect(page.locator('div[title="Set the current poll question"]')).toBeVisible();
await page.locator('div[title="Set the current poll question"]').click();
// set to blank
await page.getByRole('button', { name: 'Update' }).click();
// Verify that user 1 sees updates from user/role 2 (Not possible without openmct-yamcs implementation)
test('operator status table reflects answered values', async ({ page }) => {
// user navigates to operator status poll
const statusPollIndicator = page.locator('div[title="Set my operator status"]');
await statusPollIndicator.click();

// get user role value
const userRole = page.locator('.c-status-poll-panel__user-role');
const userRoleText = await userRole.innerText();

// get selected status value
const selectStatus = page.locator('select[name="setStatus"]');
await selectStatus.selectOption({ index: 1 });
const initialStatusValue = await selectStatus.inputValue();

// open manage status poll
const manageStatusPollIndicator = page.locator('div[title="Set the current poll question"]');
await manageStatusPollIndicator.click();
// parse the table row values
const row = page.locator(`tr:has-text("${userRoleText}")`);
const rowValues = await row.innerText();
const rowValuesArr = rowValues.split('\t');
const COLUMN_STATUS_INDEX = 1;
// check initial set value matches status table
expect(rowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
initialStatusValue.toLowerCase()
);

// change user status
await statusPollIndicator.click();
// FIXME: might want to grab a dynamic option instead of arbitrary
await page.locator('select[name="setStatus"]').selectOption({ index: 2 });
const updatedStatusValue = await selectStatus.inputValue();
// verify user status is reflected in table
await manageStatusPollIndicator.click();

const updatedRow = page.locator(`tr:has-text("${userRoleText}")`);
const updatedRowValues = await updatedRow.innerText();
const updatedRowValuesArr = updatedRowValues.split('\t');

expect(updatedRowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
updatedStatusValue.toLowerCase()
);
});

// should still be visible
await expect(page.locator('div[title="Set the current poll question"]')).toBeVisible();
});
test('clear poll button removes poll responses', async ({ page }) => {
// user navigates to operator status poll
const statusPollIndicator = page.locator('div[title="Set my operator status"]');
await statusPollIndicator.click();

// get user role value
const userRole = page.locator('.c-status-poll-panel__user-role');
const userRoleText = await userRole.innerText();

// get selected status value
const selectStatus = page.locator('select[name="setStatus"]');
// FIXME: might want to grab a dynamic option instead of arbitrary
await selectStatus.selectOption({ index: 1 });
const initialStatusValue = await selectStatus.inputValue();

// open manage status poll
const manageStatusPollIndicator = page.locator('div[title="Set the current poll question"]');
await manageStatusPollIndicator.click();
// parse the table row values
const row = page.locator(`tr:has-text("${userRoleText}")`);
const rowValues = await row.innerText();
const rowValuesArr = rowValues.split('\t');
const COLUMN_STATUS_INDEX = 1;
// check initial set value matches status table
expect(rowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
initialStatusValue.toLowerCase()
);

// clear the poll
await page.locator('button[title="Clear the previous poll question"]').click();

const updatedRow = page.locator('tr').filter({ hasText: userRoleText });

await expect(updatedRow).toContainText('Not set');
});

// Verify that user 1 sees updates from user/role 2 (Not possible without openmct-yamcs implementation)
test('operator status table reflects answered values', async ({ page }) => {
// user navigates to operator status poll
const statusPollIndicator = page.locator('div[title="Set my operator status"]');
await statusPollIndicator.click();

// get user role value
const userRole = page.locator('.c-status-poll-panel__user-role');
const userRoleText = await userRole.innerText();

// get selected status value
const selectStatus = page.locator('select[name="setStatus"]');
await selectStatus.selectOption({ index: 1 });
const initialStatusValue = await selectStatus.inputValue();

// open manage status poll
const manageStatusPollIndicator = page.locator('div[title="Set the current poll question"]');
await manageStatusPollIndicator.click();
// parse the table row values
const row = page.locator(`tr:has-text("${userRoleText}")`);
const rowValues = await row.innerText();
const rowValuesArr = rowValues.split('\t');
const COLUMN_STATUS_INDEX = 1;
// check initial set value matches status table
expect(rowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
initialStatusValue.toLowerCase()
);

// change user status
await statusPollIndicator.click();
// FIXME: might want to grab a dynamic option instead of arbitrary
await page.locator('select[name="setStatus"]').selectOption({ index: 2 });
const updatedStatusValue = await selectStatus.inputValue();
// verify user status is reflected in table
await manageStatusPollIndicator.click();

const updatedRow = page.locator(`tr:has-text("${userRoleText}")`);
const updatedRowValues = await updatedRow.innerText();
const updatedRowValuesArr = updatedRowValues.split('\t');

expect(updatedRowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
updatedStatusValue.toLowerCase()
);
});
test('Poll indicator is visible when window is really small', async ({ page }) => {
const pollIndicator = page.locator('div[title="Set my operator status"]');
//Make window narrow
await page.setViewportSize({ width: 640, height: 480 });
const indicatorsCount = await page.locator('.c-indicator').count();
//Assert that multiple indicators are active
expect(indicatorsCount).toBeGreaterThanOrEqual(3);
//Assert that indicators are expanded
await expect(page.locator('.l-shell__head')).toContainClass('l-shell__head--expanded');
//Expect poll indicator to be visible
await expect(pollIndicator).toBeInViewport({ ratio: 1 });
});

test('clear poll button removes poll responses', async ({ page }) => {
// user navigates to operator status poll
const statusPollIndicator = page.locator('div[title="Set my operator status"]');
await statusPollIndicator.click();

// get user role value
const userRole = page.locator('.c-status-poll-panel__user-role');
const userRoleText = await userRole.innerText();

// get selected status value
const selectStatus = page.locator('select[name="setStatus"]');
// FIXME: might want to grab a dynamic option instead of arbitrary
await selectStatus.selectOption({ index: 1 });
const initialStatusValue = await selectStatus.inputValue();

// open manage status poll
const manageStatusPollIndicator = page.locator('div[title="Set the current poll question"]');
await manageStatusPollIndicator.click();
// parse the table row values
const row = page.locator(`tr:has-text("${userRoleText}")`);
const rowValues = await row.innerText();
const rowValuesArr = rowValues.split('\t');
const COLUMN_STATUS_INDEX = 1;
// check initial set value matches status table
expect(rowValuesArr[COLUMN_STATUS_INDEX].toLowerCase()).toEqual(
initialStatusValue.toLowerCase()
);

// clear the poll
await page.locator('button[title="Clear the previous poll question"]').click();

const updatedRow = page.locator(`tr:has-text("${userRoleText}")`);
const updatedRowValues = await updatedRow.innerText();
const updatedRowValuesArr = updatedRowValues.split('\t');
const UNSET_VALUE_LABEL = 'Not set';
expect(updatedRowValuesArr[COLUMN_STATUS_INDEX]).toEqual(UNSET_VALUE_LABEL);
test.fixme('iterate through all possible response values', async ({ page }) => {
// test all possible response values for the poll
});
});

test('Poll indicator is visible when window is really small', async ({ page }) => {
const pollIndicator = page.locator('div[title="Set my operator status"]');
//Make window narrow
await page.setViewportSize({ width: 640, height: 480 });
const indicatorsCount = await page.locator('.c-indicator').count();
//Assert that multiple indicators are active
expect(indicatorsCount).toBeGreaterThanOrEqual(3);
//Assert that indicators are expanded
await expect(page.locator('.l-shell__head')).toContainClass('l-shell__head--expanded');
//Expect poll indicator to be visible
await expect(pollIndicator).toBeInViewport({ ratio: 1 });
});
test.describe('as user without status permissions', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: fileURLToPath(new URL('../../../../helper/addInitExampleUser.js', import.meta.url))
});
await page.addInitScript({
path: fileURLToPath(new URL('../../../../helper/addInitOperatorStatus.js', import.meta.url))
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
});

test.fixme('iterate through all possible response values', async ({ page }) => {
// test all possible response values for the poll
// verify that operator status is visible
test('operator status is not visible', async ({ page }) => {
await expect(page.locator('div[title="Set my operator status"]')).toBeHidden();
});
});
});
4 changes: 3 additions & 1 deletion e2e/tests/functional/userRoles.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import { expect, test } from '../../pluginFixtures.js';
test.describe('User Roles', () => {
test('Role prompting', async ({ page }) => {
await page.addInitScript({
path: fileURLToPath(new URL('../../helper/addInitExampleUser.js', import.meta.url))
path: fileURLToPath(
new URL('../../helper/addInitExampleUserMultipleRoles.js', import.meta.url)
)
});
await page.goto('./', { waitUntil: 'domcontentloaded' });

Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/visual-a11y/components/header.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ test.describe('Visual - Header @a11y', () => {
test.describe('Mission Header @a11y', () => {
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: fileURLToPath(new URL('../../../helper/addInitExampleUser.js', import.meta.url))
path: fileURLToPath(
new URL('../../../helper/addInitExampleUserMultipleRoles.js', import.meta.url)
)
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Select Role')).toBeVisible();
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/visual-a11y/missionStatus.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ test.describe('Mission Status Visual Tests @a11y', () => {
const GO = '1';
test.beforeEach(async ({ page }) => {
await page.addInitScript({
path: fileURLToPath(new URL('../../helper/addInitExampleUser.js', import.meta.url))
path: fileURLToPath(
new URL('../../helper/addInitExampleUserMultipleRoles.js', import.meta.url)
)
});
await page.goto('./', { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Select Role')).toBeVisible();
Expand Down
Loading
Loading