diff --git a/jest.config.js b/jest.config.js index 398cf3684..3da535ea5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ const { createConfig } = require('@edx/frontend-build'); module.exports = createConfig('jest', { - setupFiles: [ + setupFilesAfterEnv: [ '/src/setupTest.js', ], }); diff --git a/package-lock.json b/package-lock.json index 5eec7fdc0..f28699923 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,11 +49,9 @@ "@edx/browserslist-config": "^1.1.1", "@edx/frontend-build": "13.0.14", "@edx/reactifex": "2.2.0", + "@testing-library/jest-dom": "5.17.0", "@testing-library/react": "12.1.5", - "@wojtekmaj/enzyme-adapter-react-17": "0.8.0", - "enzyme": "3.11.0", "glob": "10.3.10", - "react-test-renderer": "17.0.2", "reactifex": "1.1.1", "redux-mock-store": "1.5.4" } @@ -66,6 +64,12 @@ "node": ">=0.10.0" } }, + "node_modules/@adobe/css-tools": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.3.2.tgz", + "integrity": "sha512-DA5a1C0gD/pLOvhv33YMrbf2FK3oUzwNl9oOJqE4XVjuEtt6XIakRcsd7eLiOSPkp1kTRQGICTA8cKra/vFbjw==", + "dev": true + }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -4438,6 +4442,18 @@ "@types/yargs-parser": "*" } }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/@jest/fake-timers": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-26.6.2.tgz", @@ -4739,6 +4755,18 @@ "node": ">=0.10.0" } }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/@jest/source-map": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-26.6.2.tgz", @@ -5049,6 +5077,23 @@ "node": ">=0.10.0" } }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -5486,6 +5531,12 @@ "react": ">=16.8.0" } }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, "node_modules/@sinonjs/commons": { "version": "1.8.6", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", @@ -5764,6 +5815,41 @@ "node": ">=12" } }, + "node_modules/@testing-library/jest-dom": { + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.17.0.tgz", + "integrity": "sha512-ynmNeT7asXyH3aSVv4vvX4Rb+0qjOhdNHnO/3vuZNqPmhDpV/+rCSGwQ7bLcmU2cJ4dvoheIO85LQj0IbJHEtg==", + "dev": true, + "dependencies": { + "@adobe/css-tools": "^4.0.1", + "@babel/runtime": "^7.9.2", + "@types/testing-library__jest-dom": "^5.9.1", + "aria-query": "^5.0.0", + "chalk": "^3.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.5.6", + "lodash": "^4.17.15", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=8", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@testing-library/react": { "version": "12.1.5", "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-12.1.5.tgz", @@ -6022,6 +6108,132 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.5.11", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.11.tgz", + "integrity": "sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/jest/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@types/jest/node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "node_modules/@types/jest/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@types/json-schema": { "version": "7.0.12", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", @@ -6175,6 +6387,15 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" }, + "node_modules/@types/testing-library__jest-dom": { + "version": "5.14.9", + "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.9.tgz", + "integrity": "sha512-FSYhIjFlfOpGSRyVoMBMuS3ws5ehFQODymf3vlI7U1K8c7PHwWwFY7VREfmsuzHSOnoKs/9/Y983ayOs7eRzqw==", + "dev": true, + "dependencies": { + "@types/jest": "*" + } + }, "node_modules/@types/warning": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz", @@ -6188,6 +6409,15 @@ "@types/node": "*" } }, + "node_modules/@types/yargs": { + "version": "17.0.32", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", + "integrity": "sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, "node_modules/@types/yargs-parser": { "version": "21.0.0", "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", @@ -6365,46 +6595,6 @@ } } }, - "node_modules/@wojtekmaj/enzyme-adapter-react-17": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@wojtekmaj/enzyme-adapter-react-17/-/enzyme-adapter-react-17-0.8.0.tgz", - "integrity": "sha512-zeUGfQRziXW7R7skzNuJyi01ZwuKCH8WiBNnTgUJwdS/CURrJwAhWsfW7nG7E30ak8Pu3ZwD9PlK9skBfAoOBw==", - "dev": true, - "dependencies": { - "@wojtekmaj/enzyme-adapter-utils": "^0.2.0", - "enzyme-shallow-equal": "^1.0.0", - "has": "^1.0.0", - "prop-types": "^15.7.0", - "react-is": "^17.0.0", - "react-test-renderer": "^17.0.0" - }, - "funding": { - "url": "https://github.com/wojtekmaj/enzyme-adapter-react-17?sponsor=1" - }, - "peerDependencies": { - "enzyme": "^3.0.0", - "react": "^17.0.0-0", - "react-dom": "^17.0.0-0" - } - }, - "node_modules/@wojtekmaj/enzyme-adapter-utils": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@wojtekmaj/enzyme-adapter-utils/-/enzyme-adapter-utils-0.2.0.tgz", - "integrity": "sha512-ZvZm9kZxZEKAbw+M1/Q3iDuqQndVoN8uLnxZ8bzxm7KgGTBejrGRoJAp8f1EN8eoO3iAjBNEQnTDW/H4Ekb0FQ==", - "dev": true, - "dependencies": { - "function.prototype.name": "^1.1.0", - "has": "^1.0.0", - "object.fromentries": "^2.0.0", - "prop-types": "^15.7.0" - }, - "funding": { - "url": "https://github.com/wojtekmaj/enzyme-adapter-utils?sponsor=1" - }, - "peerDependencies": { - "react": "^17.0.0-0" - } - }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -6755,25 +6945,6 @@ "node": ">=0.10.0" } }, - "node_modules/array.prototype.filter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array.prototype.filter/-/array.prototype.filter-1.0.2.tgz", - "integrity": "sha512-us+UrmGOilqttSOgoWZTpOvHu68vZT2YCjc/H4vhu56vzZpaDFBhB+Se2UwqWzMKbDv7Myq5M5pcZLAtUvTQdQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-array-method-boxes-properly": "^1.0.0", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/array.prototype.flat": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", @@ -7804,44 +7975,6 @@ "resolved": "https://registry.npmjs.org/check-types/-/check-types-7.3.0.tgz", "integrity": "sha512-bzDMlwEIZFtyK70RHwQhMCvXpPyJZgOCCKlvH9oAJz4quUQse8ZynYE5RQzKpY7b5PoL6G+jQMcZzUPD4p6tFg==" }, - "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", - "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", - "dev": true, - "dependencies": { - "cheerio-select": "^2.1.0", - "dom-serializer": "^2.0.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" - }, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/cheeriojs/cheerio?sponsor=1" - } - }, - "node_modules/cheerio-select": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", - "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-select": "^5.1.0", - "css-what": "^6.1.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/child_process": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", @@ -7881,6 +8014,21 @@ "node": ">=6.0" } }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, "node_modules/cjs-module-lexer": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz", @@ -8536,6 +8684,12 @@ "url": "https://github.com/sponsors/fb55" } }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -8999,12 +9153,6 @@ "node": ">=8" } }, - "node_modules/discontinuous-range": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", - "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", - "dev": true - }, "node_modules/dns-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", @@ -9295,52 +9443,6 @@ "node": ">=4" } }, - "node_modules/enzyme": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/enzyme/-/enzyme-3.11.0.tgz", - "integrity": "sha512-Dw8/Gs4vRjxY6/6i9wU0V+utmQO9kvh9XLnz3LIudviOnVYDEe2ec+0k+NQoMamn1VrjKgCUOWj5jG/5M5M0Qw==", - "dev": true, - "dependencies": { - "array.prototype.flat": "^1.2.3", - "cheerio": "^1.0.0-rc.3", - "enzyme-shallow-equal": "^1.0.1", - "function.prototype.name": "^1.1.2", - "has": "^1.0.3", - "html-element-map": "^1.2.0", - "is-boolean-object": "^1.0.1", - "is-callable": "^1.1.5", - "is-number-object": "^1.0.4", - "is-regex": "^1.0.5", - "is-string": "^1.0.5", - "is-subset": "^0.1.1", - "lodash.escape": "^4.0.1", - "lodash.isequal": "^4.5.0", - "object-inspect": "^1.7.0", - "object-is": "^1.0.2", - "object.assign": "^4.1.0", - "object.entries": "^1.1.1", - "object.values": "^1.1.1", - "raf": "^3.4.1", - "rst-selector-parser": "^2.2.3", - "string.prototype.trim": "^1.2.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/enzyme-shallow-equal": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/enzyme-shallow-equal/-/enzyme-shallow-equal-1.0.5.tgz", - "integrity": "sha512-i6cwm7hN630JXenxxJFBKzgLC3hMTafFQXflvzHgPmDhOBhxUWDe8AeRv1qp2/uWJ2Y8z5yLWMzmAfkTOiOCZg==", - "dev": true, - "dependencies": { - "has": "^1.0.3", - "object-is": "^1.1.5" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -9404,12 +9506,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/es-array-method-boxes-properly": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", - "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==", - "dev": true - }, "node_modules/es-module-lexer": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.3.0.tgz", @@ -11873,19 +11969,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/html-element-map": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/html-element-map/-/html-element-map-1.3.1.tgz", - "integrity": "sha512-6XMlxrAFX4UEEGxctfFnmrFaaZFNf9i5fNuV5wZ3WWQ4FVaNP1aX1LkX9j2mfEx1NpjeE/rL3nmgEn23GdFmrg==", - "dev": true, - "dependencies": { - "array.prototype.filter": "^1.0.0", - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", @@ -11967,25 +12050,6 @@ "webpack": "^5.20.0" } }, - "node_modules/htmlparser2": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", - "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", - "dev": true, - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "entities": "^4.4.0" - } - }, "node_modules/http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -12814,12 +12878,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-subset": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", - "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==", - "dev": true - }, "node_modules/is-symbol": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", @@ -13800,6 +13858,15 @@ "node": ">= 10.14.2" } }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/jest-jasmine2": { "version": "26.6.3", "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-26.6.3.tgz", @@ -14820,6 +14887,23 @@ "node": ">=8" } }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/jest-watcher": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-26.6.2.tgz", @@ -15264,29 +15348,11 @@ "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" }, - "node_modules/lodash.escape": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-4.0.1.tgz", - "integrity": "sha512-nXEOnb/jK9g0DYMr1/Xvq6l5xMD7GDG55+GSYIYmS0G4tBk/hURD4JR9WCavs04t33WmJx9kCyp9vJ+mr4BOUw==", - "dev": true - }, - "node_modules/lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", - "dev": true - }, "node_modules/lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==" }, - "node_modules/lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "dev": true - }, "node_modules/lodash.isfunction": { "version": "3.0.9", "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz", @@ -15803,12 +15869,6 @@ "node": ">=10" } }, - "node_modules/moo": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", - "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", - "dev": true - }, "node_modules/mrmime": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz", @@ -15882,34 +15942,6 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" }, - "node_modules/nearley": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", - "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", - "dev": true, - "dependencies": { - "commander": "^2.19.0", - "moo": "^0.5.0", - "railroad-diagrams": "^1.0.0", - "randexp": "0.4.6" - }, - "bin": { - "nearley-railroad": "bin/nearley-railroad.js", - "nearley-test": "bin/nearley-test.js", - "nearley-unparse": "bin/nearley-unparse.js", - "nearleyc": "bin/nearleyc.js" - }, - "funding": { - "type": "individual", - "url": "https://nearley.js.org/#give-to-nearley" - } - }, - "node_modules/nearley/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/needle": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/needle/-/needle-3.2.0.tgz", @@ -16169,22 +16201,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object-is": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", - "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", @@ -16522,31 +16538,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dev": true, - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/parse5-htmlparser2-tree-adapter": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", - "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", - "dev": true, - "dependencies": { - "domhandler": "^5.0.2", - "parse5": "^7.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -16639,12 +16630,6 @@ "node": ">=8" } }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", - "dev": true - }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -17804,21 +17789,6 @@ "node": ">=8" } }, - "node_modules/raf": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", - "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", - "dev": true, - "dependencies": { - "performance-now": "^2.1.0" - } - }, - "node_modules/railroad-diagrams": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", - "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", - "dev": true - }, "node_modules/ramda": { "version": "0.28.0", "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz", @@ -17828,19 +17798,6 @@ "url": "https://opencollective.com/ramda" } }, - "node_modules/randexp": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", - "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", - "dev": true, - "dependencies": { - "discontinuous-range": "1.0.0", - "ret": "~0.1.10" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -18334,19 +18291,6 @@ "react-dom": ">=16.8" } }, - "node_modules/react-shallow-renderer": { - "version": "16.15.0", - "resolved": "https://registry.npmjs.org/react-shallow-renderer/-/react-shallow-renderer-16.15.0.tgz", - "integrity": "sha512-oScf2FqQ9LFVQgA73vr86xl2NaOIX73rh+YFqcOp68CWj56tSfgtGKrEbyhCj0rSijyG9M1CYprTh39fBi5hzA==", - "dev": true, - "dependencies": { - "object-assign": "^4.1.1", - "react-is": "^16.12.0 || ^17.0.0 || ^18.0.0" - }, - "peerDependencies": { - "react": "^16.0.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/react-side-effect": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.2.tgz", @@ -18389,21 +18333,6 @@ "react": "^16.8.3 || ^17.0.0-0 || ^18.0.0" } }, - "node_modules/react-test-renderer": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-17.0.2.tgz", - "integrity": "sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==", - "dev": true, - "dependencies": { - "object-assign": "^4.1.1", - "react-is": "^17.0.2", - "react-shallow-renderer": "^16.13.1", - "scheduler": "^0.20.2" - }, - "peerDependencies": { - "react": "17.0.2" - } - }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", @@ -19061,16 +18990,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rst-selector-parser": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/rst-selector-parser/-/rst-selector-parser-2.2.3.tgz", - "integrity": "sha512-nDG1rZeP6oFTLN6yNDV/uiAvs1+FS/KlrEwh7+y7dpuApDBy6bI2HTBcc0/V8lv9OTqfyD34eF7au2pm8aBbhA==", - "dev": true, - "dependencies": { - "lodash.flattendeep": "^4.4.0", - "nearley": "^2.7.10" - } - }, "node_modules/rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/package.json b/package.json index ab1e5280b..818d41db6 100644 --- a/package.json +++ b/package.json @@ -68,11 +68,9 @@ "@edx/browserslist-config": "^1.1.1", "@edx/frontend-build": "13.0.14", "@edx/reactifex": "2.2.0", + "@testing-library/jest-dom": "5.17.0", "@testing-library/react": "12.1.5", - "@wojtekmaj/enzyme-adapter-react-17": "0.8.0", - "enzyme": "3.11.0", "glob": "10.3.10", - "react-test-renderer": "17.0.2", "reactifex": "1.1.1", "redux-mock-store": "1.5.4" } diff --git a/src/head/Head.test.jsx b/src/head/Head.test.jsx index 91eab5eb5..a10eb5f82 100644 --- a/src/head/Head.test.jsx +++ b/src/head/Head.test.jsx @@ -1,14 +1,14 @@ import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { Helmet } from 'react-helmet'; -import { mount } from 'enzyme'; +import { render } from '@testing-library/react'; import { getConfig } from '@edx/frontend-platform'; import Head from './Head'; describe('Head', () => { const props = {}; it('should match render title tag and favicon with the site configuration values', () => { - mount(); + render(); const helmet = Helmet.peek(); expect(helmet.title).toEqual(`Profile | ${getConfig().SITE_NAME}`); expect(helmet.linkTags[0].rel).toEqual('shortcut icon'); diff --git a/src/profile/ProfilePage.test.jsx b/src/profile/ProfilePage.test.jsx index 411ca4536..997a92e86 100644 --- a/src/profile/ProfilePage.test.jsx +++ b/src/profile/ProfilePage.test.jsx @@ -3,11 +3,10 @@ import { getConfig } from '@edx/frontend-platform'; import * as analytics from '@edx/frontend-platform/analytics'; import { AppContext } from '@edx/frontend-platform/react'; import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n'; -import { mount } from 'enzyme'; +import { render } from '@testing-library/react'; import React from 'react'; import PropTypes from 'prop-types'; import { Provider } from 'react-redux'; -import renderer from 'react-test-renderer'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; @@ -100,7 +99,7 @@ describe('', () => { config: getConfig(), }; const component = ; - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -110,7 +109,7 @@ describe('', () => { config: getConfig(), }; const component = ; - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -144,7 +143,7 @@ describe('', () => { match={{ params: { username: 'verified' } }} // Override default match /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -159,7 +158,7 @@ describe('', () => { store={mockStore(storeMocks.savingEditedBio)} /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -176,7 +175,7 @@ describe('', () => { store={mockStore(storeData)} /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -194,7 +193,7 @@ describe('', () => { store={mockStore(storeData)} /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -212,7 +211,7 @@ describe('', () => { store={mockStore(storeData)} /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -230,7 +229,7 @@ describe('', () => { store={mockStore(storeData)} /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); @@ -248,7 +247,7 @@ describe('', () => { store={mockStore(storeMocks.viewOwnProfile)} /> ); - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }); it('test age message alert', () => { @@ -259,17 +258,15 @@ describe('', () => { authenticatedUser: { userId: 123, username: 'staff', administrator: true }, config: { ...getConfig(), COLLECT_YEAR_OF_BIRTH: true }, }; - const component = ( + const { container } = render( + />, ); - const wrapper = mount(component); - wrapper.update(); - expect(wrapper.find('.alert-info').hasClass('show')).toBe(true); + expect(container.querySelector('.alert-info')).toHaveClass('show'); }); it('test photo error alert', () => { const storeData = JSON.parse(JSON.stringify(storeMocks.viewOwnProfile)); @@ -278,11 +275,15 @@ describe('', () => { authenticatedUser: { userId: 123, username: 'staff', administrator: true }, config: { ...getConfig(), COLLECT_YEAR_OF_BIRTH: true }, }; - const component = ; - const wrapper = mount(component); - wrapper.update(); + const { container } = render( + , + ); - expect(wrapper.find('.alert-danger').hasClass('show')).toBe(true); + expect(container.querySelector('.alert-danger')).toHaveClass('show'); }); }); @@ -292,15 +293,13 @@ describe('', () => { authenticatedUser: { userId: 123, username: 'staff', administrator: true }, config: getConfig(), }; - const component = ( + render( + />, ); - const wrapper = mount(component); - wrapper.update(); expect(analytics.sendTrackingLogEvent.mock.calls.length).toBe(1); expect(analytics.sendTrackingLogEvent.mock.calls[0][0]).toEqual('edx.profile.viewed'); diff --git a/src/profile/__snapshots__/ProfilePage.test.jsx.snap b/src/profile/__snapshots__/ProfilePage.test.jsx.snap index 8ecdb3ba3..fc4bb65b4 100644 --- a/src/profile/__snapshots__/ProfilePage.test.jsx.snap +++ b/src/profile/__snapshots__/ProfilePage.test.jsx.snap @@ -1,30 +1,28 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` Renders correctly in various states app loading 1`] = ` -
+
-
+ class="profile-page" + >
+ class="profile-page-bg-banner bg-primary d-md-block p-relative" + /> +
- - Profile loading... - + + Profile loading... + +
@@ -32,2375 +30,2194 @@ exports[` Renders correctly in various states app loading 1`] = ` `; exports[` Renders correctly in various states test country edit with error 1`] = ` -
-
+
+
- + +
+ profile avatar
- profile avatar +
+ +
-
- -
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
- -
-
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
-
+
- -

- Lemon Seltzer -

- - This is the name that appears in your account and on your certificates. - + +
+
+
-
-
-
- - -
-
- country error -
-
-
-
-
- - - - - - - -
-
- - -
-
-
-
+ staff + +

+ Member since + 2017 +

+
+
-
-
- -

- Yoruba -

+ +
-
-
-

- Education - -

-

-

- - - Just me - + + + Just me + +

+
+

+ Lemon Seltzer

+ + This is the name that appears in your account and on your certificates. +
-

- Elementary/primary school -

-
-
-

- Social Links - -

-

- -

- - - - Everyone on localhost - -

+ + +
+
+ country error +
+
+
+
+
+ + + + + + + +
+
+ + +
+
+ +
-
+
+
+
-
+

+ Education -

- - + +

+ + + + Just me + +

+
+

+ Elementary/primary school +

+
-
-
-
-
-

- About Me - -

-

+ + + + Everyone on localhost + +

+
+
    - - - - Everyone on localhost - -

    + + Twitter + + +
  • + + + Facebook + +
  • +
  • +
    + +
    +
  • +
-

- This is my bio -

-

- My Certificates - -

-

-

- - - Everyone on localhost - + + + Everyone on localhost + +

+
+

+ This is my bio

+
+
+

+ My Certificates + +

+

+ + + + Everyone on localhost + +

+
+
-
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+

- Verified Certificate + From

-

- edX Demonstration Course -

-
-

- From -

-

- edX -

- @@ -2415,1169 +2232,988 @@ exports[` Renders correctly in various states test country edit w `; exports[` Renders correctly in various states test education edit with error 1`] = ` -
+
- -
- -

