Skip to content

Commit a255a14

Browse files
committed
Fixes tests
1 parent dd4b2a9 commit a255a14

File tree

5 files changed

+32
-97
lines changed

5 files changed

+32
-97
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18131813
<RooHero />
18141814

18151815
{/* New users should see tips */}
1816-
{taskHistory.length < 400000 && <RooTips />}
1816+
{taskHistory.length < 4 && <RooTips />}
18171817

18181818
{/* Everyone should see their task history if any */}
18191819
{taskHistory.length > 0 && <HistoryPreview />}

webview-ui/src/components/chat/__tests__/ChatView.spec.tsx

Lines changed: 30 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ vi.mock("../AutoApproveMenu", () => ({
6161
default: () => null,
6262
}))
6363

64+
// Mock CloudAgents component
65+
vi.mock("../../cloud/CloudAgents", () => ({
66+
default: function MockCloudAgents() {
67+
return <div data-testid="cloud-agents">Cloud Agents</div>
68+
},
69+
}))
70+
6471
// Mock VersionIndicator - returns null by default to prevent rendering in tests
6572
vi.mock("../../common/VersionIndicator", () => ({
6673
default: vi.fn(() => null),
@@ -1268,10 +1275,10 @@ describe("ChatView - Version Indicator Tests", () => {
12681275
})
12691276
})
12701277

1271-
describe("ChatView - DismissibleUpsell Display Tests", () => {
1278+
describe("ChatView - DismissibleUpsell and RooTips Display Tests", () => {
12721279
beforeEach(() => vi.clearAllMocks())
12731280

1274-
it("does not show DismissibleUpsell when user is authenticated to Cloud", () => {
1281+
it("does not show DismissibleUpsell when user is authenticated to Cloud", async () => {
12751282
const { queryByTestId } = renderChatView()
12761283

12771284
// Hydrate state with user authenticated to cloud
@@ -1286,29 +1293,16 @@ describe("ChatView - DismissibleUpsell Display Tests", () => {
12861293
clineMessages: [], // No active task
12871294
})
12881295

1289-
// Should not show DismissibleUpsell when authenticated
1290-
expect(queryByTestId("dismissible-upsell")).not.toBeInTheDocument()
1291-
})
1292-
1293-
it("does not show DismissibleUpsell when user has only run 3 tasks in their history", () => {
1294-
const { queryByTestId } = renderChatView()
1295-
1296-
// Hydrate state with user not authenticated but only 3 tasks
1297-
mockPostMessage({
1298-
cloudIsAuthenticated: false,
1299-
taskHistory: [
1300-
{ id: "1", ts: Date.now() - 2000 },
1301-
{ id: "2", ts: Date.now() - 1000 },
1302-
{ id: "3", ts: Date.now() },
1303-
],
1304-
clineMessages: [], // No active task
1296+
// Wait for the state to be updated and component to re-render
1297+
await waitFor(() => {
1298+
// CloudAgents should be shown instead of DismissibleUpsell when authenticated
1299+
expect(queryByTestId("cloud-agents")).toBeInTheDocument()
1300+
// Should not show DismissibleUpsell when authenticated
1301+
expect(queryByTestId("dismissible-upsell")).not.toBeInTheDocument()
13051302
})
1306-
1307-
// Should not show DismissibleUpsell with less than 4 tasks
1308-
expect(queryByTestId("dismissible-upsell")).not.toBeInTheDocument()
13091303
})
13101304

1311-
it("shows DismissibleUpsell when user is not authenticated and has run 4 or more tasks", async () => {
1305+
it("shows DismissibleUpsell when user is not authenticated", async () => {
13121306
const { getByTestId } = renderChatView()
13131307

13141308
// Hydrate state with user not authenticated and 4 tasks
@@ -1329,29 +1323,7 @@ describe("ChatView - DismissibleUpsell Display Tests", () => {
13291323
})
13301324
})
13311325

1332-
it("shows DismissibleUpsell when user is not authenticated and has run 5 tasks", async () => {
1333-
const { getByTestId } = renderChatView()
1334-
1335-
// Hydrate state with user not authenticated and 5 tasks
1336-
mockPostMessage({
1337-
cloudIsAuthenticated: false,
1338-
taskHistory: [
1339-
{ id: "1", ts: Date.now() - 4000 },
1340-
{ id: "2", ts: Date.now() - 3000 },
1341-
{ id: "3", ts: Date.now() - 2000 },
1342-
{ id: "4", ts: Date.now() - 1000 },
1343-
{ id: "5", ts: Date.now() },
1344-
],
1345-
clineMessages: [], // No active task
1346-
})
1347-
1348-
// Wait for component to render and show DismissibleUpsell
1349-
await waitFor(() => {
1350-
expect(getByTestId("dismissible-upsell")).toBeInTheDocument()
1351-
})
1352-
})
1353-
1354-
it("does not show DismissibleUpsell when there is an active task (regardless of auth status)", async () => {
1326+
it("does not show any home screen elements when there is an active task (regardless of auth status)", async () => {
13551327
const { queryByTestId } = renderChatView()
13561328

13571329
// Hydrate state with active task
@@ -1384,14 +1356,13 @@ describe("ChatView - DismissibleUpsell Display Tests", () => {
13841356
})
13851357
})
13861358

1387-
it("shows RooTips when user is authenticated (instead of DismissibleUpsell)", () => {
1388-
const { queryByTestId, getByTestId } = renderChatView()
1359+
it("shows RooTips when the user has less than 4 tasks", () => {
1360+
const { queryByTestId } = renderChatView()
13891361

13901362
// Hydrate state with user authenticated to cloud
13911363
mockPostMessage({
13921364
cloudIsAuthenticated: true,
13931365
taskHistory: [
1394-
{ id: "1", ts: Date.now() - 3000 },
13951366
{ id: "2", ts: Date.now() - 2000 },
13961367
{ id: "3", ts: Date.now() - 1000 },
13971368
{ id: "4", ts: Date.now() },
@@ -1400,27 +1371,27 @@ describe("ChatView - DismissibleUpsell Display Tests", () => {
14001371
})
14011372

14021373
// Should not show DismissibleUpsell but should show RooTips
1403-
expect(queryByTestId("dismissible-upsell")).not.toBeInTheDocument()
1404-
expect(getByTestId("roo-tips")).toBeInTheDocument()
1374+
expect(queryByTestId("roo-tips")).toBeInTheDocument()
14051375
})
14061376

1407-
it("shows RooTips when user has fewer than 4 tasks (instead of DismissibleUpsell)", () => {
1408-
const { queryByTestId, getByTestId } = renderChatView()
1377+
it("does not show RooTips when the user has more than 4 tasks", () => {
1378+
const { queryByTestId } = renderChatView()
14091379

1410-
// Hydrate state with user not authenticated but fewer than 4 tasks
1380+
// Hydrate state with user authenticated to cloud
14111381
mockPostMessage({
1412-
cloudIsAuthenticated: false,
1382+
cloudIsAuthenticated: true,
14131383
taskHistory: [
1414-
{ id: "1", ts: Date.now() - 2000 },
1415-
{ id: "2", ts: Date.now() - 1000 },
1416-
{ id: "3", ts: Date.now() },
1384+
{ id: "0", ts: Date.now() - 4000 },
1385+
{ id: "1", ts: Date.now() - 3000 },
1386+
{ id: "2", ts: Date.now() - 2000 },
1387+
{ id: "3", ts: Date.now() - 1000 },
1388+
{ id: "4", ts: Date.now() },
14171389
],
14181390
clineMessages: [], // No active task
14191391
})
14201392

14211393
// Should not show DismissibleUpsell but should show RooTips
1422-
expect(queryByTestId("dismissible-upsell")).not.toBeInTheDocument()
1423-
expect(getByTestId("roo-tips")).toBeInTheDocument()
1394+
expect(queryByTestId("roo-tips")).toBeInTheDocument()
14241395
})
14251396
})
14261397

webview-ui/src/components/cloud/__tests__/CloudAgents.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe("CloudAgents", () => {
142142
})
143143

144144
await waitFor(() => {
145-
expect(screen.getByText(/Code away from your IDE/)).toBeInTheDocument()
145+
expect(screen.getByText(/any Cloud Agents yet/)).toBeInTheDocument()
146146
})
147147

148148
// Find and click the "Create your first" button in the empty state

webview-ui/src/components/history/__tests__/HistoryPreview.spec.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ describe("HistoryPreview", () => {
9797
setShowAllWorkspaces: vi.fn(),
9898
})
9999

100-
const { container } = render(<HistoryPreview />)
101-
102100
// Should render the container but no task items
103-
expect(container.firstChild).toHaveClass("flex", "flex-col", "gap-3")
104101
expect(screen.queryByTestId(/task-item-/)).not.toBeInTheDocument()
105102
})
106103

@@ -210,22 +207,4 @@ describe("HistoryPreview", () => {
210207
expect.anything(),
211208
)
212209
})
213-
214-
it("renders with correct container classes", () => {
215-
mockUseTaskSearch.mockReturnValue({
216-
tasks: mockTasks.slice(0, 1),
217-
searchQuery: "",
218-
setSearchQuery: vi.fn(),
219-
sortOption: "newest",
220-
setSortOption: vi.fn(),
221-
lastNonRelevantSort: null,
222-
setLastNonRelevantSort: vi.fn(),
223-
showAllWorkspaces: false,
224-
setShowAllWorkspaces: vi.fn(),
225-
})
226-
227-
const { container } = render(<HistoryPreview />)
228-
229-
expect(container.firstChild).toHaveClass("flex", "flex-col", "gap-3")
230-
})
231210
})

webview-ui/src/components/history/__tests__/TaskItem.spec.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,4 @@ describe("TaskItem", () => {
9494
// Should display time ago format
9595
expect(screen.getByText(/ago/)).toBeInTheDocument()
9696
})
97-
98-
it("applies hover effect class", () => {
99-
render(
100-
<TaskItem
101-
item={mockTask}
102-
variant="full"
103-
isSelected={false}
104-
onToggleSelection={vi.fn()}
105-
isSelectionMode={false}
106-
/>,
107-
)
108-
109-
const taskItem = screen.getByTestId("task-item-1")
110-
expect(taskItem).toHaveClass("hover:bg-vscode-list-hoverBackground")
111-
})
11297
})

0 commit comments

Comments
 (0)