Parcourir la source

Merge pull request #4529 from cheahjs/fix/integration-tests

ci: fix cypress integration tests
Timothy Jaeryang Baek il y a 9 mois
Parent
commit
748be3e637
2 fichiers modifiés avec 25 ajouts et 13 suppressions
  1. 7 0
      .github/workflows/integration-test.yml
  2. 18 13
      cypress/e2e/chat.cy.ts

+ 7 - 0
.github/workflows/integration-test.yml

@@ -15,6 +15,13 @@ jobs:
     name: Run Cypress Integration Tests
     runs-on: ubuntu-latest
     steps:
+      - name: Maximize build space
+        uses: AdityaGarg8/remove-unwanted-software@v4.1
+        with:
+          remove-android: 'true'
+          remove-haskell: 'true'
+          remove-codeql: 'true'
+
       - name: Checkout Repository
         uses: actions/checkout@v4
 

+ 18 - 13
cypress/e2e/chat.cy.ts

@@ -38,9 +38,10 @@ describe('Settings', () => {
 			// User's message should be visible
 			cy.get('.chat-user').should('exist');
 			// Wait for the response
-			cy.get('.chat-assistant', { timeout: 120_000 }) // .chat-assistant is created after the first token is received
-				.find('div[aria-label="Generation Info"]', { timeout: 120_000 }) // Generation Info is created after the stop token is received
-				.should('exist');
+			// .chat-assistant is created after the first token is received
+			cy.get('.chat-assistant', { timeout: 10_000 }).should('exist');
+			// Generation Info is created after the stop token is received
+			cy.get('div[aria-label="Generation Info"]', { timeout: 120_000 }).should('exist');
 		});
 
 		it('user can share chat', () => {
@@ -57,21 +58,24 @@ describe('Settings', () => {
 			// User's message should be visible
 			cy.get('.chat-user').should('exist');
 			// Wait for the response
-			cy.get('.chat-assistant', { timeout: 120_000 }) // .chat-assistant is created after the first token is received
-				.find('div[aria-label="Generation Info"]', { timeout: 120_000 }) // Generation Info is created after the stop token is received
-				.should('exist');
+			// .chat-assistant is created after the first token is received
+			cy.get('.chat-assistant', { timeout: 10_000 }).should('exist');
+			// Generation Info is created after the stop token is received
+			cy.get('div[aria-label="Generation Info"]', { timeout: 120_000 }).should('exist');
 			// spy on requests
 			const spy = cy.spy();
-			cy.intercept('GET', '/api/v1/chats/*', spy);
+			cy.intercept('POST', '/api/v1/chats/**/share', spy);
 			// Open context menu
 			cy.get('#chat-context-menu-button').click();
 			// Click share button
 			cy.get('#chat-share-button').click();
 			// Check if the share dialog is visible
 			cy.get('#copy-and-share-chat-button').should('exist');
-			cy.wrap({}, { timeout: 5000 }).should(() => {
-				// Check if the request was made twice (once for to replace chat object and once more due to change event)
-				expect(spy).to.be.callCount(2);
+			// Click the copy button
+			cy.get('#copy-and-share-chat-button').click();
+			cy.wrap({}, { timeout: 5_000 }).should(() => {
+				// Check if the share request was made
+				expect(spy).to.be.callCount(1);
 			});
 		});
 
@@ -89,9 +93,10 @@ describe('Settings', () => {
 			// User's message should be visible
 			cy.get('.chat-user').should('exist');
 			// Wait for the response
-			cy.get('.chat-assistant', { timeout: 120_000 }) // .chat-assistant is created after the first token is received
-				.find('div[aria-label="Generation Info"]', { timeout: 120_000 }) // Generation Info is created after the stop token is received
-				.should('exist');
+			// .chat-assistant is created after the first token is received
+			cy.get('.chat-assistant', { timeout: 10_000 }).should('exist');
+			// Generation Info is created after the stop token is received
+			cy.get('div[aria-label="Generation Info"]', { timeout: 120_000 }).should('exist');
 			// Click on the generate image button
 			cy.get('[aria-label="Generate Image"]').click();
 			// Wait for image to be visible