diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/redirections.constants.js b/openmetadata-ui/src/main/resources/ui/cypress/constants/redirections.constants.js
index 255fca85f97..b4e2ef1145a 100644
--- a/openmetadata-ui/src/main/resources/ui/cypress/constants/redirections.constants.js
+++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/redirections.constants.js
@@ -63,7 +63,7 @@ export const LEFT_PANEL_DETAILS = {
export const NAVBAR_DETAILS = {
explore: {
testid: '[data-testid="appbar-item-explore"]',
- url: `${BASE_URL}/explore/tables?page=1`,
+ url: `${BASE_URL}/explore/tables`,
},
quality: {
testid: '[data-testid="appbar-item-data-quality"]',
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.test.tsx
new file mode 100644
index 00000000000..c15314c6831
--- /dev/null
+++ b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.test.tsx
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2023 Collate.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { act, fireEvent, render, screen } from '@testing-library/react';
+import {
+ MOCK_TEST_CASE,
+ MOCK_TEST_DEFINITION_COLUMN_VALUES_TO_MATCH_REGEX,
+} from 'mocks/TestSuite.mock';
+import React, { forwardRef } from 'react';
+import { EditTestCaseModalProps } from './AddDataQualityTest.interface';
+import EditTestCaseModal from './EditTestCaseModal';
+
+const mockProps: EditTestCaseModalProps = {
+ visible: true,
+ testCase: MOCK_TEST_CASE[0],
+ onCancel: jest.fn(),
+ onUpdate: jest.fn(),
+};
+
+jest.mock('../common/rich-text-editor/RichTextEditor', () => {
+ return forwardRef(
+ jest.fn().mockImplementation(() =>
RichTextEditor.component
)
+ );
+});
+jest.mock('./components/ParameterForm', () => {
+ return jest.fn().mockImplementation(() => ParameterForm.component
);
+});
+jest.mock('rest/testAPI', () => {
+ return {
+ getTestDefinitionById: jest
+ .fn()
+ .mockImplementation(() =>
+ Promise.resolve(MOCK_TEST_DEFINITION_COLUMN_VALUES_TO_MATCH_REGEX)
+ ),
+ updateTestCaseById: jest.fn().mockImplementation(() => Promise.resolve()),
+ };
+});
+
+describe('EditTestCaseModal Component', () => {
+ it('component should render', async () => {
+ render( );
+
+ expect(await screen.findByTestId('edit-test-form')).toBeInTheDocument();
+ expect(await screen.findByLabelText('label.table')).toBeInTheDocument();
+ expect(await screen.findByLabelText('label.column')).toBeInTheDocument();
+ expect(await screen.findByLabelText('label.name')).toBeInTheDocument();
+ expect(
+ await screen.findByLabelText('label.display-name')
+ ).toBeInTheDocument();
+ expect(
+ await screen.findByLabelText('label.test-entity')
+ ).toBeInTheDocument();
+ expect(
+ await screen.findByText('RichTextEditor.component')
+ ).toBeInTheDocument();
+ expect(
+ await screen.findByText('ParameterForm.component')
+ ).toBeInTheDocument();
+ expect(await screen.findByText('label.cancel')).toBeInTheDocument();
+ expect(await screen.findByText('label.submit')).toBeInTheDocument();
+ });
+
+ it('table, name, test definition, should be disabled', async () => {
+ render( );
+
+ expect(await screen.findByLabelText('label.name')).toBeDisabled();
+ expect(await screen.findByLabelText('label.column')).toBeDisabled();
+ expect(await screen.findByLabelText('label.table')).toBeDisabled();
+ expect(await screen.findByLabelText('label.test-entity')).toBeDisabled();
+ });
+
+ it('fields should have data based on testCase value', async () => {
+ render( );
+
+ expect(await screen.findByLabelText('label.table')).toHaveValue(
+ 'dim_address'
+ );
+ expect(await screen.findByLabelText('label.column')).toHaveValue(
+ 'last_name'
+ );
+ expect(await screen.findByLabelText('label.name')).toHaveValue(
+ 'column_values_to_match_regex'
+ );
+ expect(await screen.findByLabelText('label.test-entity')).toHaveValue(
+ 'columnValuesToMatchRegex'
+ );
+ });
+
+ it('should call onCancel function, on click of cancel button', async () => {
+ render( );
+
+ const cancelBtn = await screen.findByText('label.cancel');
+
+ await act(async () => {
+ fireEvent.click(cancelBtn);
+ });
+
+ expect(mockProps.onCancel).toHaveBeenCalled();
+ });
+
+ it('should call onUpdate function, on click of submit button', async () => {
+ render( );
+
+ const submitBtn = await screen.findByText('label.submit');
+
+ await act(async () => {
+ fireEvent.click(submitBtn);
+ });
+
+ expect(mockProps.onUpdate).toHaveBeenCalled();
+ });
+});
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.tsx
index 799287a5cc8..dcf3f81407a 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/EditTestCaseModal.tsx
@@ -198,6 +198,7 @@ const EditTestCaseModal: React.FC = ({
form.resetFields();
onCancel();
}}
+ cancelText={t('label.cancel')}
closable={false}
confirmLoading={isLoadingOnSave}
maskClosable={false}
@@ -212,21 +213,22 @@ const EditTestCaseModal: React.FC = ({
) : (
+
{isColumn && (
-
+
)}
= ({
{GenerateParamsField()}
-
+
{
};
useEffect(() => {
- if (isUndefined(testSummary)) {
- if (testCasePermission?.ViewAll || testCasePermission?.ViewBasic) {
- fetchTestSummary();
- }
+ if (
+ isUndefined(testSummary) &&
+ (testCasePermission?.ViewAll || testCasePermission?.ViewBasic)
+ ) {
+ fetchTestSummary();
} else {
- setSummary(testSummary);
+ setSummary(testSummary ?? INITIAL_TEST_SUMMARY);
setIsLoading(false);
}
}, [testCasePermission]);
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/SummaryPannel/SummaryPanel.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/SummaryPannel/SummaryPanel.test.tsx
new file mode 100644
index 00000000000..2f854c09544
--- /dev/null
+++ b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/SummaryPannel/SummaryPanel.test.tsx
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2023 Collate.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { render, screen } from '@testing-library/react';
+import React from 'react';
+import { getTestCaseExecutionSummary } from 'rest/testAPI';
+import { SummaryPanel } from './SummaryPanel.component';
+
+const testCasePermission = {
+ Create: true,
+ Delete: true,
+ ViewAll: true,
+ EditAll: true,
+ EditDescription: true,
+ EditDisplayName: true,
+ EditCustomFields: true,
+};
+const mockSummary = {
+ total: 10,
+ success: 7,
+ aborted: 2,
+ failed: 1,
+};
+
+jest.mock('components/PermissionProvider/PermissionProvider', () => ({
+ usePermissionProvider: jest.fn().mockImplementation(() => ({
+ permissions: {
+ testCase: testCasePermission,
+ },
+ })),
+}));
+jest.mock('components/common/SummaryCard/SummaryCard.component', () => {
+ return {
+ SummaryCard: jest
+ .fn()
+ .mockImplementation(() => SummaryCard.component
),
+ };
+});
+jest.mock('rest/testAPI', () => {
+ return {
+ getTestCaseExecutionSummary: jest
+ .fn()
+ .mockImplementation(() => Promise.resolve(mockSummary)),
+ };
+});
+
+describe('SummaryPanel component', () => {
+ it('component should render', async () => {
+ render( );
+
+ const summaryCards = await screen.findAllByText('SummaryCard.component');
+
+ expect(summaryCards).toHaveLength(4);
+ });
+
+ it('on page load getTestCaseExecutionSummary API should call', async () => {
+ const mockGetTestCaseExecutionSummary =
+ getTestCaseExecutionSummary as jest.Mock;
+ render( );
+
+ expect(mockGetTestCaseExecutionSummary).toHaveBeenCalled();
+ });
+
+ it('should not call getTestCaseExecutionSummary API, if testSummary data is provided', async () => {
+ const mockGetTestCaseExecutionSummary =
+ getTestCaseExecutionSummary as jest.Mock;
+ render( );
+
+ expect(mockGetTestCaseExecutionSummary).not.toHaveBeenCalled();
+ });
+
+ it('should not call getTestCaseExecutionSummary API, if there is no permission', async () => {
+ const mockGetTestCaseExecutionSummary =
+ getTestCaseExecutionSummary as jest.Mock;
+ testCasePermission.ViewAll = false;
+ render( );
+
+ expect(mockGetTestCaseExecutionSummary).not.toHaveBeenCalled();
+ });
+});
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCaseStatusModal/TestCaseStatusModal.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCaseStatusModal/TestCaseStatusModal.component.tsx
index 2b52f836a3f..5975c5a0285 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCaseStatusModal/TestCaseStatusModal.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestCaseStatusModal/TestCaseStatusModal.component.tsx
@@ -51,6 +51,7 @@ export const TestCaseStatusModal = ({
return (