- staff -

-

- Member since - 2017 -

-
-
-
- -
+
- -

- Lemon Seltzer -

- - This is the name that appears in your account and on your certificates. - + +
-
-
-

- Location - -

+ + Edit + + +

+ + + + Just me + +

+

- + + This is the name that appears in your account and on your certificates. + +

+
+
+
+
+

- - - Everyone on localhost - + + Edit + +

+

+ + + + Everyone on localhost + +

+
+

+ Montenegro

-

- Montenegro -

-
-
-

- Primary Language Spoken - -

+ + Edit + + +

+ + + + Everyone on localhost + +

+

- - - - Everyone on localhost - + Yoruba

-

- Yoruba -

-
-
-
-
- - -
-
- education error -
-
-
-
+
- + + + + + + + + + + + +
- - - - - +
+ education error +
+
-
+
+ - + + +
-
- + +
-
-
-

- Social Links - -

-

- - - - Everyone on localhost - -

-
- -
-
-
-
-
-
-
-

- About Me - -

- +
+
    - - - - Everyone on localhost - -

    + + Twitter + + +
  • + + + Facebook + +
  • +
  • +
    + +
    +
  • +
-

- This is my bio -

-

- My Certificates - -

-

-

- - - Everyone on localhost - + + + Everyone on localhost + +

