UI: Fixed issue: TestSuite descriptions are unable to update and also unable to create a test suite when edit tests permission is given#7507 (#7557)

This commit is contained in:
Shailesh Parmar 2022-09-20 02:59:15 +05:30 committed by GitHub
parent 209aecc4a0
commit 9ee96deec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 36 deletions

View File

@ -101,7 +101,7 @@ export const NEW_TEST_SUITE = {
};
export const NEW_TABLE_TEST_CASE = {
type: 'TableColumnNameToExist',
type: 'tableColumnNameToExist',
field: 'id',
description: 'New table test case for TableColumnNameToExist',
};

View File

@ -22,7 +22,11 @@ const columnTestName = `${NEW_COLUMN_TEST_CASE.column}_${NEW_COLUMN_TEST_CASE.ty
const goToProfilerTab = () => {
// click on the 1st result and go to entity details page and follow the entity
interceptURL('GET', '/api/v1/feed*', 'getEntityDetails');
interceptURL(
'GET',
'/api/v1/tables/name/*?fields=columns,usageSummary,followers,joins,tags,owner,dataModel,profile,tests,tableConstraints,extension&include=all',
'getEntityDetails'
);
cy.get('[data-testid="table-link"]')
.first()
.contains(TEAM_ENTITY, { matchCase: false })
@ -162,11 +166,16 @@ describe('Data Quality and Profiler should work properly', () => {
// wait for ingestion to run
cy.clock();
cy.wait(10000);
interceptURL(
'GET',
'/api/v1/testCase?fields=testCaseResult,testDefinition,testSuite&testSuiteId=*&limit=10',
'testCase'
);
cy.get('[data-testid="view-service-button"]')
.should('be.visible')
.click({ force: true });
verifyResponseStatusCode('@testCase', 200);
cy.contains(`${TEAM_ENTITY}_${NEW_TABLE_TEST_CASE.type}`).should(
'be.visible'
);

View File

@ -19,9 +19,11 @@ import React, { useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { ReactComponent as ArrowDown } from '../../../assets/svg/arrow-down.svg';
import { ReactComponent as ArrowRight } from '../../../assets/svg/arrow-right.svg';
import { useAuthContext } from '../../../authentication/auth-provider/AuthProvider';
import { getTableTabPath } from '../../../constants/constants';
import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil';
import { TestCase, TestCaseResult } from '../../../generated/tests/testCase';
import { useAuth } from '../../../hooks/authHooks';
import { getEntityName, getNameFromFQN } from '../../../utils/CommonUtils';
import { getTestSuitePath } from '../../../utils/RouterUtils';
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
@ -37,10 +39,13 @@ import TestSummary from './TestSummary';
const DataQualityTab: React.FC<DataQualityTabProps> = ({
testCases,
onTestUpdate,
hasAccess,
}) => {
const [selectedTestCase, setSelectedTestCase] = useState<TestCase>();
const [editTestCase, setEditTestCase] = useState<TestCase>();
const { isAdminUser } = useAuth();
const { isAuthDisabled } = useAuthContext();
const hasAccess = isAdminUser || isAuthDisabled;
const columns: ColumnsType<TestCase> = useMemo(() => {
return [
@ -140,28 +145,6 @@ const DataQualityTab: React.FC<DataQualityTabProps> = ({
render: (_, record) => {
return (
<Row align="middle">
<Tooltip
placement="bottomLeft"
title={hasAccess ? 'Delete' : NO_PERMISSION_FOR_ACTION}>
<Button
className="flex-center"
data-testid={`delete-${record.name}`}
disabled={!hasAccess}
icon={
<SVGIcons
alt="Delete"
className="tw-h-4"
icon={Icons.DELETE}
/>
}
type="text"
onClick={(e) => {
// preventing expand/collapse on click of delete button
e.stopPropagation();
setSelectedTestCase(record);
}}
/>
</Tooltip>
<Tooltip
placement="bottomRight"
title={hasAccess ? 'Edit' : NO_PERMISSION_FOR_ACTION}>
@ -185,6 +168,28 @@ const DataQualityTab: React.FC<DataQualityTabProps> = ({
}}
/>
</Tooltip>
<Tooltip
placement="bottomLeft"
title={hasAccess ? 'Delete' : NO_PERMISSION_FOR_ACTION}>
<Button
className="flex-center"
data-testid={`delete-${record.name}`}
disabled={!hasAccess}
icon={
<SVGIcons
alt="Delete"
className="tw-h-4"
icon={Icons.DELETE}
/>
}
type="text"
onClick={(e) => {
// preventing expand/collapse on click of delete button
e.stopPropagation();
setSelectedTestCase(record);
}}
/>
</Tooltip>
</Row>
);
},

View File

@ -1,6 +1,8 @@
import { Space, Tooltip } from 'antd';
import React from 'react';
import { useAuthContext } from '../../authentication/auth-provider/AuthProvider';
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
import { useAuth } from '../../hooks/authHooks';
import { IcDeleteColored } from '../../utils/SvgUtils';
import { Button } from '../buttons/Button/Button';
import DeleteWidgetModal from '../common/DeleteWidget/DeleteWidgetModal';
@ -20,8 +22,12 @@ const TestSuiteDetails = ({
testSuiteDescription,
descriptionHandler,
handleDescriptionUpdate,
permissions,
}: TestSuiteDetailsProps) => {
const { isAdminUser } = useAuth();
const { isAuthDisabled } = useAuthContext();
const hasAccess = isAdminUser || isAuthDisabled;
return (
<>
<Space
@ -32,11 +38,10 @@ const TestSuiteDetails = ({
data-testid="test-suite-breadcrumb"
titleLinks={slashedBreadCrumb}
/>
<Tooltip
title={permissions.Delete ? 'Delete' : NO_PERMISSION_FOR_ACTION}>
<Tooltip title={hasAccess ? 'Delete' : NO_PERMISSION_FOR_ACTION}>
<Button
data-testid="test-suite-delete"
disabled={!permissions.Delete}
disabled={!hasAccess}
size="small"
theme="primary"
variant="outlined"
@ -66,11 +71,7 @@ const TestSuiteDetails = ({
<span className="tw-flex" key={index}>
<EntitySummaryDetails
data={info}
updateOwner={
permissions.EditAll || permissions.EditOwner
? handleUpdateOwner
: undefined
}
updateOwner={hasAccess ? handleUpdateOwner : undefined}
/>
</span>
))}
@ -81,7 +82,7 @@ const TestSuiteDetails = ({
className="test-suite-description"
description={testSuiteDescription || ''}
entityName={testSuite?.displayName ?? testSuite?.name}
hasEditAccess={permissions.EditDescription || permissions.EditAll}
hasEditAccess={hasAccess}
isEdit={isDescriptionEditable}
onCancel={() => descriptionHandler(false)}
onDescriptionEdit={() => descriptionHandler(true)}