* feat: add e2e tests for insights ChartCard components - Test that all ChartCard components render with expected titles - Test graceful handling of TRPC call failures - Test ChartCard rendering for organization users - Wait for page load and TRPC calls before checking chart presence - Use text-based selectors to find ChartCard titles in h2 elements - Remove page.waitForTimeout() calls to comply with ESLint rules Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * clean up e2e tests * fix titles * still render charts if no data --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
36 lines
952 B
TypeScript
36 lines
952 B
TypeScript
"use client";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc";
|
|
|
|
import { useInsightsBookingParameters } from "../../hooks/useInsightsBookingParameters";
|
|
import { ChartCard } from "../ChartCard";
|
|
import { LoadingInsight } from "../LoadingInsights";
|
|
import { UserStatsTable } from "../UserStatsTable";
|
|
|
|
export const LowestRatedMembersTable = () => {
|
|
const { t } = useLocale();
|
|
const insightsBookingParams = useInsightsBookingParameters();
|
|
|
|
const { data, isSuccess, isPending } = trpc.viewer.insights.membersWithLowestRatings.useQuery(
|
|
insightsBookingParams,
|
|
{
|
|
staleTime: 180000,
|
|
refetchOnWindowFocus: false,
|
|
trpc: {
|
|
context: { skipBatch: true },
|
|
},
|
|
}
|
|
);
|
|
|
|
if (isPending) return <LoadingInsight />;
|
|
|
|
if (!isSuccess || !data) return null;
|
|
|
|
return (
|
|
<ChartCard title={t("lowest_rated")}>
|
|
<UserStatsTable data={data} />
|
|
</ChartCard>
|
|
);
|
|
};
|