Skip to content

Commit

Permalink
add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwinto committed May 2, 2024
1 parent 884af4a commit 261747c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe("When Input is Focused", () => {
it("Sends postback on click", () => {
cy.visitWebchat();
cy.initMockWebchat();
cy.openWebchat();
cy.startConversation();

cy.fixture("messages/buttons.json").then(({ text, data, source }) => {
cy.receiveMessage(text, data, source);
});

cy.focusInput();
cy.contains("foobar005b1").click();
cy.get(".webchat-message-row.user").contains("foobar005b1").should("be.visible");
});
});
6 changes: 6 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,10 @@ Cypress.Commands.add('updateSettings', (settings: Partial<IWebchatSettings>) =>
});

return cy.then(() => { });
});

Cypress.Commands.add("focusInput", () => {
cy.get(".webchat-input-message-input").focus();

return cy.then(() => {});
});
2 changes: 2 additions & 0 deletions cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ declare namespace Cypress {
* @param settings - The partial settings object to update.
*/
updateSettings(settings: any): Chainable<any>;

focusInput(): Chainable<any>;
}
}

0 comments on commit 261747c

Please sign in to comment.