diff --git a/.gitignore b/.gitignore index bd9afb3..684247a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules dist .cache .eslintcache -.parcel-cache \ No newline at end of file +.parcel-cache +cypress/downloads \ No newline at end of file diff --git a/cypress/e2e/tests/TC001.spec.js b/cypress/e2e/tests/TC001.spec.js index 1bfc1d9..267aee0 100644 --- a/cypress/e2e/tests/TC001.spec.js +++ b/cypress/e2e/tests/TC001.spec.js @@ -20,4 +20,33 @@ describe("page bsn tool", () => { it("has an input field for bsn numbers", () => { cy.get("#bsn-number"); }); + + it("should not display copy button when there is no input", () => { + cy.get("#bsn-number__copy-button").should("not.be.visible"); + }); + + it("should display copy button when a valid bsn has been generated", () => { + cy.get("#bsn-generator-btn").click(); + cy.get("#bsn-number__copy-button").should("be.visible"); + }); + + it("should display copy icon when copy button is visible", () => { + cy.get("#bsn-generator-btn").click(); + cy.get("#bsn-number__copy-icon").should("have.class", "fa fa-copy"); + }); + + it("should display checkmark icon when copy button has been clicked", () => { + cy.get("#bsn-number").type("999999023"); + cy.get("#bsn-validator-btn").click(); + cy.get("#bsn-number__copy-button").realClick(); + cy.get("#bsn-number__copy-icon").should("have.class", "fa fa-check"); + }); + + it("should hide copy button when input has changed", () => { + cy.get("#bsn-number").type("999999023"); + cy.get("#bsn-validator-btn").click(); + cy.get("#bsn-number__copy-button").should("exist"); + cy.get("#bsn-number").type("555"); + cy.get("#bsn-number__copy-button").should("not.be.visible"); + }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 119ab03..563b06f 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,5 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +// eslint-disable-next-line import/no-extraneous-dependencies +import "cypress-real-events"; diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index 0120e20..bdd77e7 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,9 +1,9 @@ { - "compilerOptions": { - "allowJs": true, - "baseUrl": "../node_modules", - "types": ["cypress"], - "outDir": "lib" - }, - "include": ["**/*.*"] + "compilerOptions": { + "allowJs": true, + "baseUrl": "../node_modules", + "outDir": "lib", + "types": ["cypress", "node", "cypress-real-events"], + }, + "include": ["**/*.*"], } diff --git a/package-lock.json b/package-lock.json index 2493f6e..2c21b33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "ISC", "dependencies": { "bsn-js": "^1.0.4", - "cypress": "^13.6.4" + "cypress": "^13.6.4", + "cypress-real-events": "^1.11.0" }, "devDependencies": { "eslint": "^8.55.0", @@ -3392,6 +3393,14 @@ "node": "^16.0.0 || ^18.0.0 || >=20.0.0" } }, + "node_modules/cypress-real-events": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/cypress-real-events/-/cypress-real-events-1.11.0.tgz", + "integrity": "sha512-4LXVRsyq+xBh5TmlEyO1ojtBXtN7xw720Pwb9rEE9rkJuXmeH3VyoR1GGayMGr+Itqf11eEjfDewtDmcx6PWPQ==", + "peerDependencies": { + "cypress": "^4.x || ^5.x || ^6.x || ^7.x || ^8.x || ^9.x || ^10.x || ^11.x || ^12.x || ^13.x" + } + }, "node_modules/cypress/node_modules/cli-truncate": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", diff --git a/package.json b/package.json index b3827a2..438d177 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "license": "ISC", "dependencies": { "bsn-js": "^1.0.4", - "cypress": "^13.6.4" + "cypress": "^13.6.4", + "cypress-real-events": "^1.11.0" }, "devDependencies": { "eslint": "^8.55.0",