@@ -86,10 +86,6 @@ describe('Chat', () => {
8686 } )
8787
8888 it ( 'should navigate to knowledge base and test saved chat' , ( ) => {
89- // Click on Knowledge Base navigation
90- cy . get ( '.from-emerald-500' ) . click ( )
91- cy . url ( ) . should ( 'include' , '/knowledge' )
92-
9389 // Poll the backend API to wait for document processing to complete
9490 // This is more reliable than fixed waits, especially in CI environments
9591 const pollForDocuments = ( retriesLeft = 20 , delayMs = 3000 ) => {
@@ -113,27 +109,30 @@ describe('Chat', () => {
113109 } )
114110 }
115111
116- // Wait for documents to be processed
112+ // Wait for documents to be processed in backend
117113 pollForDocuments ( )
118114
119- // Now verify UI shows the documents
120- cy . get ( '.rounded-xl > .w-80 > .overflow-y-auto' , { timeout : 10000 } ) . should ( 'exist' )
121- cy . get ( '.overflow-y-auto > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist ')
115+ // Navigate to knowledge base (after polling to ensure data is ready)
116+ cy . get ( '.from-emerald-500' ) . click ( )
117+ cy . url ( ) . should ( 'include' , '/knowledge ')
122118
123- // Verify the chat title "Chat: New Chat" appears in the knowledge base
124- cy . get ( '.overflow-y-auto > :nth-child(1) > .items-start > .flex-1 > .font-medium' , { timeout : 10000 } )
125- . should ( 'exist' )
126- . should ( 'contain' , 'Chat: New Chat' )
119+ // Wait for the page to load documents from API (onMount fetch)
120+ cy . wait ( 3000 )
127121
128- // Click on the knowledge base item
129- cy . get ( '.overflow-y-auto > :nth-child(1) > .items-start' ) . click ( )
122+ // Now verify UI shows the documents
123+ cy . get ( '.grid > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' )
130124
131- // Wait for the item to load
125+ // Click on the first document card
126+ cy . get ( '.grid > :nth-child(1)' ) . click ( )
127+
128+ // Wait for document detail page to load
132129 cy . wait ( 2000 )
133130
134- // Verify the chat content appears correctly
135- cy . get ( '.markdown-content > :nth-child(1)' , { timeout : 10000 } ) . should ( 'contain' , 'Hi' )
136- cy . get ( '.markdown-content > :nth-child(2)' ) . should ( 'exist' ) . and ( 'not.be.empty' )
131+ // Verify we're on a document detail page
132+ cy . url ( ) . should ( 'match' , / \/ k n o w l e d g e \/ [ a - f 0 - 9 - ] + / )
133+
134+ // Verify the document content appears correctly
135+ cy . get ( 'body' , { timeout : 10000 } ) . should ( 'contain' , 'Hi' )
137136 } )
138137
139138 it ( 'should create tag and add to chat' , ( ) => {
@@ -188,14 +187,15 @@ describe('Chat', () => {
188187
189188 // Poll for documents to ensure they're loaded
190189 cy . request ( 'http://localhost:8000/api/documents' ) . its ( 'body.documents' ) . should ( 'have.length.at.least' , 1 )
191- cy . wait ( 2000 )
190+ cy . wait ( 3000 )
192191
193192 // Wait for documents to load and click on the saved chat again
194- cy . get ( '.overflow-y-auto' , { timeout : 10000 } ) . should ( 'exist' )
195- cy . get ( '.overflow-y-auto > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' )
196- cy . get ( '.overflow-y-auto > :nth-child(1) > .items-start' , { timeout : 10000 } ) . should ( 'exist' ) . click ( )
193+ cy . get ( '.grid > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' ) . click ( )
197194 cy . wait ( 2000 )
198195
196+ // Verify we're on the document detail page
197+ cy . url ( ) . should ( 'match' , / \/ k n o w l e d g e \/ [ a - f 0 - 9 - ] + / )
198+
199199 // Click on the inline-flex button to add tag
200200 cy . get ( '.inline-flex' ) . click ( { multiple : true } )
201201 cy . wait ( 1000 )
@@ -217,14 +217,15 @@ describe('Chat', () => {
217217
218218 // Poll for documents to ensure they're loaded
219219 cy . request ( 'http://localhost:8000/api/documents' ) . its ( 'body.documents' ) . should ( 'have.length.at.least' , 1 )
220- cy . wait ( 2000 )
220+ cy . wait ( 3000 )
221221
222222 // Wait for documents to load and click on the saved chat to open it
223- cy . get ( '.overflow-y-auto' , { timeout : 10000 } ) . should ( 'exist' )
224- cy . get ( '.overflow-y-auto > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' )
225- cy . get ( '.overflow-y-auto > :nth-child(1) > .items-start' , { timeout : 10000 } ) . should ( 'exist' ) . click ( )
223+ cy . get ( '.grid > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' ) . click ( )
226224 cy . wait ( 2000 )
227225
226+ // Verify we're on the document detail page
227+ cy . url ( ) . should ( 'match' , / \/ k n o w l e d g e \/ [ a - f 0 - 9 - ] + / )
228+
228229 // Click the edit button
229230 cy . contains ( 'button' , 'Edit' ) . click ( )
230231 cy . wait ( 1000 )
@@ -253,14 +254,19 @@ describe('Chat', () => {
253254
254255 // Poll for documents to ensure they're loaded
255256 cy . request ( 'http://localhost:8000/api/documents' ) . its ( 'body.documents' ) . should ( 'have.length.at.least' , 1 )
257+ cy . wait ( 3000 )
258+
259+ // Click on the first document to open it
260+ cy . get ( '.grid > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' ) . click ( )
256261 cy . wait ( 2000 )
257262
258- // Wait for documents to load and find and delete the saved chat
259- cy . get ( '.overflow-y-auto' , { timeout : 10000 } ) . should ( 'exist' )
260- cy . get ( '.overflow-y-auto > :nth-child(1)' , { timeout : 10000 } ) . should ( 'exist' )
261- cy . get ( '.overflow-y-auto > :nth-child(1)' ) . find ( 'button[title*="Delete"], button:contains("Delete"), .delete' ) . first ( ) . click ( )
263+ // Delete the document from the detail page
264+ cy . get ( 'button' ) . contains ( 'Delete' , { timeout : 10000 } ) . click ( )
262265 cy . wait ( 2000 )
263266
267+ // Should redirect back to knowledge base
268+ cy . url ( ) . should ( 'include' , '/knowledge' )
269+
264270 // Second: Delete the created tag
265271 cy . get ( '.from-orange-500' ) . click ( )
266272 cy . url ( ) . should ( 'include' , '/tags' )
0 commit comments