+
+

+ This is my bio

+
+
+

+ My Certificates + +

+

+ + + + Everyone on localhost + +

+
+
-
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+
+

+ From +

- Verified Certificate + edX

-

+

- edX Demonstration Course -

-
-

- From -

-

- edX -

-
@@ -3592,2044 +3228,1863 @@ exports[` Renders correctly in various states test education edit `; exports[` Renders correctly in various states test preferreded language edit with error 1`] = ` -
-
+
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
- -
+
- -

- Lemon Seltzer -

- - This is the name that appears in your account and on your certificates. - + +
-
-
-

- Location - -

+ + Edit + + +

+ + + + Just me + +

+

- + + This is the name that appears in your account and on your certificates. + +

+
+
+
+
+

- - - Everyone on localhost - + + Edit + +

+

+ + + + Everyone on localhost + +

+
+

+ Montenegro

-

- Montenegro -

-
-
-
-
- - -
-
- preferred language error -
-
-
-
+
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - - - +
+ preferred language error +
+
- - -
-
-
-
-
-
-
-
-
-

- Education - -

-

- - - - Just me - -

+
+
+ + +
+
+ +
-

- Elementary/primary school -

-
-
-

- Social Links - -

-

-

- - - Everyone on localhost - + + + Just me + +

+
+

+ Elementary/primary school

- + +

+ + + + Everyone on localhost + +

+
+ +
-
-
-

- About Me - -

-

-

- - - Everyone on localhost - + + + Everyone on localhost + +

+
+

+ This is my bio

-

- This is my bio -

-
-
-

- My Certificates - -

-

-

- - - Everyone on localhost - -

-
-
+ + + Everyone on localhost + +

+
-
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+

- Verified Certificate + From

-

- edX Demonstration Course -

-
-

- From -

-

- edX -

- @@ -5644,1527 +5099,1269 @@ exports[` Renders correctly in various states test preferreded la `; exports[` Renders correctly in various states viewing other profile with all fields 1`] = ` -
-
+
+
- +
+
+
+ +
-
- -
-
-
- -

- staff -

-

- Member since - 2017 -

-
- - - - - + staff + +

+ Member since + 2017 +

- Your profile information is only visible to you. Only your username is visible to others on localhost. + + + +
+ Your profile information is only visible to you. Only your username is visible to others on localhost. +
-
-
-
-
- +
-
-
- -

- staff -

-

- Member since - 2017 -

-
- - - - - + staff + +

+ Member since + 2017 +

- Your profile information is only visible to you. Only your username is visible to others on localhost. -
-
-
-
-
- +
-
-
-
+
- -

- user -

+ + + + in a new tab + + + +
-
-
-

+

+ Full Name +

+
+

- Location - + user +

-

-
-
-

- Primary Language Spoken -

+

+ Location +

+
+

-

-
-
-

- Education -

+

+ Primary Language Spoken +

+
+

-

- Other education -

-
-
-

+

+ Education +

+
+

- Social Links - + Other education +

-
-
-
-
-
-

- About Me -

+

+ Social Links +

+
+
-

- bio -

-

- My Certificates -

+

+ About Me +

+
+

+ bio +

- You don't have any certificates yet.
-
-
-
-
-
-`; - -exports[` Renders correctly in various states viewing own profile 1`] = ` -
-
-
-
-
-
-
- -
+ My Certificates +
- profile avatar + You don't have any certificates yet.
-
- -
-
-
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
-
+
+
+`; + +exports[` Renders correctly in various states viewing own profile 1`] = ` +
+
+
- -

- staff -

-

- Member since - 2017 -

-
-
+
+
+ +
+ profile avatar +
+
+ +
+
+
-
+
- -

- Lemon Seltzer -

- - This is the name that appears in your account and on your certificates. - + +
+
+
-
-

- Location - -

+

+ staff +

+ Member since + 2017 +

+
+ +
+ -

- Montenegro -

+ +
-
-
-

- Primary Language Spoken - -

+ + Edit + + +

+ + + + Just me + +

+

- + + This is the name that appears in your account and on your certificates. + +

+
+
+
+
+

- - - Everyone on localhost - + + Edit + +

+

+ + + + Everyone on localhost + +

+
+

+ Montenegro

-

- Yoruba -

-
-
-

- Education - -

+ + Edit + + +

+ + + + Everyone on localhost + +

+

- +

+
+
+
+
+

+ Education + +

+

- - - Just me - + + + Just me + +

+
+

+ Elementary/primary school

-

- Elementary/primary school -

-
-
-

- Social Links - -

-

- - - - Everyone on localhost - -

-
-
+
- - + Facebook + + +
  • +
    + +
    +
  • + +
    -
    -
    -

    - About Me - -

    -

    -

    - - - Everyone on localhost - + + + Everyone on localhost + +

    +
    +

    + This is my bio

    -

    - This is my bio -

    -
    -
    -

    - My Certificates - -

    -

    -

    - - - Everyone on localhost - -

    -
    -
    + + + Everyone on localhost + +

    +
    -
    +
    +
    +

    + Verified Certificate +

    +

    + edX Demonstration Course +

    +

    - Verified Certificate + From

    -

    - edX Demonstration Course -

    -
    -

    - From -

    -

    - edX -

    - @@ -7179,1109 +6376,930 @@ exports[` Renders correctly in various states viewing own profile `; exports[` Renders correctly in various states while saving an edited bio 1`] = ` -
    -
    +
    -
    - -

    - staff -

    -

    - Member since - 2017 -

    -
    -
    -
    - -
    +
    - -

    - Lemon Seltzer -

    - - This is the name that appears in your account and on your certificates. - + +
    -
    -
    -

    - Location - -

    -

    -

    - - - Everyone on localhost - + + + Just me + +

    +
    +

    + Lemon Seltzer

    + + This is the name that appears in your account and on your certificates. +
    -

    - Montenegro -

    -
    -
    -

    - Primary Language Spoken - -

    -

    -

    - - - Everyone on localhost - + + + Everyone on localhost + +

    +
    +

    + Montenegro

    -

    - Yoruba -

    -
    -
    -

    - Education - -

    -

    -

    - - - Just me - + + + Everyone on localhost + +

    +
    +

    + Yoruba

    -

    - Elementary/primary school -

    -
    -
    -

    - Social Links - -

    -

    -

    - - - Everyone on localhost - + + + Just me + +

    +
    +

    + Elementary/primary school

    - + +

    + + + + Everyone on localhost + +

    +
    + +
    -
    -
    -
    -
    - -
    -
    +
    + - + + +
    -
    - + +
    -
    -
    -

    - My Certificates - -

    -

    -

    - - - Everyone on localhost - -

    -
    -
    + + + Everyone on localhost + +

    +
    -
    +
    +
    +

    + Verified Certificate +

    +

    + edX Demonstration Course +

    +

    - Verified Certificate + From

    -

    - edX Demonstration Course -

    -
    -

    - From -

    -

    - edX -

    - @@ -8296,1117 +7314,938 @@ exports[` Renders correctly in various states while saving an edi `; exports[` Renders correctly in various states while saving an edited bio with error 1`] = ` -
    +
    - -
    - -

    - staff -

    -

    - Member since - 2017 -

    -
    -
    -
    - -
    +
    - -

    - Lemon Seltzer -

    - - This is the name that appears in your account and on your certificates. - + +
    -
    -
    -

    - Location - -

    -

    -

    - - - Everyone on localhost - + + + Just me + +

    +
    +

    + Lemon Seltzer

    + + This is the name that appears in your account and on your certificates. +
    -

    - Montenegro -

    -
    -
    -

    - Primary Language Spoken - -

    -

    -

    - - - Everyone on localhost - + + + Everyone on localhost + +

    +
    +

    + Montenegro

    -

    - Yoruba -

    -
    -
    -

    - Education - -

    -

    -

    - - - Just me - + + + Everyone on localhost + +

    +
    +

    + Yoruba

    -

    - Elementary/primary school -

    -
    -
    -

    - Social Links - -

    -

    -

    - - - Everyone on localhost - + + + Just me + +

    +
    +

    + Elementary/primary school

    - + +

    + + + + Everyone on localhost + +

    +
    + +
    -
    -
    -
    -
    - - +
    +
    + bio error +
    +
    -
    +
    + - + + +
    -
    - + +
    -
    -
    -

    - My Certificates - -

    -

    -

    - - - Everyone on localhost - -

    -
    -
    + + + Everyone on localhost + +

    +
    -
    +
    +
    +

    + Verified Certificate +

    +

    + edX Demonstration Course +

    +
    +

    + From +

    +

    + edX +

    +

    - Verified Certificate + Completed on + 3/4/2019

    -

    - edX Demonstration Course -

    -
    -

    - From -

    -

    - edX -

    -
    @@ -9421,952 +8260,788 @@ exports[` Renders correctly in various states while saving an edi `; exports[` Renders correctly in various states without credentials service 1`] = ` -
    +
    -
    +
    - + +
    + profile avatar
    - profile avatar +
    + +
    -
    - -
    -
    -
    - -

    - staff -

    -

    - Member since - 2017 -

    -
    -
    +

    + staff +

    +

    + Member since + 2017 +

    +
    + +
    +
    -
    -
    -
    - -

    - staff -

    -

    - Member since - 2017 -

    -
    -
    -
    -
    -
    +

    + staff +

    +

    + Member since + 2017 +

    +
    + +
    +
    -

    - Full Name - -

    -

    -

    - - - Just me - + + + Just me + +

    +
    +

    + Lemon Seltzer

    + + This is the name that appears in your account and on your certificates. +
    -

    - Lemon Seltzer -

    - - This is the name that appears in your account and on your certificates. -
    -
    -
    -

    - Location - -

    -

    -

    - - - Everyone on localhost - + + + Everyone on localhost + +

    +
    +

    + Montenegro

    -

    - Montenegro -

    -
    -
    -

    - Primary Language Spoken - -

    -

    -

    - - - Everyone on localhost - + + + Everyone on localhost + +

    +
    +

    + Yoruba

    -

    - Yoruba -

    -
    -
    -

    - Education - -

    -

    -

    - - - Just me - + + + Just me + +

    +
    +

    + Elementary/primary school

    -

    - Elementary/primary school -

    -
    -
    -

    - Social Links - -

    -

    - - - - Everyone on localhost - -

    -
    -
    +
    - - + Facebook + + +
  • +
    + +
    +
  • + +
    -
    -
    -

    - About Me - -

    -

    -

    - - - Everyone on localhost - + + + Everyone on localhost + +

    +
    +

    + This is my bio

    -

    - This is my bio -

    -
    -
    -

    - My Certificates - -

    -

    -

    - - - Everyone on localhost - -

    -
    -
    + + + Everyone on localhost + +

    +
    -
    +
    +
    +

    + Verified Certificate +

    +

    + edX Demonstration Course +

    +

    - Verified Certificate + From

    -

    - edX Demonstration Course -

    -
    -

    - From -

    -

    - edX -

    - diff --git a/src/profile/forms/LearningGoal.test.jsx b/src/profile/forms/LearningGoal.test.jsx index 1143aff0b..dcb63b1f1 100644 --- a/src/profile/forms/LearningGoal.test.jsx +++ b/src/profile/forms/LearningGoal.test.jsx @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React, { useMemo } from 'react'; import { Provider } from 'react-redux'; -import renderer from 'react-test-renderer'; +import { render, screen } from '@testing-library/react'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n'; @@ -92,31 +92,25 @@ LearningGoalWrapperWithStore.propTypes = { describe('', () => { describe('renders the current learning goal', () => { it('renders "I want to advance my career"', () => { - const learningGoalRenderer = renderer.create( + render( , ); - - const learningGoalInstance = learningGoalRenderer.root; - - expect(learningGoalInstance.findByProps({ className: 'lead' }).children).toEqual(['I want to advance my career']); + expect(screen.getByText('I want to advance my career')).toBeTruthy(); }); it('renders "Something else"', () => { requiredLearningGoalProps.learningGoal = 'something_else'; - const learningGoalRenderer = renderer.create( + render( , ); - - const learningGoalInstance = learningGoalRenderer.root; - - expect(learningGoalInstance.findByProps({ className: 'lead' }).children).toEqual(['Something else']); + expect(screen.getByText('Something else')).toBeTruthy(); }); }); }); diff --git a/src/profile/forms/SocialLinks.test.jsx b/src/profile/forms/SocialLinks.test.jsx index d25eaa74c..0392d063f 100644 --- a/src/profile/forms/SocialLinks.test.jsx +++ b/src/profile/forms/SocialLinks.test.jsx @@ -1,8 +1,7 @@ -import { mount } from 'enzyme'; +import { render, fireEvent, screen } from '@testing-library/react'; import PropTypes from 'prop-types'; import React, { useMemo } from 'react'; import { Provider } from 'react-redux'; -import renderer from 'react-test-renderer'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n'; @@ -103,7 +102,7 @@ describe('', () => { ['certificates', 'bio', 'goals', 'socialLinks'].forEach(editMode => ( it(`calls social links with edit mode ${editMode}`, () => { const component = ; - const tree = renderer.create(component).toJSON(); + const { container: tree } = render(component); expect(tree).toMatchSnapshot(); }) )); @@ -112,47 +111,45 @@ describe('', () => { const changeHandler = jest.fn(); const submitHandler = jest.fn(); const closeHandler = jest.fn(); - const component = ( + const { container } = render( + />, ); - const wrapper = mount(component); - const socialLink = wrapper.find(SocialLinks); + const { platform } = defaultProps.socialLinks[0]; - const inputField = socialLink.find(`#social-${platform}`); - inputField.simulate('change', { target: { value: 'test', name: platform } }); + const inputField = container.querySelector(`#social-${platform}`); + fireEvent.change(inputField, { target: { value: 'test', name: platform } }); expect(changeHandler).toHaveBeenCalledTimes(1); - expect(socialLink.find('#visibilitySocialLinks select').props().value).toBe('private'); - const event = { target: { value: 'all_users', name: 'visibilitySocialLinks' } }; - socialLink.find('#visibilitySocialLinks select').simulate('change', event); + const selectElement = container.querySelector('#visibilitySocialLinks'); + expect(selectElement.value).toBe('private'); + fireEvent.change(selectElement, { target: { value: 'all_users', name: 'visibilitySocialLinks' } }); expect(changeHandler).toHaveBeenCalledTimes(2); - socialLink.find('[aria-labelledby="editing-form"]').simulate('submit'); + fireEvent.submit(container.querySelector('[aria-labelledby="editing-form"]')); expect(submitHandler).toHaveBeenCalledTimes(1); - socialLink.find('[aria-labelledby="editing-form"]').find('Button .btn-link').simulate('click'); + fireEvent.click(screen.getByRole('button', { name: 'Cancel' })); expect(closeHandler).toHaveBeenCalledTimes(1); }); it('calls social links with static', () => { const openHandler = jest.fn(); - const component = ( + render( + />, ); - const wrapper = mount(component); - const socialLink = wrapper.find(SocialLinks); + const addFacebookButton = screen.getByRole('button', { name: 'Add Facebook' }); + fireEvent.click(addFacebookButton); - socialLink.find('EmptyContent button').first().simulate('click'); expect(openHandler).toHaveBeenCalledTimes(1); }); @@ -160,10 +157,9 @@ describe('', () => { const newStore = JSON.parse(JSON.stringify(savingEditedBio)); newStore.profilePage.errors.bio = { userMessage: 'error' }; - const component = ; - const wrapper = mount(component); - const socialLink = wrapper.find(SocialLinks); + const { container } = render(); - expect(socialLink.find('.alert-danger').exists()).toBe(true); + const alertDanger = container.querySelector('.alert-danger'); + expect(alertDanger).toBeInTheDocument(); }); }); diff --git a/src/profile/forms/__snapshots__/SocialLinks.test.jsx.snap b/src/profile/forms/__snapshots__/SocialLinks.test.jsx.snap index f0aa6c848..74fb7e2a9 100644 --- a/src/profile/forms/__snapshots__/SocialLinks.test.jsx.snap +++ b/src/profile/forms/__snapshots__/SocialLinks.test.jsx.snap @@ -1,586 +1,504 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` calls social links with edit mode bio 1`] = ` -
    +
    -
    -
    - -
    -
    -
      -
    • - - -
    • -
    • +
    +
    +
      - - - -
    -
    + + + +
  • + + +
  • +
    - - - - - - - Everyone on localhost - - - -
    -
    -
    +
    - - - - + + + + + Saving - - Saving - - - - + + +
    -
    -
    + +
    `; exports[` calls social links with edit mode certificates 1`] = ` -
    +
    -

    - Social Links - -

    -

    -

    - - - Just me - -

    -
    -
      -
    + + + Twitter + + + +
    `; exports[` calls social links with edit mode goals 1`] = ` -
    +
    -

    +

    + Social Links +

    +
    +
      - Social Links - +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    -
      +
    +`; + +exports[` calls social links with edit mode socialLinks 1`] = ` +
    +
    +
    -
  • -
    +

    + Social Links -

    -
  • -
  • -
    - -
    -
  • - -
    -
    -`; - -exports[` calls social links with edit mode socialLinks 1`] = ` -
    -
    -
    -

    +

    +

    +
      - Social Links - - -

      -

    • - - - Just me - -

      + + Twitter + +
    • +
    -
    `; diff --git a/src/setupTest.js b/src/setupTest.js index c94ae39b1..84cc8b354 100755 --- a/src/setupTest.js +++ b/src/setupTest.js @@ -1,7 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ import 'core-js/stable'; import 'regenerator-runtime/runtime'; - -import Enzyme from 'enzyme'; -import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; - -Enzyme.configure({ adapter: new Adapter() }); +import '@testing-library/jest-dom';