Skip to content

Commit adabfc9

Browse files
authored
Merge pull request #524 from NERSC/integration
additional smoke test for checkings NATS connection
2 parents 7f7b68b + 2d2e992 commit adabfc9

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

frontend/interactEM/src/components/natsstatus.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ type NatsStatus = {
99
tooltip: string
1010
}
1111

12+
export const NATS_STATUS_TOOLTIPS = {
13+
disconnected: "NATS is not connected",
14+
draining: "NATS connection is draining",
15+
closed: "NATS connection is closed",
16+
connected: "NATS connection is active",
17+
connecting: "NATS connection is establishing",
18+
} as const
19+
1220
const getNatsStatus = (
1321
connection: NatsConnection | null,
1422
isConnected: boolean,
@@ -17,38 +25,38 @@ const getNatsStatus = (
1725
return {
1826
color: "error",
1927
label: "Disconnected",
20-
tooltip: "NATS is not connected",
28+
tooltip: NATS_STATUS_TOOLTIPS.disconnected,
2129
}
2230
}
2331

2432
if (connection.isDraining()) {
2533
return {
2634
color: "warning",
2735
label: "Draining",
28-
tooltip: "NATS connection is draining",
36+
tooltip: NATS_STATUS_TOOLTIPS.draining,
2937
}
3038
}
3139

3240
if (connection.isClosed()) {
3341
return {
3442
color: "error",
3543
label: "Closed",
36-
tooltip: "NATS connection is closed",
44+
tooltip: NATS_STATUS_TOOLTIPS.closed,
3745
}
3846
}
3947

4048
if (isConnected) {
4149
return {
4250
color: "success",
4351
label: "Connected",
44-
tooltip: "NATS connection is active",
52+
tooltip: NATS_STATUS_TOOLTIPS.connected,
4553
}
4654
}
4755

4856
return {
4957
color: "warning",
5058
label: "Connecting",
51-
tooltip: "NATS connection is establishing",
59+
tooltip: NATS_STATUS_TOOLTIPS.connecting,
5260
}
5361
}
5462

frontend/interactEM/tests/e2e/fixtures/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, test as base, type Page } from "@playwright/test"
1+
import { expect, test as base, type Page, type TestType } from "@playwright/test"
22

33
const username = process.env.FIRST_SUPERUSER_USERNAME
44
const password = process.env.FIRST_SUPERUSER_PASSWORD
@@ -23,7 +23,7 @@ type Fixtures = {
2323
authPage: Page
2424
}
2525

26-
export const test = base.extend<Fixtures>({
26+
export const test: TestType<Fixtures, {}> = base.extend<Fixtures>({
2727
authPage: async ({ page }, use) => {
2828
await login(page)
2929
await use(page)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import { expect } from "@playwright/test"
2+
import { NATS_STATUS_TOOLTIPS } from "../../src/components/natsstatus"
23
import { test } from "./fixtures/auth"
34

45
test("loads composer page", async ({ authPage }) => {
56
await authPage.waitForSelector(".composer-page", { timeout: 20_000 })
67
await expect(authPage.locator(".composer-page")).toBeVisible()
78
})
9+
10+
test("shows NATS connected after login", async ({ authPage }) => {
11+
const natsChip = authPage
12+
.locator(".composer-page")
13+
.getByText("NATS", { exact: true })
14+
15+
await expect(natsChip).toBeVisible()
16+
await natsChip.hover()
17+
await expect(authPage.getByRole("tooltip")).toHaveText(
18+
NATS_STATUS_TOOLTIPS.connected,
19+
{ timeout: 5_000 },
20+
)
21+
})

frontend/interactEM/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"noFallthroughCasesInSwitch": true,
2222
// Recommended setting (not in strict, but should be)
2323
"noUncheckedIndexedAccess": true,
24-
"types": ["node"]
24+
"types": ["node", "@playwright/test"]
2525
},
2626
"include": ["src", "tests", "playwright.config.ts"],
2727
"references": [{ "path": "./tsconfig.node.json" }]

0 commit comments

Comments
 (0)