90 lines
2.9 KiB
Diff
90 lines
2.9 KiB
Diff
From 2403a2414f234a4025055e56f8202094caf1b655 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Devat <idevat@redhat.com>
|
|
Date: Thu, 30 Mar 2023 17:03:06 +0200
|
|
Subject: [PATCH] fix cluster-status/fence_levels shape expectation
|
|
|
|
---
|
|
jest.config.js | 1 +
|
|
.../endpoints/clusterStatus/shape/cluster.ts | 10 +++--
|
|
.../cluster/displayAdvancedStatus.test.ts | 37 +++++++++++++++++++
|
|
3 files changed, 44 insertions(+), 4 deletions(-)
|
|
create mode 100644 src/test/scenes/cluster/displayAdvancedStatus.test.ts
|
|
|
|
diff --git a/jest.config.js b/jest.config.js
|
|
index 08660443..c5c39dc5 100644
|
|
--- a/jest.config.js
|
|
+++ b/jest.config.js
|
|
@@ -1,4 +1,5 @@
|
|
module.exports = {
|
|
globalSetup: "./src/test/jest-preset.ts",
|
|
moduleDirectories: ["node_modules", "src"],
|
|
+ testTimeout: 10000,
|
|
};
|
|
diff --git a/src/app/backend/endpoints/clusterStatus/shape/cluster.ts b/src/app/backend/endpoints/clusterStatus/shape/cluster.ts
|
|
index 97ec4f17..ea29470e 100644
|
|
--- a/src/app/backend/endpoints/clusterStatus/shape/cluster.ts
|
|
+++ b/src/app/backend/endpoints/clusterStatus/shape/cluster.ts
|
|
@@ -13,10 +13,12 @@ The key of record is a target.
|
|
*/
|
|
const ApiFencingLevels = t.record(
|
|
t.string,
|
|
- t.type({
|
|
- level: t.string,
|
|
- devices: t.array(t.string),
|
|
- }),
|
|
+ t.array(
|
|
+ t.type({
|
|
+ level: t.string,
|
|
+ devices: t.string,
|
|
+ }),
|
|
+ ),
|
|
);
|
|
|
|
export const ApiClusterStatusFlag = t.keyof({
|
|
diff --git a/src/test/scenes/cluster/displayAdvancedStatus.test.ts b/src/test/scenes/cluster/displayAdvancedStatus.test.ts
|
|
new file mode 100644
|
|
index 00000000..78eb7dbe
|
|
--- /dev/null
|
|
+++ b/src/test/scenes/cluster/displayAdvancedStatus.test.ts
|
|
@@ -0,0 +1,37 @@
|
|
+// Cluster status is pretty complex. Sometimes a discrepancy between frontend
|
|
+// and backend appears. This modules collect tests for discovered cases.
|
|
+
|
|
+import * as t from "dev/responses/clusterStatus/tools";
|
|
+
|
|
+import {dt} from "test/tools/selectors";
|
|
+import {location, shortcuts} from "test/tools";
|
|
+
|
|
+const clusterName = "test-cluster";
|
|
+
|
|
+// We want to see browser behavior with (for now) invalid status before fix. But
|
|
+// the typecheck tell us that it is wrong and dev build fails. So, we decive it.
|
|
+const deceiveTypeCheck = (maybeInvalidPart: ReturnType<typeof JSON.parse>) =>
|
|
+ JSON.parse(JSON.stringify(maybeInvalidPart));
|
|
+
|
|
+describe("Cluster with advanced status", () => {
|
|
+ it("accept fence levels", async () => {
|
|
+ shortcuts.interceptWithCluster({
|
|
+ clusterStatus: t.cluster(clusterName, "ok", {
|
|
+ fence_levels: deceiveTypeCheck({
|
|
+ "node-1": [
|
|
+ {
|
|
+ level: "1",
|
|
+ devices: "fence-1",
|
|
+ },
|
|
+ {
|
|
+ level: "2",
|
|
+ devices: "fence-2",
|
|
+ },
|
|
+ ],
|
|
+ }),
|
|
+ }),
|
|
+ });
|
|
+ await page.goto(location.cluster({clusterName}));
|
|
+ await page.waitForSelector(dt("cluster-overview"));
|
|
+ });
|
|
+});
|
|
--
|
|
2.39.2
|
|
|