mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 14:18:16 +00:00
feat(Fault Management): allow fault providers to define shelve durations (#7849)
* refactor: clean up FaultManagementView code * feat: providers can now provide "Shelve Duration" options * fix(exampleFaultSource): support `getShelveDurations` * a11y: aria label for fault management list item * a11y(FaultManagement): more labels * refactor: eliminate some faultUtils and refactor locator() out of tests * docs: add some more docs to fault management api * refactor: make for loop more readable * test: use static faults when testing * fix: set a timestamp for static faults and subtract so we get faults in order * refactor: autoformat * chore: add missing copyright header * fix: use as default parameter to get value as method is called * refactor: make magic number a const * fix(codecov): use codecov github action to upload * fix: generate the report * build: update circleci yml to use codecov orb * build: remove codecov scripts and package * build: don't use the orb because things can't be easy - nasa org disallows "third party" orbs * build: only use `sudo` if we ain't da root user --------- Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
@ -25,6 +25,7 @@ import { expect } from '../pluginFixtures.js';
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function navigateToFaultManagementWithExample(page) {
|
||||
await page.addInitScript({
|
||||
@ -36,6 +37,7 @@ export async function navigateToFaultManagementWithExample(page) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function navigateToFaultManagementWithStaticExample(page) {
|
||||
await page.addInitScript({
|
||||
@ -47,6 +49,7 @@ export async function navigateToFaultManagementWithStaticExample(page) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function navigateToFaultManagementWithoutExample(page) {
|
||||
await page.addInitScript({
|
||||
@ -58,6 +61,7 @@ export async function navigateToFaultManagementWithoutExample(page) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function navigateToFaultItemInTree(page) {
|
||||
await page.goto('./', { waitUntil: 'domcontentloaded' });
|
||||
@ -77,6 +81,8 @@ async function navigateToFaultItemInTree(page) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function acknowledgeFault(page, rowNumber) {
|
||||
await openFaultRowMenu(page, rowNumber);
|
||||
@ -86,6 +92,8 @@ export async function acknowledgeFault(page, rowNumber) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {...number} nums
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function shelveMultipleFaults(page, ...nums) {
|
||||
const selectRows = nums.map((num) => {
|
||||
@ -99,6 +107,8 @@ export async function shelveMultipleFaults(page, ...nums) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {...number} nums
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function acknowledgeMultipleFaults(page, ...nums) {
|
||||
const selectRows = nums.map((num) => {
|
||||
@ -106,50 +116,43 @@ export async function acknowledgeMultipleFaults(page, ...nums) {
|
||||
});
|
||||
await Promise.all(selectRows);
|
||||
|
||||
await page.locator('button:has-text("Acknowledge")').click();
|
||||
await page.getByLabel('Acknowledge selected faults').click();
|
||||
await page.getByLabel('Save').click();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function shelveFault(page, rowNumber) {
|
||||
await openFaultRowMenu(page, rowNumber);
|
||||
await page.locator('.c-menu >> text="Shelve"').click();
|
||||
// Click [aria-label="Save"]
|
||||
await page.getByLabel('Shelve', { exact: true }).click();
|
||||
await page.getByLabel('Save').click();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
export async function changeViewTo(page, view) {
|
||||
await page.locator('.c-fault-mgmt__search-row select').first().selectOption(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {'severity' | 'newest-first' | 'oldest-first'} sort
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function sortFaultsBy(page, sort) {
|
||||
await page.locator('.c-fault-mgmt__list-header-sortButton select').selectOption(sort);
|
||||
await page.getByTitle('Sort By').getByRole('combobox').selectOption(sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {'acknowledged' | 'shelved' | 'standard view'} view
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function enterSearchTerm(page, term) {
|
||||
await page.locator('.c-fault-mgmt-search [aria-label="Search Input"]').fill(term);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
export async function clearSearch(page) {
|
||||
await enterSearchTerm(page, '');
|
||||
export async function changeViewTo(page, view) {
|
||||
await page.getByTitle('View Filter').getByRole('combobox').selectOption(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function selectFaultItem(page, rowNumber) {
|
||||
await page
|
||||
@ -165,71 +168,37 @@ export async function selectFaultItem(page, rowNumber) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
export async function getHighestSeverity(page) {
|
||||
const criticalCount = await page.locator('[title=CRITICAL]').count();
|
||||
const warningCount = await page.locator('[title=WARNING]').count();
|
||||
|
||||
if (criticalCount > 0) {
|
||||
return 'CRITICAL';
|
||||
} else if (warningCount > 0) {
|
||||
return 'WARNING';
|
||||
}
|
||||
|
||||
return 'WATCH';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
export async function getLowestSeverity(page) {
|
||||
const warningCount = await page.locator('[title=WARNING]').count();
|
||||
const watchCount = await page.locator('[title=WATCH]').count();
|
||||
|
||||
if (watchCount > 0) {
|
||||
return 'WATCH';
|
||||
} else if (warningCount > 0) {
|
||||
return 'WARNING';
|
||||
}
|
||||
|
||||
return 'CRITICAL';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
export async function getFaultResultCount(page) {
|
||||
const count = await page.locator('.c-faults-list-view-item-body > .c-fault-mgmt__list').count();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {import('@playwright/test').Locator}
|
||||
*/
|
||||
export function getFault(page, rowNumber) {
|
||||
const fault = page.locator(
|
||||
`.c-faults-list-view-item-body > .c-fault-mgmt__list >> nth=${rowNumber - 1}`
|
||||
);
|
||||
const fault = page.getByLabel('Fault triggered at').nth(rowNumber - 1);
|
||||
|
||||
return fault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {string} name
|
||||
* @returns {import('@playwright/test').Locator}
|
||||
*/
|
||||
export function getFaultByName(page, name) {
|
||||
const fault = page.locator(`.c-fault-mgmt__list-faultname:has-text("${name}")`);
|
||||
const fault = page.getByLabel('Fault triggered at').filter({
|
||||
hasText: name
|
||||
});
|
||||
|
||||
return fault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export async function getFaultName(page, rowNumber) {
|
||||
const faultName = await page
|
||||
.locator(`.c-fault-mgmt__list-faultname >> nth=${rowNumber - 1}`)
|
||||
.getByLabel('Fault name', { exact: true })
|
||||
.nth(rowNumber - 1)
|
||||
.textContent();
|
||||
|
||||
return faultName;
|
||||
@ -237,21 +206,13 @@ export async function getFaultName(page, rowNumber) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
export async function getFaultSeverity(page, rowNumber) {
|
||||
const faultSeverity = await page
|
||||
.locator(`.c-faults-list-view-item-body .c-fault-mgmt__list-severity >> nth=${rowNumber - 1}`)
|
||||
.getAttribute('title');
|
||||
|
||||
return faultSeverity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export async function getFaultNamespace(page, rowNumber) {
|
||||
const faultNamespace = await page
|
||||
.locator(`.c-fault-mgmt__list-path >> nth=${rowNumber - 1}`)
|
||||
.getByLabel('Fault namespace')
|
||||
.nth(rowNumber - 1)
|
||||
.textContent();
|
||||
|
||||
return faultNamespace;
|
||||
@ -259,10 +220,13 @@ export async function getFaultNamespace(page, rowNumber) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export async function getFaultTriggerTime(page, rowNumber) {
|
||||
const faultTriggerTime = await page
|
||||
.locator(`.c-fault-mgmt__list-trigTime >> nth=${rowNumber - 1} >> .c-fault-mgmt-item__value`)
|
||||
.getByLabel('Last Trigger Time')
|
||||
.nth(rowNumber - 1)
|
||||
.textContent();
|
||||
|
||||
return faultTriggerTime.toString().trim();
|
||||
@ -270,11 +234,14 @@ export async function getFaultTriggerTime(page, rowNumber) {
|
||||
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
* @param {number} rowNumber
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function openFaultRowMenu(page, rowNumber) {
|
||||
// select
|
||||
await page
|
||||
.getByLabel('Disposition actions')
|
||||
.getByLabel('Fault triggered at')
|
||||
.nth(rowNumber - 1)
|
||||
.getByLabel('Disposition Actions')
|
||||
.click();
|
||||
}
|
||||
|
Reference in New Issue
Block a user