-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from RasaHQ/feature/widget-input-field-max-cha…
…racter-limit test(e2e): Max allowed number of characters in widget input field
- Loading branch information
Showing
6 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters