Skip to content

Commit

Permalink
add plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwinto committed Jun 20, 2024
1 parent c8fee83 commit ef3a507
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
63 changes: 63 additions & 0 deletions cypress/e2e/plugins.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
describe("Message Plugins", () => {
beforeEach(() => {
cy.visitWebchat();
})

it("shows message matched by plugin", () => {
cy.initMockWebchat();
cy.openWebchat().startConversation();

cy.receiveMessage(
"",
{
"_plugin": {
"type": "google-maps",
"center": {
"lat": 51.259823489,
"lng": 6.23432432
},
"zoom": 12,
"apikey": ""
}
},
"bot"
);

cy.contains("Google").should("be.visible");
});

it("skips rendering a messaging not matched by any plugin", () => {
cy.initMockWebchat();
cy.openWebchat().startConversation();

cy.receiveMessage(
"",
{
"_plugin": {
"type": "GARBAGE",
}
},
"bot"
);

cy.contains("TEST MESSAGE").should("not.exist");
});

it("renders text when exist but no other plugin was matched", () => {
cy.initMockWebchat();
cy.openWebchat().startConversation();

cy.receiveMessage(
"TEST MESSAGE",
{
"_plugin": {
"type": "GARBAGE",
}
},
"bot"
);

cy.contains("TEST MESSAGE").should("be.visible");
});
})

1 change: 1 addition & 0 deletions dist/webchat.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<body>
<script src="./webchat.js"></script>
<script src="./plugin.test.js"></script>
</body>
</html>

0 comments on commit ef3a507

Please sign in to comment.