Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions packages/ui/src/features/loops/components/LoopsListView.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { LoopSchemas } from "@posthog/api-client/loops";
import type { UserBasic } from "@posthog/shared/domain-types";
import { Theme } from "@radix-ui/themes";
import { render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
Expand All @@ -12,7 +13,18 @@ vi.mock("./LoopTemplatesSection", () => ({
LoopTemplatesSection: () => null,
}));
vi.mock("./LoopRow", () => ({
LoopRow: ({ loop }: { loop: LoopSchemas.Loop }) => <div>{loop.name}</div>,
LoopRow: ({
loop,
creator,
}: {
loop: LoopSchemas.Loop;
creator?: UserBasic;
}) => (
<div>
{loop.name}
{loop.visibility === "team" && creator ? ` by ${creator.email}` : null}
</div>
),
}));

function loop(
Expand Down Expand Up @@ -53,6 +65,11 @@ describe("LoopsListViewPresentation", () => {
});

it("groups loops by ownership rather than visibility", async () => {
const currentUser: UserBasic = {
id: 1,
uuid: "current-user",
email: "current@example.com",
};
render(
<Theme>
<LoopsListViewPresentation
Expand All @@ -62,6 +79,7 @@ describe("LoopsListViewPresentation", () => {
loop("teammate-team", "team", 2),
]}
currentUserId={1}
members={[currentUser]}
onStartBlank={vi.fn()}
onStartFromTemplate={vi.fn()}
/>
Expand All @@ -73,7 +91,9 @@ describe("LoopsListViewPresentation", () => {
within(controlledPanel(personalTab)).getByText("personal loop"),
).toBeVisible();
expect(
within(controlledPanel(personalTab)).getByText("team loop"),
within(controlledPanel(personalTab)).getByText(
"team loop by current@example.com",
),
).toBeVisible();

const teamTab = screen.getByRole("tab", { name: "Team loops (1)" });
Expand Down
8 changes: 7 additions & 1 deletion packages/ui/src/features/loops/components/LoopsListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ function LoopListTabs({
</TabsList>
<TabsContent value="personal">
{personalLoops.length > 0 ? (
<LoopListSection loops={personalLoops} />
<LoopListSection
loops={personalLoops}
members={members}
membersLoading={membersLoading}
membersError={membersError}
membersComplete={membersComplete}
/>
) : (
<LoopsEmptyState />
)}
Expand Down
Loading