11import { test } from './fixtures.electron.packaged' ;
22import { expect } from '@playwright/test' ;
3- import { waitForLoadingDone } from './helpers/video' ;
4-
5- const LLM_TIMEOUT = 30000 ;
3+ import { expectChatContainsMessage , expectLastChatMessageContains , expectChatMessageCount , expectSessionCount , goToChatHistory , goToHome , openSession , sendMessage } from './helpers/test-steps' ;
64
75test . describe ( 'Goose App' , { tag : '@release' } , ( ) => {
86 test ( 'goose conversation' , async ( { goosePage } ) => {
@@ -11,9 +9,7 @@ test.describe('Goose App', {tag: '@release'}, () => {
119 await expect ( goosePage . getByRole ( 'button' , { name : 'New Chat' } ) . first ( ) ) . toBeVisible ( ) ;
1210 await expect ( goosePage . getByTestId ( 'chat-show-all' ) ) . toHaveCount ( 0 ) ;
1311
14- await goosePage . getByTestId ( 'sidebar-home-button' ) . click ( ) ;
15- const chatInput = goosePage . locator ( '[data-testid="chat-input"]:visible' ) . first ( ) ;
16- await expect ( chatInput ) . toBeVisible ( ) ;
12+ await goToHome ( goosePage ) ;
1713
1814 const costTrigger = goosePage . getByTestId ( 'bottom-menu-cost-trigger' ) . first ( ) ;
1915 const costTooltip = goosePage . getByTestId ( 'bottom-menu-cost-tooltip' ) . first ( ) ;
@@ -23,61 +19,29 @@ test.describe('Goose App', {tag: '@release'}, () => {
2319 'Input: 0 tokens ($0.000000) | Output: 0 tokens ($0.000000)'
2420 ) ;
2521
26- await chatInput . fill ( 'Hello First' ) ;
27- await chatInput . press ( 'Enter' ) ;
28-
29- await waitForLoadingDone ( goosePage , LLM_TIMEOUT ) ;
30- await expect ( goosePage . locator ( '[data-testid="message-container"]:visible' ) . last ( ) ) . toBeVisible ( ) ;
22+ await sendMessage ( goosePage , 'Hello First' ) ;
3123
32- await chatInput . fill ( 'Hello First' ) ;
33- await chatInput . press ( 'Enter' ) ;
34- await waitForLoadingDone ( goosePage , LLM_TIMEOUT ) ;
24+ await sendMessage ( goosePage , 'Hello Second' ) ;
3525
3626 await costTrigger . hover ( ) ;
3727 await expect ( costTrigger ) . not . toContainText ( '0.0000' ) ;
3828 await expect ( costTooltip ) . not . toContainText (
3929 'Input: 0 tokens ($0.000000) | Output: 0 tokens ($0.000000)'
4030 ) ;
4131
42- const showAllAfterChat = goosePage . getByTestId ( 'chat-show-all' ) . first ( ) ;
43- if ( ! ( await showAllAfterChat . isVisible ( ) . catch ( ( ) => false ) ) ) {
44- await goosePage . getByTestId ( 'sidebar-chat-button' ) . click ( ) ;
45- }
46- await expect ( showAllAfterChat ) . toBeVisible ( ) ;
47- await showAllAfterChat . click ( ) ;
48- await expect ( goosePage . getByRole ( 'heading' , { name : 'Chat history' } ) ) . toBeVisible ( ) ;
49- const historyCards = goosePage . getByTestId ( 'session-history-card' ) ;
50- const historyCountAfterFirstConversation = await historyCards . count ( ) ;
51- expect ( historyCountAfterFirstConversation ) . toBeGreaterThanOrEqual ( 1 ) ;
52-
53- await goosePage . getByTestId ( 'sidebar-home-button' ) . click ( ) ;
54- const hubChatInput = goosePage . locator ( '[data-testid="chat-input"]:visible' ) . first ( ) ;
55- await expect ( hubChatInput ) . toBeVisible ( ) ;
56- await expect ( goosePage . locator ( '[data-testid="message-container"]:visible' ) ) . toHaveCount ( 0 ) ;
57-
58- await hubChatInput . fill ( 'Hello from hub' ) ;
59- await hubChatInput . press ( 'Enter' ) ;
60- await waitForLoadingDone ( goosePage , LLM_TIMEOUT ) ;
61- await expect ( goosePage . locator ( '[data-testid="message-container"]:visible' ) ) . toHaveCount ( 2 ) ;
62-
63- const showAllAfterHubConversation = goosePage . getByTestId ( 'chat-show-all' ) . first ( ) ;
64- if ( ! ( await showAllAfterHubConversation . isVisible ( ) . catch ( ( ) => false ) ) ) {
65- await goosePage . getByTestId ( 'sidebar-chat-button' ) . click ( ) ;
66- }
67- await expect ( showAllAfterHubConversation ) . toBeVisible ( ) ;
68- await showAllAfterHubConversation . click ( ) ;
69- await expect ( goosePage . getByRole ( 'heading' , { name : 'Chat history' } ) ) . toBeVisible ( ) ;
70-
71- const originalSessionCard = goosePage . getByTestId ( 'session-history-card' ) . nth ( 1 ) ;
72- await originalSessionCard . click ( ) ;
73- const resumedChatInput = goosePage . locator ( '[data-testid="chat-input"]:visible' ) . first ( ) ;
74- await expect ( resumedChatInput ) . toBeVisible ( ) ;
75- await expect (
76- goosePage
77- . locator ( '[data-testid="message-container"]:visible' )
78- . filter ( { hasText : 'Hello First' } )
79- . first ( )
80- ) . toBeVisible ( ) ;
32+ await goToChatHistory ( goosePage ) ;
33+ await expectSessionCount ( goosePage , 1 ) ;
34+
35+ await goToHome ( goosePage ) ;
36+ await expectChatMessageCount ( goosePage , 0 ) ;
37+
38+ await sendMessage ( goosePage , 'Hello from hub' ) ;
39+ await expectChatMessageCount ( goosePage , 2 ) ;
40+
41+ await goToChatHistory ( goosePage ) ;
42+
43+ await openSession ( goosePage , 2 ) ;
44+ await expectChatContainsMessage ( goosePage , 'Hello Second' ) ;
8145
8246 const workingDirButton = goosePage . locator ( '[data-testid="bottom-menu-dir-switcher"]:visible' ) . first ( ) ;
8347 await expect ( workingDirButton ) . toBeVisible ( ) ;
@@ -89,26 +53,18 @@ test.describe('Goose App', {tag: '@release'}, () => {
8953 const updatedWorkingDir = ( await workingDirButton . textContent ( ) ) ?. trim ( ) ?? '' ;
9054 expect ( updatedWorkingDir . length ) . toBeGreaterThan ( 0 ) ;
9155
92- await resumedChatInput . fill ( 'what is your working directory? reply with exact path only' ) ;
93- await resumedChatInput . press ( 'Enter' ) ;
94- await waitForLoadingDone ( goosePage , LLM_TIMEOUT ) ;
95- await expect ( goosePage . locator ( '[data-testid="message-container"]:visible' ) . last ( ) ) . toContainText (
96- updatedWorkingDir
97- ) ;
56+ await sendMessage ( goosePage , 'what is your working directory? reply with exact path only' ) ;
57+ await expectLastChatMessageContains ( goosePage , updatedWorkingDir ) ;
9858 } ) ;
9959
10060 test ( 'developer tool is called' , async ( { goosePage } ) => {
10161
102- await goosePage . getByTestId ( 'sidebar-home-button' ) . click ( ) ;
103- const chatInput = goosePage . locator ( '[data-testid="chat-input"]:visible' ) . first ( ) ;
104- await expect ( chatInput ) . toBeVisible ( ) ;
62+ await goToHome ( goosePage ) ;
10563
10664 const toolCalls = goosePage . locator ( '.goose-message-tool' ) ;
10765 await expect ( toolCalls ) . toHaveCount ( 0 ) ;
10866
109- await chatInput . fill ( 'show the number of files in current directory' ) ;
110- await chatInput . press ( 'Enter' ) ;
111- await waitForLoadingDone ( goosePage , LLM_TIMEOUT ) ;
67+ await sendMessage ( goosePage , 'show the number of files in current directory' ) ;
11268
11369 await expect ( toolCalls ) . toHaveCount ( 1 ) ;
11470 const newestToolCall = toolCalls . first ( ) ;
@@ -120,17 +76,9 @@ test.describe('Goose App', {tag: '@release'}, () => {
12076 } ) ;
12177
12278 test ( 'verify chat history' , async ( { goosePage } ) => {
123- const chatInput = goosePage . getByTestId ( 'chat-input' ) ;
124- await chatInput . fill ( 'What is 2+2?' ) ;
125- await chatInput . press ( 'Enter' ) ;
126-
127- await waitForLoadingDone ( goosePage , LLM_TIMEOUT ) ;
128-
129- const response = goosePage . getByTestId ( 'message-container' ) . last ( ) ;
130- const responseText = await response . textContent ( ) ;
131- expect ( responseText ) . toBeTruthy ( ) ;
132-
133- await expect ( goosePage . getByTestId ( 'message-container' ) ) . toHaveCount ( 2 ) ;
79+ await expectChatMessageCount ( goosePage , 0 ) ;
80+ await sendMessage ( goosePage , 'What is 2+2?' ) ;
81+ await expectChatMessageCount ( goosePage , 2 ) ;
13482
13583 const chatInputForHistory = goosePage . getByTestId ( 'chat-input' ) ;
13684 await chatInputForHistory . press ( 'Control+ArrowUp' ) ;
0 commit comments