Skip to content

Commit

Permalink
Merge pull request #77 from RasaHQ/feature/widget-input-field-max-cha…
Browse files Browse the repository at this point in the history
…racter-limit

test(e2e): Max allowed number of characters in widget input field
  • Loading branch information
csunjka authored Aug 21, 2024
2 parents d6d5f31 + 2739c87 commit 88cef78
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
Binary file modified e2e/RasaChatbotWidgetTestCases.xlsx
Binary file not shown.
4 changes: 4 additions & 0 deletions e2e/cypress/tests/errorToastMessageSocketIO.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ describe('Error Toast message on Network Connectivity issues with Socket IO conn
]);
});

afterEach(() => {
cy.resetWsMessages(mockedServerUrl);
});

it('TC010 - Error toast message on Network connectivity issue - Socket IO', () => {
chatbotWidgetPage.widgetLauncher.click();

Expand Down
50 changes: 50 additions & 0 deletions e2e/cypress/tests/miscTestCases.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { chatbotWidgetPage } from '@rasa-cypress-POM/chatbotWidgetPOM';
import { generateMixedString } from '@rasa-cypress-utils/utils';
import { invoke } from 'cypress/types/lodash';

describe('Miscellaneous test cases for Rasa Chat Widget', () => {
const mockedServerUrl = Cypress.env('mockedServerUrl');

beforeEach(() => {
cy.setPropertiesAndOpenThePage([
{ key: 'server-url', value: mockedServerUrl },
]);
});

afterEach(() => {
cy.resetWsMessages(mockedServerUrl);
});

it('TC012 - User input max number of characters 500', () => {
const userInputOver500Chars = generateMixedString(501);

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');

cy.userSendMessage(userInputOver500Chars);

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

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

cy.get('chat-message')
.find('span.text')
.invoke('text')
.then((text) => {
expect(text.length).to.eq(500);
});
});
});
4 changes: 4 additions & 0 deletions e2e/cypress/tests/propSettings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
describe('Property Settings for Chatbot Widget test suite', () => {
const mockedServerUrl = Cypress.env('mockedServerUrl');

afterEach(() => {
cy.resetWsMessages(mockedServerUrl);
});

it('TC014 - When auto-open property set, widget is opened automatically', () => {
cy.setPropertiesAndOpenThePage([
{ key: 'server-url', value: mockedServerUrl },
Expand Down
20 changes: 20 additions & 0 deletions e2e/cypress/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function generateMixedString(length: number): string {
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
let charCount = 0;

while (result.length < length) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
charCount++;

if (charCount === 10) {
result += ' ';
charCount = 0;
}
}

return result.substring(0, length);
}

export { generateMixedString };
3 changes: 2 additions & 1 deletion e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"baseUrl": ".",
"paths": {
"@rasa-cypress-POM/*": ["./cypress/pageObjects/*"],
"@rasa-cypress-fixtures/*": ["./cypress/fixtures/*"]
"@rasa-cypress-fixtures/*": ["./cypress/fixtures/*"],
"@rasa-cypress-utils/*": ["./cypress/utils/*"]
},
"esModuleInterop": true,
"resolveJsonModule": true,
Expand Down

0 comments on commit 88cef78

Please sign in to comment.