-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Meena
committed
Aug 13, 2023
1 parent
8cb3932
commit f980f7e
Showing
5 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
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,18 @@ | ||
context("HideHints", () => { | ||
it("should hide all hints after calling hideHints()", () => { | ||
cy.visit("./cypress/setup/index.html").then(async (window) => { | ||
const instance = window.introJs(); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint").should("have.length", 4); | ||
|
||
await instance.hideHints(); | ||
|
||
cy.get(".introjs-hint").should("have.length", 4); | ||
cy.get(".introjs-hint").each((x) => | ||
cy.wrap(x).should("have.class", "introjs-hidehint") | ||
); | ||
}); | ||
}); | ||
}); |
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,60 @@ | ||
context("Hints Modal", () => { | ||
it("should be able to open and close hint modals", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs(); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint").first().click(); | ||
|
||
cy.get(".introjs-tooltip").should("have.length", 1); | ||
cy.get(".introjs-tooltip").contains("fixed header"); | ||
|
||
cy.get(".introjs-button").click(); | ||
|
||
cy.get(".introjs-tooltip").should("have.length", 0); | ||
}); | ||
}); | ||
|
||
it("should display the correct modal content", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs(); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint").first().click(); | ||
|
||
cy.get(".introjs-tooltip").contains("fixed header"); | ||
|
||
cy.get(".introjs-hint").eq(1).click(); | ||
|
||
cy.get(".introjs-tooltip").contains("a button"); | ||
|
||
cy.get(".introjs-hint").eq(2).click(); | ||
|
||
cy.get(".introjs-tooltip").contains("secondary header"); | ||
|
||
cy.get(".introjs-hint").eq(3).click(); | ||
|
||
cy.get(".introjs-tooltip").contains("this is the footer"); | ||
}); | ||
}); | ||
|
||
it("clicking on the same hint should close the modal", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs(); | ||
|
||
instance.showHints(); | ||
|
||
for (let i = 0; i < 3; i++) { | ||
cy.get(".introjs-hint").first().click(); | ||
|
||
cy.get(".introjs-tooltip").contains("fixed header"); | ||
|
||
cy.get(".introjs-hint").first().click(); | ||
|
||
cy.get(".introjs-tooltip").should("not.exist"); | ||
} | ||
}); | ||
}); | ||
}); |
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,32 @@ | ||
context("RemoveHints", () => { | ||
it("should remove all hints after calling removeHints()", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs().setOptions({ | ||
hints: [ | ||
{ | ||
element: "#fixed-parent", | ||
hint: "header element", | ||
}, | ||
{ | ||
element: "#clickable-button", | ||
hint: "main button", | ||
}, | ||
{ | ||
element: "#relative-parent", | ||
hint: "relative parent", | ||
}, | ||
], | ||
}); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint") | ||
.should("have.length", 3) | ||
.then(() => { | ||
instance.removeHints(); | ||
|
||
cy.get(".introjs-hint").should("have.length", 0); | ||
}); | ||
}); | ||
}); | ||
}); |
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,53 @@ | ||
context("ShowHints", () => { | ||
it("should render all hints using the data-hint attributes", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs(); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint").should("have.length", 4); | ||
}); | ||
}); | ||
|
||
it("should render all hints on the page with the given JSON options", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs().setOptions({ | ||
hints: [ | ||
{ | ||
element: "#fixed-parent", | ||
hint: "header element", | ||
}, | ||
{ | ||
element: "#clickable-button", | ||
hint: "main button", | ||
}, | ||
{ | ||
element: "#relative-parent", | ||
hint: "relative parent", | ||
}, | ||
], | ||
}); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint").should("have.length", 3); | ||
}); | ||
}); | ||
|
||
it("should prefer JSON options over data-hint attributes", () => { | ||
cy.visit("./cypress/setup/index.html").then((window) => { | ||
const instance = window.introJs().setOptions({ | ||
hints: [ | ||
{ | ||
element: "#fixed-parent", | ||
hint: "header element", | ||
}, | ||
], | ||
}); | ||
|
||
instance.showHints(); | ||
|
||
cy.get(".introjs-hint").should("have.length", 1); | ||
}); | ||
}); | ||
}); |
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