@@ -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
6572vi . 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
0 commit comments