Skip to content

Commit 0332118

Browse files
eunjae-leedevin-ai-integration[bot]sean-brydon
authored
feat: add e2e tests for insights charts (calcom#23777)
* 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>
1 parent 34b62f7 commit 0332118

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

apps/web/playwright/insights.e2e.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,39 @@ test.describe("Insights", async () => {
237237
// Wait for the download process to complete and save the downloaded file somewhere.
238238
await download.saveAs("./" + "test-insights.csv");
239239
});
240+
241+
test("should render all ChartCard components with expected titles", async ({ page, users }) => {
242+
const owner = await users.create();
243+
const member = await users.create();
244+
245+
await createTeamsAndMembership(owner.id, member.id);
246+
247+
await owner.apiLogin();
248+
249+
await page.goto("/insights");
250+
251+
const expectedChartTitles = [
252+
"Events",
253+
"Performance",
254+
"Event Trends",
255+
"Bookings by Hour",
256+
"Average Event Duration",
257+
"Most Bookings Scheduled",
258+
"Least Bookings Scheduled",
259+
"Most Bookings Completed",
260+
"Least Bookings Completed",
261+
"Most Cancelled",
262+
"Most No-Show",
263+
"Recent No-Show Guests",
264+
"Highest Rated",
265+
"Lowest Rated",
266+
"Recent Ratings",
267+
"Popular Events",
268+
];
269+
270+
for (const title of expectedChartTitles) {
271+
const chartCard = page.locator("[data-testid='panel-card'] h2").filter({ hasText: title });
272+
await expect(chartCard).toBeVisible();
273+
}
274+
});
240275
});

packages/features/insights/components/booking/HighestRatedMembersTable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ export const HighestRatedMembersTable = () => {
2727

2828
if (!isSuccess || !data) return null;
2929

30-
return data && data.length > 0 ? (
30+
return (
3131
<ChartCard title={t("highest_rated")}>
3232
<UserStatsTable data={data} />
3333
</ChartCard>
34-
) : (
35-
<></>
3634
);
3735
};

packages/features/insights/components/booking/LowestRatedMembersTable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ export const LowestRatedMembersTable = () => {
2727

2828
if (!isSuccess || !data) return null;
2929

30-
return data && data.length > 0 ? (
30+
return (
3131
<ChartCard title={t("lowest_rated")}>
3232
<UserStatsTable data={data} />
3333
</ChartCard>
34-
) : (
35-
<></>
3634
);
3735
};

packages/ui/components/card/PanelCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function PanelCard({
4545

4646
return (
4747
<div
48+
data-testid="panel-card"
4849
ref={animationParent}
4950
className={classNames(
5051
"bg-muted group relative flex w-full flex-col items-center rounded-2xl px-1",

0 commit comments

Comments
 (0)