MINOR: fix the wrong team count displayed on team tab (#19368)

* fix the wrong team count displayed on team tab

* added playwright test for checking counts
This commit is contained in:
Ashish Gupta 2025-01-15 17:47:53 +05:30 committed by GitHub
parent 69342d4783
commit 58f95e9e98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 6 deletions

View File

@ -34,6 +34,7 @@ import { settingClick } from '../../utils/sidebar';
import {
addTeamOwnerToEntity,
addUserInTeam,
checkTeamTabCount,
createTeam,
hardDeleteTeam,
searchTeam,
@ -114,6 +115,8 @@ test.describe('Teams Page', () => {
test('Teams Page Flow', async ({ page }) => {
await test.step('Create a new team', async () => {
await settingClick(page, GlobalSettingOptions.TEAMS);
await checkTeamTabCount(page);
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="add-team"]');

View File

@ -349,3 +349,17 @@ export const addUserInTeam = async (page: Page, user: UserClass) => {
page.locator(`[data-testid="${userName.toLowerCase()}"]`)
).toBeVisible();
};
export const checkTeamTabCount = async (page: Page) => {
const fetchResponse = page.waitForResponse(
'/api/v1/teams/name/*?fields=*childrenCount*include=all'
);
const response = await fetchResponse;
const jsonRes = await response.json();
await expect(
page.locator(
'[data-testid="teams"] [data-testid="count"] [data-testid="filter-count"]'
)
).toContainText(jsonRes.childrenCount.toString());
};

View File

@ -210,11 +210,8 @@ const TeamDetailsV1 = ({
);
const teamCount = useMemo(
() =>
isOrganization && currentTeam && currentTeam.childrenCount
? currentTeam.childrenCount + 1
: childTeamList.length,
[childTeamList, isOrganization, currentTeam.childrenCount]
() => currentTeam.childrenCount ?? childTeamList.length,
[childTeamList, currentTeam.childrenCount]
);
const updateActiveTab = (key: string) => {
history.push({ search: Qs.stringify({ activeTab: key }) });

View File

@ -288,8 +288,8 @@ const TeamsPage = () => {
const res = await createTeam(teamData);
if (res) {
fetchTeamBasicDetails(selectedTeam.name, true);
handleAddTeam(false);
await fetchTeamBasicDetails(selectedTeam.name, true);
loadAdvancedDetails();
}
} catch (error) {