@@ -53,6 +91,6 @@ export default function InsightsPage() {
-
+ >
);
}
diff --git a/apps/web/playwright/insights.e2e.ts b/apps/web/playwright/insights.e2e.ts
index dbdd3b694d..ac51e31c53 100644
--- a/apps/web/playwright/insights.e2e.ts
+++ b/apps/web/playwright/insights.e2e.ts
@@ -75,10 +75,8 @@ test.describe("Insights", async () => {
// go to insights page
await page.goto("/insights");
- await page.waitForURL(/.*\/insights\?teamId=[^&]*&isAll=false.*/);
- // expect url to have isAll and TeamId in query params
- await expect(page).toHaveURL(/.*\/insights\?teamId=[^&]*&isAll=false.*/);
+ await page.locator('[data-testid^="insights-filters-false-"]').waitFor();
});
test("should be able to go to insights as members", async ({ page, users }) => {
@@ -91,10 +89,7 @@ test.describe("Insights", async () => {
// go to insights page
await page.goto("/insights");
- await page.waitForURL(/.*\/insights\?userId=[^&]*&isAll=false.*/);
-
- // expect url to have isAll and TeamId in query params
- await expect(page).toHaveURL(/.*\/insights\?userId=[^&]*&isAll=false.*/);
+ await page.locator('[data-testid^="insights-filters-false-"]').waitFor();
});
test("team select filter should have 2 teams and your account option only as member", async ({
@@ -107,19 +102,22 @@ test.describe("Insights", async () => {
await user.apiLogin();
await createTeamsAndMembership(user.id, userTwo.id);
+
// go to insights page
await page.goto("/insights");
+ await page.locator(`[data-testid=insights-filters-false-undefined-${user.id}]`).waitFor();
- // get div from team select filter with this class flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1
- await page.getByTestId("dashboard-shell").getByText("Team: test-insights").click();
- await page
- .locator('div[class="flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1"]')
- .click();
- const teamSelectFilter = await page.locator(
- 'div[class="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 transition hover:cursor-pointer"]'
+ await page.getByTestId("dashboard-shell").getByText("Your account").click();
+
+ await expect(await page.locator('[data-testid="org-teams-filter-item"]')).toHaveCount(3);
+
+ await expect(await page.locator('[data-testid="org-teams-filter-item"]', { hasText: "All" })).toHaveCount(
+ 0
);
- await expect(teamSelectFilter).toHaveCount(3);
+ await expect(
+ await page.locator('[data-testid="org-teams-filter-item"]', { hasText: "Your account" })
+ ).toHaveCount(1);
});
test("Insights Organization should have isAll option true", async ({ users, page }) => {
@@ -132,17 +130,20 @@ test.describe("Insights", async () => {
await owner.apiLogin();
await page.goto("/insights");
+ await page.locator('[data-testid^="insights-filters-true-"]').waitFor();
- await page.getByTestId("dashboard-shell").getByText("All").nth(1).click();
+ await page.locator('[data-testid^="insights-filters-true-"]').getByText("All").click();
- const teamSelectFilter = await page.locator(
- 'div[class="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 transition hover:cursor-pointer"]'
- );
+ await expect(await page.locator('[data-testid="org-teams-filter-item"]')).toHaveCount(3);
- await expect(teamSelectFilter).toHaveCount(4);
+ await expect(
+ await page
+ .locator('[data-testid="org-teams-filter-item"]', { hasText: "All" })
+ .locator('input[type="checkbox"]')
+ ).toBeChecked();
});
- test("should have all option in team-and-self filter as admin", async ({ page, users }) => {
+ test("should not have all option as admin in non-org", async ({ page, users }) => {
const owner = await users.create();
const member = await users.create();
@@ -152,16 +153,13 @@ test.describe("Insights", async () => {
await page.goto("/insights");
- // get div from team select filter with this class flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1
- await page.getByTestId("dashboard-shell").getByText("Team: test-insights").click();
- await page
- .locator('div[class="flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1"]')
- .click();
- const teamSelectFilter = await page.locator(
- 'div[class="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 transition hover:cursor-pointer"]'
- );
+ await page.getByTestId("dashboard-shell").getByText("Your account").click();
- await expect(teamSelectFilter).toHaveCount(3);
+ await expect(await page.locator('[data-testid="org-teams-filter-item"]')).toHaveCount(3);
+
+ await expect(await page.locator('[data-testid="org-teams-filter-item"]', { hasText: "All" })).toHaveCount(
+ 0
+ );
});
test("should be able to switch between teams and self profile for insights", async ({ page, users }) => {
@@ -174,25 +172,18 @@ test.describe("Insights", async () => {
await page.goto("/insights");
- // get div from team select filter with this class flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1
- await page.getByTestId("dashboard-shell").getByText("Team: test-insights").click();
- await page
- .locator('div[class="flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1"]')
- .click();
- const teamSelectFilter = await page.locator(
- 'div[class="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 transition hover:cursor-pointer"]'
- );
+ await page.getByTestId("dashboard-shell").getByText("Your account").click();
- await expect(teamSelectFilter).toHaveCount(3);
+ await expect(await page.locator('[data-testid="org-teams-filter-item"]')).toHaveCount(3);
// switch to self profile
- await page.getByTestId("dashboard-shell").getByText("Your Account").click();
+ await page.locator('[data-testid="org-teams-filter-item"]', { hasText: "Your account" }).click();
// switch to team 1
- await page.getByTestId("dashboard-shell").getByText("test-insights").nth(0).click();
+ await page.locator('[data-testid="org-teams-filter-item"]', { hasText: "test-insights" }).first().click();
// switch to team 2
- await page.getByTestId("dashboard-shell").getByText("test-insights-2").click();
+ await page.locator('[data-testid="org-teams-filter-item"]', { hasText: "test-insights-2" }).click();
});
test("should be able to switch between memberUsers", async ({ page, users }) => {
@@ -205,36 +196,39 @@ test.describe("Insights", async () => {
await page.goto("/insights");
- await page.getByText("Add filter").click();
+ // Choose a team
+ await page.getByTestId("dashboard-shell").getByText("Your account").click();
+ await page.locator('[data-testid="org-teams-filter-item"]').nth(1).click();
+ await page.keyboard.press("Escape");
- await page.getByRole("button", { name: "User" }).click();
- //
People
- // await page.locator('div[class="flex select-none truncate font-medium"]').getByText("People").click();
- await page.waitForSelector('[data-testid="people-filter-button"]');
- await page.click('[data-testid="people-filter-button"]');
+ // Choose User filter item from dropdown
+ await page.getByTestId("add-filter-button").click();
+ await page.getByTestId("add-filter-item-bookingUserId").click();
+
+ // Wait for the URL to include bookingUserId
+ await page.waitForURL((url) => url.toString().includes("bookingUserId"));
+
+ // Click User filter to see a user list
+ await page.getByTestId("filter-popover-trigger-bookingUserId").click();
await page
- // .locator(
- // 'div[class="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 transition hover:cursor-pointer"]'
- // )
- .locator('[data-testid="people-filter-group-option-0"]')
- // .nth(0)
+ .locator('[data-testid="single-select-options-bookingUserId"]')
+ .getByRole("option")
+ .nth(0)
.click();
await page
- // .locator(
- // 'div[class="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 transition hover:cursor-pointer"]'
- // )
- .locator('[data-testid="people-filter-group-option-1"]')
- // .nth(1)
+ .locator('[data-testid="single-select-options-bookingUserId"]')
+ .getByRole("option")
+ .nth(1)
.click();
+
// press escape button to close the filter
await page.keyboard.press("Escape");
- await page.getByRole("button", { name: "Clear" }).click();
+ await page.getByTestId("clear-filters-button").click();
- // expect for "Team: test-insight" text in page
- await expect(page.locator("text=Team: test-insights")).toBeVisible();
+ await expect(page.url()).not.toContain("bookingUserId");
});
test("should test download button", async ({ page, users }) => {
diff --git a/packages/features/data-table/components/filters/AddFilterButton.tsx b/packages/features/data-table/components/filters/AddFilterButton.tsx
index 4caf473842..393a78ff99 100644
--- a/packages/features/data-table/components/filters/AddFilterButton.tsx
+++ b/packages/features/data-table/components/filters/AddFilterButton.tsx
@@ -63,7 +63,8 @@ function AddFilterButtonComponent
(
handleAddFilter(column.id)}
- className="px-4 py-2">
+ className="px-4 py-2"
+ data-testid={`add-filter-item-${column.id}`}>
{startCase(column.title)}
);
diff --git a/packages/features/data-table/components/filters/ClearFiltersButton.tsx b/packages/features/data-table/components/filters/ClearFiltersButton.tsx
index 341f3a632c..000118c0e6 100644
--- a/packages/features/data-table/components/filters/ClearFiltersButton.tsx
+++ b/packages/features/data-table/components/filters/ClearFiltersButton.tsx
@@ -13,6 +13,7 @@ export const ClearFiltersButton = ({ exclude }: { exclude?: string[] }) => {
return (