Skip to content
Snippets Groups Projects
Commit 8bc4eee7 authored by Johanna Szepanski's avatar Johanna Szepanski
Browse files

migrated dialog test

parent 68477fd2
No related branches found
No related tags found
1 merge request!217CE-3633: Migrate dialogs
import { mount } from "cypress/react";
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount;
login(): Chainable<void>;
}
}
}
import { composeStories } from "@storybook/react"; import { composeStories } from "@storybook/react";
import { mount } from "cypress/react";
import * as stories from "../../../stories/common/Dialog/Dialog.stories"; import * as stories from "../../../stories/common/Dialog/Dialog.stories";
const { BasicDialog, Confirmation, DangerActionDialog } = const { BasicDialog, Confirmation, DangerActionDialog } =
...@@ -6,14 +7,14 @@ const { BasicDialog, Confirmation, DangerActionDialog } = ...@@ -6,14 +7,14 @@ const { BasicDialog, Confirmation, DangerActionDialog } =
describe("SimpleDialog", () => { describe("SimpleDialog", () => {
it("should close on clicking close", () => { it("should close on clicking close", () => {
cy.mount(<BasicDialog />); mount(<BasicDialog />);
cy.findByText(/some title/i).should("exist"); cy.findByText(/some title/i).should("exist");
cy.findByRole("button", { name: /close/i }).click(); cy.findByRole("button", { name: /close/i }).click();
cy.findByText(/some title/i).should("not.exist"); cy.findByText(/some title/i).should("not.exist");
}); });
it("should close on escape", () => { it("should close on escape", () => {
cy.mount(<BasicDialog />); mount(<BasicDialog />);
cy.findByText(/some title/i) cy.findByText(/some title/i)
.should("exist") .should("exist")
...@@ -26,7 +27,7 @@ const closedText = "You closed the dialog!"; ...@@ -26,7 +27,7 @@ const closedText = "You closed the dialog!";
describe("ConfirmationDialog", () => { describe("ConfirmationDialog", () => {
it("should close on clicking close icon", () => { it("should close on clicking close icon", () => {
cy.mount(<Confirmation />); mount(<Confirmation />);
cy.findByText(/some title/i).should("exist"); cy.findByText(/some title/i).should("exist");
cy.findByRole("button", { name: /close/i }).click(); cy.findByRole("button", { name: /close/i }).click();
...@@ -34,7 +35,7 @@ describe("ConfirmationDialog", () => { ...@@ -34,7 +35,7 @@ describe("ConfirmationDialog", () => {
cy.findByText(closedText).should("exist"); cy.findByText(closedText).should("exist");
}); });
it("should close on escape", () => { it("should close on escape", () => {
cy.mount(<Confirmation />); mount(<Confirmation />);
cy.findByText(/some title/i) cy.findByText(/some title/i)
.should("exist") .should("exist")
...@@ -43,7 +44,7 @@ describe("ConfirmationDialog", () => { ...@@ -43,7 +44,7 @@ describe("ConfirmationDialog", () => {
cy.findByText(closedText).should("exist"); cy.findByText(closedText).should("exist");
}); });
it("should close and when clicking cancel", () => { it("should close and when clicking cancel", () => {
cy.mount(<Confirmation />); mount(<Confirmation />);
cy.findByText(/some title/i).should("exist"); cy.findByText(/some title/i).should("exist");
cy.findByRole("button", { name: /cancel/i }).click(); cy.findByRole("button", { name: /cancel/i }).click();
...@@ -54,7 +55,7 @@ describe("ConfirmationDialog", () => { ...@@ -54,7 +55,7 @@ describe("ConfirmationDialog", () => {
describe("DangerActionDialog", () => { describe("DangerActionDialog", () => {
const mountDangerActionDialog = () => { const mountDangerActionDialog = () => {
cy.mount(<DangerActionDialog />); mount(<DangerActionDialog />);
cy.contains("Open Danger Action Dialog").click(); cy.contains("Open Danger Action Dialog").click();
}; };
......
import { KeyboardEvent, useState } from "react"; import { KeyboardEvent, useState } from "react";
export const useTypingTimer = ({ init = "", interval = 750 } = {}) => { export const useTypingTimer = ({ init = "", interval = 750 } = {}) => {
const [typingTimer, setTypingTimer] = useState<NodeJS.Timeout>(); const [typingTimer, setTypingTimer] =
useState<ReturnType<typeof setTimeout>>();
const [value, setValue] = useState(init); const [value, setValue] = useState(init);
const doneTypingInterval = interval; // ms const doneTypingInterval = interval; // ms
......
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
"noEmit": true, "noEmit": true,
"declaration": true, "declaration": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"typeRoots": ["./dist/index.d.ts", "node_modules/@types"], "typeRoots": ["./dist/index.d.ts", "node_modules/@types", "node_modules"],
/* Linting */ /* Linting */
"strict": true, "strict": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true,
"types": ["cypress", "@testing-library/cypress"]
}, },
"include": ["src"] "include": ["src", "cypress.d.ts"]
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment