Browse Source

Test new functionality

GneyHabub 4 years ago
parent
commit
b9f6390b10

+ 13 - 0
kafka-ui-react-app/src/components/Dashboard/ClustersWidget/__test__/ClusterWidget.spec.tsx

@@ -70,4 +70,17 @@ describe('ClusterWidget', () => {
       ).toMatchSnapshot();
     });
   });
+
+  describe('when cluster is read-only', () => {
+    it('renders the tag', () => {
+      expect(
+        shallow(
+          <ClusterWidget cluster={{ ...onlineCluster, readOnly: true }} />
+        )
+          .find('.title')
+          .childAt(1)
+          .text()
+      ).toEqual('readonly');
+    });
+  });
 });

+ 6 - 0
kafka-ui-react-app/src/components/Schemas/Details/__test__/Details.spec.tsx

@@ -101,6 +101,12 @@ describe('Details', () => {
           expect(shallow(setupWrapper({ versions }))).toMatchSnapshot();
         });
       });
+
+      describe('when the readonly flag is set', () => {
+        it('mathces the snapshot', () => {
+          expect(shallow(setupWrapper({ isReadOnly: true }))).toMatchSnapshot();
+        });
+      });
     });
   });
 });

+ 86 - 0
kafka-ui-react-app/src/components/Schemas/Details/__test__/__snapshots__/Details.spec.tsx.snap

@@ -322,6 +322,92 @@ exports[`Details View when page with schema versions loaded when schema has vers
 </div>
 `;
 
+exports[`Details View when page with schema versions loaded when the readonly flag is set mathces the snapshot 1`] = `
+<div
+  className="section"
+>
+  <div
+    className="level"
+  >
+    <Breadcrumb
+      links={
+        Array [
+          Object {
+            "href": "/ui/clusters/Test cluster/schemas",
+            "label": "Schema Registry",
+          },
+        ]
+      }
+    >
+      test
+    </Breadcrumb>
+  </div>
+  <div
+    className="box"
+  >
+    <div
+      className="level"
+    >
+      <div
+        className="level-left"
+      >
+        <div
+          className="level-item"
+        >
+          <div
+            className="mr-1"
+          >
+            <b>
+              Latest Version
+            </b>
+          </div>
+          <div
+            className="tag is-info is-light"
+            title="Version"
+          >
+            #
+            1
+          </div>
+        </div>
+      </div>
+    </div>
+    <LatestVersionItem
+      schema={
+        Object {
+          "compatibilityLevel": "BACKWARD",
+          "id": 1,
+          "schema": "{\\"type\\":\\"record\\",\\"name\\":\\"MyRecord1\\",\\"namespace\\":\\"com.mycompany\\",\\"fields\\":[{\\"name\\":\\"id\\",\\"type\\":\\"long\\"}]}",
+          "subject": "test",
+          "version": "1",
+        }
+      }
+    />
+  </div>
+  <div
+    className="box"
+  >
+    <table
+      className="table is-striped is-fullwidth"
+    >
+      <thead>
+        <tr>
+          <th>
+            Version
+          </th>
+          <th>
+            ID
+          </th>
+          <th>
+            Schema
+          </th>
+        </tr>
+      </thead>
+      <tbody />
+    </table>
+  </div>
+</div>
+`;
+
 exports[`Details View when page with schema versions loaded when versions are empty matches snapshot 1`] = `
 <div
   className="section"

+ 7 - 0
kafka-ui-react-app/src/components/Schemas/List/__test__/List.spec.tsx

@@ -49,5 +49,12 @@ describe('List', () => {
         expect(wrapper.find('ListItem').length).toEqual(3);
       });
     });
+
+    describe('with readonly cluster', () => {
+      const wrapper = shallow(setupWrapper({ schemas, isReadOnly: true }));
+      it('does not render Create Schema button', () => {
+        expect(wrapper.exists('NavLink')).toBeFalsy();
+      });
+    });
   });
 });

+ 18 - 0
kafka-ui-react-app/src/components/Topics/List/__tests__/List.spec.tsx

@@ -0,0 +1,18 @@
+import { shallow } from 'enzyme';
+import React from 'react';
+import List from '../List';
+
+describe('List', () => {
+  describe('when it has readonly flag', () => {
+    it('does not render the Add a Topic button', () => {
+      const props = {
+        clusterName: 'Cluster',
+        topics: [],
+        externalTopics: [],
+        isReadOnly: true,
+      };
+      const component = shallow(<List {...props} />);
+      expect(component.exists('NavLink')).toBeFalsy();
+    });
+  });
+});