mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-08 13:36:32 +00:00
* fix the asset count and placehoder issue in teams page * fix sonar issue * fix around promise mock
This commit is contained in:
parent
19c43273dc
commit
6d89bfd865
@ -748,7 +748,7 @@ const TeamDetailsV1 = ({
|
||||
heading: t('label.role'),
|
||||
doc: ROLE_DOCS,
|
||||
children: t('message.assigning-team-entity-description', {
|
||||
entity: t('label.role'),
|
||||
entity: t('label.role-lowercase'),
|
||||
name: currentTeam.name,
|
||||
}),
|
||||
type: ERROR_PLACEHOLDER_TYPE.ASSIGN,
|
||||
@ -819,7 +819,7 @@ const TeamDetailsV1 = ({
|
||||
fetchErrorPlaceHolder({
|
||||
permission: entityPermissions.EditAll,
|
||||
children: t('message.assigning-team-entity-description', {
|
||||
entity: t('label.policy-plural'),
|
||||
entity: t('label.policy-lowercase-plural'),
|
||||
name: currentTeam.name,
|
||||
}),
|
||||
type: ERROR_PLACEHOLDER_TYPE.ASSIGN,
|
||||
|
||||
@ -1345,7 +1345,7 @@
|
||||
"are-you-want-to-restore": "Are you sure you want to restore {{entity}}?",
|
||||
"assess-data-reliability-with-data-profiler-lineage": "Gain a competitive edge in the data-driven world with the right approach to data governance. Secure your data and empower your business to fuel innovation and growth.",
|
||||
"assigned-you-a-new-task-lowercase": "a new task has been assigned to you",
|
||||
"assigning-team-entity-description": "Add a {{entity}} to {{name}}. This {{entity}} will be inherited by all the Users in the Team {{name}} as well as all the Teams under {{name}}",
|
||||
"assigning-team-entity-description": "Add a {{entity}} to {{name}}. This {{entity}} will be inherited by all the users in the team {{name}} as well as all the teams under {{name}}",
|
||||
"at-least-one-policy": "Enter at least one policy",
|
||||
"auth-configuration-missing": "Auth configuration is missing",
|
||||
"authProvider-is-not-basic": "AuthProvider is not Basic",
|
||||
|
||||
@ -1345,7 +1345,7 @@
|
||||
"are-you-want-to-restore": "本当に{{entity}}をリストアしてよろしいですか?",
|
||||
"assess-data-reliability-with-data-profiler-lineage": "Assess data reliability with data profiler, lineage, sample data, and more.",
|
||||
"assigned-you-a-new-task-lowercase": "新しいタスクがアサインされました",
|
||||
"assigning-team-entity-description": "Add a {{entity}} to {{name}}. This {{entity}} will be inherited by all the Users in the Team {{name}} as well as all the Teams under {{name}}",
|
||||
"assigning-team-entity-description": "Add a {{entity}} to {{name}}. This {{entity}} will be inherited by all the users in the team {{name}} as well as all the teams under {{name}}",
|
||||
"at-least-one-policy": "Enter at least one policy",
|
||||
"auth-configuration-missing": "Auth configuration is missing",
|
||||
"authProvider-is-not-basic": "AuthProvider is not Basic",
|
||||
|
||||
@ -16,8 +16,10 @@ import { act, render, screen } from '@testing-library/react';
|
||||
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
|
||||
import { ResourceEntity } from '../../context/PermissionProvider/PermissionProvider.interface';
|
||||
import { ERROR_PLACEHOLDER_TYPE } from '../../enums/common.enum';
|
||||
import { TeamType } from '../../generated/entity/teams/team';
|
||||
import { mockUserData } from '../../mocks/MyDataPage.mock';
|
||||
import { MOCK_CURRENT_TEAM } from '../../mocks/Teams.mock';
|
||||
import { searchData } from '../../rest/miscAPI';
|
||||
import { getTeamByName } from '../../rest/teamsAPI';
|
||||
import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
|
||||
import TeamsPage from './TeamsPage';
|
||||
@ -92,11 +94,7 @@ jest.mock('../../rest/teamsAPI', () => ({
|
||||
}));
|
||||
|
||||
jest.mock('../../rest/miscAPI', () => ({
|
||||
searchData: jest
|
||||
.fn()
|
||||
.mockResolvedValue(() =>
|
||||
Promise.resolve({ data: [], paging: { total: 5 } })
|
||||
),
|
||||
searchData: jest.fn().mockResolvedValue({ data: [], paging: { total: 0 } }),
|
||||
}));
|
||||
|
||||
jest.mock('../../hooks/useFqn', () => ({
|
||||
@ -199,5 +197,53 @@ describe('Test Teams Page', () => {
|
||||
});
|
||||
|
||||
expect(screen.getByText('No_Data_Error_Placeholder')).toBeInTheDocument();
|
||||
|
||||
(getTeamByName as jest.Mock).mockReset();
|
||||
});
|
||||
|
||||
it('should fetchAssetCount on page load', async () => {
|
||||
(usePermissionProvider as jest.Mock).mockImplementationOnce(() => ({
|
||||
getEntityPermissionByFqn: jest.fn().mockImplementationOnce(() => ({
|
||||
ViewBasic: true,
|
||||
})),
|
||||
}));
|
||||
|
||||
(getTeamByName as jest.Mock).mockImplementation(() =>
|
||||
Promise.resolve({ ...MOCK_CURRENT_TEAM, teamType: TeamType.Group })
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
render(<TeamsPage />);
|
||||
});
|
||||
|
||||
expect(searchData).toHaveBeenCalledWith(
|
||||
'',
|
||||
0,
|
||||
0,
|
||||
'owner.id:f9578f16-363a-4788-80fb-d05816c9e169',
|
||||
'',
|
||||
'',
|
||||
'all'
|
||||
);
|
||||
});
|
||||
|
||||
it('should not fetchAssetCount on page load if TeamType is not Group', async () => {
|
||||
(usePermissionProvider as jest.Mock).mockImplementationOnce(() => ({
|
||||
getEntityPermissionByFqn: jest.fn().mockImplementationOnce(() => ({
|
||||
ViewBasic: true,
|
||||
})),
|
||||
}));
|
||||
|
||||
(getTeamByName as jest.Mock).mockImplementation(() =>
|
||||
Promise.resolve({ ...MOCK_CURRENT_TEAM, teamType: TeamType.BusinessUnit })
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
render(<TeamsPage />);
|
||||
});
|
||||
|
||||
expect(searchData).not.toHaveBeenCalled();
|
||||
|
||||
(getTeamByName as jest.Mock).mockReset();
|
||||
});
|
||||
});
|
||||
|
||||
@ -80,11 +80,6 @@ const TeamsPage = () => {
|
||||
const [isFetchAllTeamAdvancedDetails, setFetchAllTeamAdvancedDetails] =
|
||||
useState<boolean>(false);
|
||||
|
||||
const isGroupType = useMemo(
|
||||
() => selectedTeam.teamType === TeamType.Group,
|
||||
[selectedTeam]
|
||||
);
|
||||
|
||||
const hasViewPermission = useMemo(
|
||||
() => entityPermissions.ViewAll || entityPermissions.ViewBasic,
|
||||
[entityPermissions]
|
||||
@ -193,8 +188,8 @@ const TeamsPage = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const fetchAssets = async () => {
|
||||
if (selectedTeam.id && isGroupType) {
|
||||
const fetchAssets = async (selectedTeam: Team) => {
|
||||
if (selectedTeam.id && selectedTeam.teamType === TeamType.Group) {
|
||||
try {
|
||||
const res = await searchData(
|
||||
``,
|
||||
@ -241,7 +236,7 @@ const TeamsPage = () => {
|
||||
});
|
||||
|
||||
setSelectedTeam((prev) => ({ ...prev, ...data }));
|
||||
fetchAssets();
|
||||
fetchAssets(data);
|
||||
} catch (error) {
|
||||
showErrorToast(error as AxiosError, t('server.unexpected-response'));
|
||||
} finally {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user