From f470bcd11fbf1be98e364a7acbb20757d91e6e0b Mon Sep 17 00:00:00 2001
From: Maytas Monsereenusorn <52679095+maytasm@users.noreply.github.com>
Date: Wed, 20 May 2020 13:49:28 -1000
Subject: [PATCH] Fix deleting a data node tier causes load rules to display
incorrectly (#9891)
* Fix Deleting a data node tier causes load rules to malfunction & display incorrectly
* add tests
* fix style
---
.../__snapshots__/rule-editor.spec.tsx.snap | 1322 ++++++++++++++++-
.../rule-editor/rule-editor.spec.tsx | 62 +-
.../components/rule-editor/rule-editor.tsx | 5 +-
3 files changed, 1386 insertions(+), 3 deletions(-)
diff --git a/web-console/src/components/rule-editor/__snapshots__/rule-editor.spec.tsx.snap b/web-console/src/components/rule-editor/__snapshots__/rule-editor.spec.tsx.snap
index e1e7c49c98a..43d59de1691 100644
--- a/web-console/src/components/rule-editor/__snapshots__/rule-editor.spec.tsx.snap
+++ b/web-console/src/components/rule-editor/__snapshots__/rule-editor.spec.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`rule editor matches snapshot 1`] = `
+exports[`rule editor matches snapshot no tier in rule 1`] = `
@@ -213,3 +213,1323 @@ exports[`rule editor matches snapshot 1`] = `
`;
+
+exports[`rule editor matches snapshot with existing tier and non existing tier in rule 1`] = `
+
+
+
+
+
+
+
+
+`;
+
+exports[`rule editor matches snapshot with existing tier in rule 1`] = `
+
+
+
+
+
+
+
+
+`;
+
+exports[`rule editor matches snapshot with non existing tier in rule 1`] = `
+
+
+
+
+
+
+
+
+`;
diff --git a/web-console/src/components/rule-editor/rule-editor.spec.tsx b/web-console/src/components/rule-editor/rule-editor.spec.tsx
index fc945a33868..36aeb1c0223 100644
--- a/web-console/src/components/rule-editor/rule-editor.spec.tsx
+++ b/web-console/src/components/rule-editor/rule-editor.spec.tsx
@@ -22,7 +22,7 @@ import React from 'react';
import { RuleEditor } from './rule-editor';
describe('rule editor', () => {
- it('matches snapshot', () => {
+ it('matches snapshot no tier in rule', () => {
const ruleEditor = (
{
const { container } = render(ruleEditor);
expect(container.firstChild).toMatchSnapshot();
});
+
+ it('matches snapshot with non existing tier in rule', () => {
+ const ruleEditor = (
+ {}}
+ onDelete={() => {}}
+ moveUp={null}
+ moveDown={null}
+ />
+ );
+ const { container } = render(ruleEditor);
+ expect(container.firstChild).toMatchSnapshot();
+ });
+
+ it('matches snapshot with existing tier in rule', () => {
+ const ruleEditor = (
+ {}}
+ onDelete={() => {}}
+ moveUp={null}
+ moveDown={null}
+ />
+ );
+ const { container } = render(ruleEditor);
+ expect(container.firstChild).toMatchSnapshot();
+ });
+
+ it('matches snapshot with existing tier and non existing tier in rule', () => {
+ const ruleEditor = (
+ {}}
+ onDelete={() => {}}
+ moveUp={null}
+ moveDown={null}
+ />
+ );
+ const { container } = render(ruleEditor);
+ expect(container.firstChild).toMatchSnapshot();
+ });
});
diff --git a/web-console/src/components/rule-editor/rule-editor.tsx b/web-console/src/components/rule-editor/rule-editor.tsx
index f811adcdbef..cf861c09959 100644
--- a/web-console/src/components/rule-editor/rule-editor.tsx
+++ b/web-console/src/components/rule-editor/rule-editor.tsx
@@ -102,8 +102,11 @@ export const RuleEditor = React.memo(function RuleEditor(props: RuleEditorProps)
onChange(RuleUtil.renameTieredReplicants(rule, tier, e.target.value))
}
>
+
{tiers
- .filter(t => t === tier || !tieredReplicants[t])
+ .filter(t => t !== tier && !tieredReplicants[t])
.map(t => {
return (