Skip to content

Commit a8f9435

Browse files
gooddaytodaykiselev
authored andcommitted
Cypress test for added later element
1 parent a0957d7 commit a8f9435

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
context("Added later element", () => {
2+
const addedLaterElId = "later_added";
3+
const stepOneText = "step one";
4+
const stepTwoText = "step two, click on create btn";
5+
const stepThreeText = "added later element";
6+
const createDivBtnSelector = "#create-div-button";
7+
beforeEach(() => {
8+
cy.visit("./cypress/setup/create_div_btn.html").then((window) => {
9+
window
10+
.introJs()
11+
.setOptions({
12+
disableInteraction: false,
13+
steps: [
14+
{
15+
intro: stepOneText,
16+
},
17+
{
18+
intro: stepTwoText,
19+
element: createDivBtnSelector,
20+
},
21+
{
22+
intro: stepThreeText,
23+
element: "#" + addedLaterElId,
24+
},
25+
],
26+
})
27+
.start();
28+
});
29+
});
30+
31+
it("should find by selector and highlight added later element", () => {
32+
cy.get(".introjs-tooltiptext").contains(stepOneText);
33+
cy.nextStep();
34+
cy.get(".introjs-tooltiptext").contains(stepTwoText);
35+
cy.wait(500);
36+
cy.get(createDivBtnSelector).click();
37+
cy.nextStep();
38+
cy.wait(500);
39+
cy.get("#" + addedLaterElId)
40+
.filter(".introjs-showElement")
41+
.contains("Later added div");
42+
cy.wait(2000);
43+
cy.compareSnapshot("added-later-element-end", 0.05);
44+
cy.doneButton();
45+
cy.get(".introjs-showElement").should("not.exist");
46+
});
47+
});
Loading

tests/cypress/support/commands.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Cypress.Commands.add("nextStep", () => {
3434
cy.get(".introjs-nextbutton").click();
3535
});
3636

37+
Cypress.Commands.add("doneButton", () => {
38+
cy.get(".introjs-donebutton").click();
39+
});
40+
3741
Cypress.Commands.add("prevStep", () => {
3842
cy.get(".introjs-prevbutton").click();
3943
});

0 commit comments

Comments
 (0)