Skip to content

Commit d400fb7

Browse files
committed
test(FaultManagement): shows faults of differing severities
1 parent caab28b commit d400fb7

File tree

1 file changed

+57
-22
lines changed

1 file changed

+57
-22
lines changed

tests/e2e/yamcs/faultManagement.e2e.spec.mjs

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const YAMCS_API_URL = "http://localhost:8090/api/";
3131

3232
test.describe("Fault Management @yamcs", () => {
3333
test.beforeAll("activate alarms on a telemetry point", async () => {
34+
// Set the default alarms for the parameter in such a way
35+
// that it is guaranteed to produce a fault on load.
3436
const response = await setDefaultAlarms('Latitude', [
3537
{
3638
level: 'WATCH',
@@ -62,34 +64,46 @@ test.describe("Fault Management @yamcs", () => {
6264
});
6365

6466
test.beforeEach(async ({ page }) => {
65-
await page.route('**/api/**/alarms', async route => {
66-
const response = await route.fetch();
67-
let body = await response.json();
68-
69-
// Modify the rawValue.floatValue to trigger a specific alarm
70-
body.alarms.forEach(alarm => {
71-
if (alarm.id.name === "Latitude") {
72-
alarm.parameterDetail.currentValue.rawValue.floatValue = 815; // Example value to trigger CRITICAL alarm
73-
alarm.parameterDetail.currentValue.engValue.floatValue = 815; // Example value to trigger CRITICAL alarm
74-
}
67+
68+
const networkPromise = page.waitForResponse('**/api/mdb/myproject/parameters**');
69+
70+
await page.goto('./', { waitUntil: 'domcontentloaded' });
71+
await networkPromise;
72+
});
73+
74+
test('Shows faults of differing severities ', async ({ page }) => {
75+
await test.step('Shows fault with severity WATCH', async () => {
76+
await page.route('**/api/**/alarms', async route => {
77+
await modifyAlarmSeverity(route, "Latitude", 'WATCH');
7578
});
7679

77-
await route.fulfill({
78-
response,
79-
body: JSON.stringify(body),
80-
headers: {
81-
...response.headers(),
82-
'content-type': 'application/json'
83-
}
80+
await page.goto('./', { waitUntil: 'domcontentloaded' });
81+
82+
await page.getByLabel('Navigate to Fault Management').click();
83+
await expect(page.getByLabel('Fault Latitude with severity WATCH in /myproject')).toBeVisible();
84+
});
85+
86+
await test.step('Shows fault with severity WARNING', async () => {
87+
await page.route('**/api/**/alarms', async route => {
88+
await modifyAlarmSeverity(route, "Latitude", 'WARNING');
8489
});
90+
91+
await page.goto('./', { waitUntil: 'domcontentloaded' });
92+
93+
await page.getByLabel('Navigate to Fault Management').click();
94+
await expect(page.getByLabel('Fault Latitude with severity WARNING in /myproject')).toBeVisible();
8595
});
86-
await page.goto('./', { waitUntil: 'domcontentloaded' });
87-
await page.waitForResponse('**/api/mdb/myproject/parameters**');
88-
});
8996

90-
test('Show faults ', async ({ page }) => {
91-
await page.getByLabel('Navigate to Fault Management').click();
97+
await test.step('Shows fault with severity CRITICAL', async () => {
98+
await page.route('**/api/**/alarms', async route => {
99+
await modifyAlarmSeverity(route, "Latitude", 'CRITICAL');
100+
});
101+
102+
await page.goto('./', { waitUntil: 'domcontentloaded' });
92103

104+
await page.getByLabel('Navigate to Fault Management').click();
105+
await expect(page.getByLabel('Fault Latitude with severity CRITICAL in /myproject')).toBeVisible();
106+
});
93107
});
94108

95109
test.afterAll("remove alarms from a telemetry point", async () => {
@@ -166,3 +180,24 @@ async function clearAlarms(parameter, instance = 'myproject', processor = 'realt
166180
async function getAlarms(instance = 'myproject') {
167181
return fetch(`${YAMCS_API_URL}archive/${instance}/alarms`);
168182
}
183+
184+
async function modifyAlarmSeverity(route, alarmName, newSeverity) {
185+
const response = await route.fetch();
186+
let body = await response.json();
187+
188+
// Modify the rawValue.floatValue to trigger a specific alarm
189+
body.alarms.forEach(alarm => {
190+
if (alarm.id.name === alarmName) {
191+
alarm.severity = newSeverity;
192+
}
193+
});
194+
195+
await route.fulfill({
196+
response,
197+
body: JSON.stringify(body),
198+
headers: {
199+
...response.headers(),
200+
'content-type': 'application/json'
201+
}
202+
});
203+
}

0 commit comments

Comments
 (0)