diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7d8b327a0..c16eb3c4a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,10 +47,8 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/setup_modules - uses: ./.github/actions/build_cache_read - - name: Tests without snapshots - run: yarn test:noSnapshots - - name: Tests snapshots - run: yarn test:snapshots + - name: Tests + run: yarn test - name: BundleMon uses: lironer/bundlemon-action@v1 argosDesktop: diff --git a/package.json b/package.json index 0a905c6b2..6d06f7a76 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,6 @@ "sprite": "scripts/make-icon-sprite.sh", "screenshots": "node scripts/screenshots.js --screenshot-dir ./screenshots --styleguide-url file://$(pwd)/build/react --kss-dir ./build/styleguide", "test": "jest", - "test:noSnapshots": "jest --testPathIgnorePatterns 'react/examples.spec.jsx'", - "test:snapshots": "jest react/examples.spec.jsx", "screenshots:server": "nodemon ./scripts/pixelmatch-server/server.js -e js,hbs", "postbuild": "postcss transpiled/react/stylesheet.css --replace", "travis-deploy-once": "travis-deploy-once", @@ -131,7 +129,6 @@ "postcss-cli": "6.1.3", "postcss-loader": "2.1.6", "prettier": "2.6.0", - "pretty": "2.0.0", "prop-types": "15.7.2", "react": "16.12.0", "react-dom": "16.12.0", diff --git a/react/examples.spec.jsx b/react/examples.spec.jsx deleted file mode 100644 index 136193d10..000000000 --- a/react/examples.spec.jsx +++ /dev/null @@ -1,67 +0,0 @@ -import path from 'path' - -import testFromStyleguidist from '../test/testFromStyleguidist' - -// Popper does not work well inside of jest as it heavily relies on DOM APIs (see https://github.com/popperjs/popper-core/issues/478). -jest.mock('@material-ui/core/Popper', () => { - return ({ children }) => children -}) - -const makeRequire = subpath => m => { - if (m.indexOf('.') === 0) { - return require('./' + path.join(subpath, m)) - } else { - return require(m) - } -} - -const testComponent = (ComponentName, options) => { - testFromStyleguidist( - ComponentName, - path.join(__dirname, ComponentName, 'Readme.md'), - makeRequire(ComponentName), - options - ) -} - -// Please keep the list sorted -testComponent('Alert') -testComponent('AppTitle') -testComponent('Avatar') -testComponent('Badge') -testComponent('Banner') -testComponent('BarButton') -testComponent('Buttons') -testComponent('Card') -testComponent('Checkbox') -testComponent('Chips') -testComponent('ContactsList') -testComponent('ContactsListModal') -testComponent('DateMonthPicker') -testComponent('DropdownText') -testComponent('Dialog') // Prints error: Functions are not valid as a React child -testComponent('Empty') -// testComponent('Field') // fuzzy test, need to investigate why -testComponent('Hero') -testComponent('HistoryRow') -// testComponent('Icon') // fuzzy test, need to investigate why -// testComponent('IconButton') // fuzzy test, need to investigate why -testComponent('IconStack') -testComponent('InputGroup') -testComponent('Label') -testComponent('Labs/CollectionField') -testComponent('ListItemText') -testComponent('OrderedList') -testComponent('Paper') -testComponent('PasswordExample') -testComponent('PieChart') -testComponent('Progress') -testComponent('ProgressionBanner') -testComponent('Radios') -testComponent('SelectBox') -testComponent('Sidebar') -testComponent('Spinner') -testComponent('Switch') -testComponent('Textarea') -testComponent('UnorderedList') -testComponent('Wizard') diff --git a/test/testFromStyleguidist.js b/test/testFromStyleguidist.js deleted file mode 100644 index ec58f30bc..000000000 --- a/test/testFromStyleguidist.js +++ /dev/null @@ -1,85 +0,0 @@ -import React from 'react' -import fs from 'fs' -import pretty from 'pretty' -import Preview from 'react-styleguidist/lib/client/rsg-components/Preview' -import Context from 'react-styleguidist/lib/client/rsg-components/Context' -import chunkify from 'react-styleguidist/lib/loaders/utils/chunkify' - -import * as content from '../docs/fixtures/content' - -const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) - -const testFromStyleguidist = ( - name, - markdown, - require, - { delay } = { delay: 0 } -) => { - const evalInContext = a => - // eslint-disable-next-line no-new-func - new Function( - 'require', - 'content', - 'isTesting', - 'state', - 'setState', - `const React = require("react"); - ` + a - ).bind(null, require, content, () => true) - - const context = { - config: { - compilerConfig: { - objectAssign: 'Object.assign', - target: { ie: 11 }, - transforms: { - modules: false, - dangerousTaggedTemplateString: true, - asyncAwait: false - } - } - }, - codeRevision: 1337 - } - const Provider = props => - - // TouchRipples can cause flaky tests - const touchRippleRx = /<\/span>/g - const removeTouchRipples = html => { - return html.replace(touchRippleRx, '') - } - - describe(name, () => { - it('should render examples', done => { - let doneCounter = 0 - const Readme = fs.readFileSync(markdown) - const chunks = chunkify(Readme) - const codes = chunks.filter(x => x.type === 'code') - const rendered = [] - const finish = () => { - rendered.forEach(rendered => { - expect(rendered).toMatchSnapshot(name) - }) - done() - } - codes.forEach(async code => { - const root = mount( - - - - ) - await sleep(delay) // some components (like the ActionMenu) are flaky due to external libs - requestAnimationFrame(async () => { - await root.update() - rendered.push(pretty(removeTouchRipples(root.html()))) - doneCounter++ - if (doneCounter === codes.length) { - finish() - } - }) - }) - }) - }) -} - -export default testFromStyleguidist diff --git a/yarn.lock b/yarn.lock index a8066f357..cc901006e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5700,15 +5700,6 @@ concat-stream@^2.0.0: readable-stream "^3.0.2" typedarray "^0.0.6" -condense-newlines@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/condense-newlines/-/condense-newlines-0.2.1.tgz#3de985553139475d32502c83b02f60684d24c55f" - integrity sha1-PemFVTE5R10yUCyDsC9gaE0kxV8= - dependencies: - extend-shallow "^2.0.1" - is-whitespace "^0.3.0" - kind-of "^3.0.2" - config-chain@^1.1.11: version "1.1.13" resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4" @@ -5717,14 +5708,6 @@ config-chain@^1.1.11: ini "^1.3.4" proto-list "~1.2.1" -config-chain@^1.1.12: - version "1.1.12" - resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa" - integrity sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA== - dependencies: - ini "^1.3.4" - proto-list "~1.2.1" - configstore@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.2.tgz#c6f25defaeef26df12dd33414b001fe81a543f8f" @@ -7116,16 +7099,6 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -editorconfig@^0.15.3: - version "0.15.3" - resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5" - integrity sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g== - dependencies: - commander "^2.19.0" - lru-cache "^4.1.5" - semver "^5.6.0" - sigmund "^1.0.1" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -10828,11 +10801,6 @@ is-whitespace-character@^1.0.0: resolved "https://registry.yarnpkg.com/is-whitespace-character/-/is-whitespace-character-1.0.2.tgz#ede53b4c6f6fb3874533751ec9280d01928d03ed" integrity sha512-SzM+T5GKUCtLhlHFKt2SDAX2RFzfS6joT91F2/WSi9LxgFdsnhfPK/UIA+JhRR2xuyLdrCys2PiFDrtn1fU5hQ== -is-whitespace@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/is-whitespace/-/is-whitespace-0.3.0.tgz#1639ecb1be036aec69a54cbb401cfbed7114ab7f" - integrity sha1-Fjnssb4DauxppUy7QBz77XEUq38= - is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -11386,17 +11354,6 @@ js-base64@^2.1.9: resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.1.tgz#1efa39ef2c5f7980bb1784ade4a8af2de3291121" integrity sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw== -js-beautify@^1.6.12: - version "1.10.0" - resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.10.0.tgz#9753a13c858d96828658cd18ae3ca0e5783ea672" - integrity sha512-OMwf/tPDpE/BLlYKqZOhqWsd3/z2N3KOlyn1wsCRGFwViE8LOQTcDtathQvHvZc+q+zWmcNAbwKSC+iJoMaH2Q== - dependencies: - config-chain "^1.1.12" - editorconfig "^0.15.3" - glob "^7.1.3" - mkdirp "~0.5.1" - nopt "~4.0.1" - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -12433,7 +12390,7 @@ lowercase-keys@^3.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2" integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== -lru-cache@^4.0.1, lru-cache@^4.1.5: +lru-cache@^4.0.1: version "4.1.5" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== @@ -13537,7 +13494,7 @@ noms@0.0.0: inherits "^2.0.1" readable-stream "~1.0.31" -nopt@^4.0.1, nopt@~4.0.1: +nopt@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" integrity sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg== @@ -15640,15 +15597,6 @@ pretty-hrtime@^1.0.3: resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= -pretty@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/pretty/-/pretty-2.0.0.tgz#adbc7960b7bbfe289a557dc5f737619a220d06a5" - integrity sha1-rbx5YLe7/iiaVX3F9zdhmiINBqU= - dependencies: - condense-newlines "^0.2.1" - extend-shallow "^2.0.1" - js-beautify "^1.6.12" - prismjs@^1.17.1: version "1.29.0" resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12" @@ -17917,11 +17865,6 @@ sift@^6.0.0: resolved "https://registry.yarnpkg.com/sift/-/sift-6.0.0.tgz#f93a778e5cbf05a5024ebc391e6b32511a6d1f82" integrity sha1-+Tp3jly/BaUCTrw5HmsyURptH4I= -sigmund@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" - integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA= - signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"