Skip to content

Commit

Permalink
Minor: add column name to test case header (#18938)
Browse files Browse the repository at this point in the history
* fix: add column name to test case header

* test: add test case for column name

* fix: return statement for columnName

* refactor: remove replacePlus function call

---------

Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
  • Loading branch information
pranita09 and ShaileshParmar11 authored Dec 17, 2024
1 parent bd68d95 commit c96c778
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import {
updateTestCaseIncidentById,
} from '../../../../rest/incidentManagerAPI';
import { getNameFromFQN } from '../../../../utils/CommonUtils';
import { getEntityName } from '../../../../utils/EntityUtils';
import {
getColumnNameFromEntityLink,
getEntityName,
} from '../../../../utils/EntityUtils';
import { getEntityFQN } from '../../../../utils/FeedUtils';
import { checkPermission } from '../../../../utils/PermissionsUtils';
import { getDecodedFqn } from '../../../../utils/StringsUtils';
Expand Down Expand Up @@ -76,6 +79,17 @@ const IncidentManagerPageHeader = ({
initialAssignees,
} = useActivityFeedProvider();

const columnName = useMemo(() => {
const isColumn = testCaseData?.entityLink.includes('::columns::');
if (isColumn) {
const name = getColumnNameFromEntityLink(testCaseData?.entityLink ?? '');

return name;
}

return null;
}, [testCaseData]);

const tableFqn = useMemo(
() => getEntityFQN(testCaseData?.entityLink ?? ''),
[testCaseData]
Expand Down Expand Up @@ -327,6 +341,17 @@ const IncidentManagerPageHeader = ({
</Typography.Text>
</>
)}
{columnName && (
<>
<Divider className="self-center m-x-sm" type="vertical" />
<Typography.Text className="self-center text-xs whitespace-nowrap">
<span className="text-grey-muted">{`${t('label.column')}: `}</span>
<span className="font-medium" data-testid="test-column-name">
{columnName}
</span>
</Typography.Text>
</>
)}
<Divider className="self-center m-x-sm" type="vertical" />
<Typography.Text className="self-center text-xs whitespace-nowrap">
<span className="text-grey-muted">{`${t('label.test-type')}: `}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ jest.mock('../../../../utils/CommonUtils', () => ({

jest.mock('../../../../utils/EntityUtils', () => ({
getEntityName: jest.fn().mockReturnValue('getEntityName'),
getColumnNameFromEntityLink: jest
.fn()
.mockReturnValue('getColumnNameFromEntityLink'),
}));

jest.mock('../../../../utils/FeedUtils', () => ({
Expand Down Expand Up @@ -270,5 +273,8 @@ describe('Incident Manager Page Header component', () => {
// Test Type
expect(screen.getByText('label.test-type:')).toBeInTheDocument();
expect(screen.getByText('getEntityName')).toBeInTheDocument();
// If Column is present
expect(screen.getByText('label.column:')).toBeInTheDocument();
expect(screen.getByText('getColumnNameFromEntityLink')).toBeInTheDocument();
});
});

0 comments on commit c96c778

Please sign in to comment.