Skip to content

Commit

Permalink
Merge pull request #79 from RasaHQ/feature/reconnection-on-closed-widget
Browse files Browse the repository at this point in the history
test(e2e):SocketIO connection is reconnected after more then 5s widge…
  • Loading branch information
csunjka authored Aug 22, 2024
2 parents 08904f8 + 05cebe1 commit 41bdb75
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
Binary file modified e2e/RasaChatbotWidgetTestCases.xlsx
Binary file not shown.
4 changes: 4 additions & 0 deletions e2e/cypress/pageObjects/chatbotWidgetPOM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class ChatbotWidget {
return cy.get('div.rasa-chatbot-widget__launcher');
}

get widgetCloseButton() {
return cy.get('rasa-icon-close-chat');
}

get widgetLauncherImage() {
return cy.get('img.rasa-chatbot-widget__launcher-image');
}
Expand Down
71 changes: 71 additions & 0 deletions e2e/cypress/tests/miscTestCases.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { userInputs } from '@rasa-cypress-fixtures/chatbotWidgetData';
import { chatbotWidgetPage } from '@rasa-cypress-POM/chatbotWidgetPOM';
import { generateMixedString } from '@rasa-cypress-utils/utils';
import { invoke } from 'cypress/types/lodash';
Expand Down Expand Up @@ -47,4 +48,74 @@ describe('Miscellaneous test cases for Rasa Chat Widget', () => {
expect(text.length).to.eq(500);
});
});

it('TC022 - Widget reconnects SocketIO session after being closed more then 5s', () => {
chatbotWidgetPage.widgetLauncher.should('be.visible');

chatbotWidgetPage.widgetLauncher.click();

chatbotWidgetPage.widgetOpened.should('be.visible');

chatbotWidgetPage.widgetHeader.should('be.visible');

chatbotWidgetPage.widgetHeader
.get('span')
.should('contain.text', 'Rasa Widget');

chatbotWidgetPage.widgetInputField.should('be.visible');

chatbotWidgetPage.widgetSendButton.should('be.visible');

chatbotWidgetPage.widgetSessionDivider.should('be.visible');

chatbotWidgetPage.widgetSessionDivider.should('have.length', 1);

cy.userSendMessage(userInputs.textMessage);

cy.checkUserMessageIsSent(userInputs.textMessage);

chatbotWidgetPage.botChatTextMessage.should('be.visible');

chatbotWidgetPage.botChatTextMessage
.get('span')
.should(
'contain.text',
"I understand you want to be connected to a human agent, but that's something I cannot help you with at the moment. Is there something else I can help you with?"
);

chatbotWidgetPage.widgetCloseButton.should('be.visible');

chatbotWidgetPage.widgetCloseButton.click();

chatbotWidgetPage.widgetOpened.should('not.exist');

chatbotWidgetPage.widgetLauncher.should('be.visible');

cy.wait(5000);

chatbotWidgetPage.widgetLauncher.click();

chatbotWidgetPage.widgetOpened.should('be.visible');

chatbotWidgetPage.widgetHeader.should('be.visible');

chatbotWidgetPage.widgetInputField.should('be.visible');

chatbotWidgetPage.widgetSendButton.should('be.visible');

cy.checkUserMessageIsSent(userInputs.textMessage);

chatbotWidgetPage.botChatTextMessage.should('be.visible');

chatbotWidgetPage.botChatTextMessage
.get('span')
.should(
'contain.text',
"I understand you want to be connected to a human agent, but that's something I cannot help you with at the moment. Is there something else I can help you with?"
);

chatbotWidgetPage.widgetSessionDivider.should('be.visible');

chatbotWidgetPage.widgetSessionDivider.should('have.length', 2);
});
});

0 comments on commit 41bdb75

Please sign in to comment.