diff --git a/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.js b/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.js index 311b6241bbe..9efbba10fba 100644 --- a/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.js +++ b/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.js @@ -20,7 +20,7 @@ import { LivePreview } from 'react-live-replacement' // we use this replacement, because; -// to simply have newer prism version for the LiveEditor +// to simply have newer prism version for the LiveEditor - I made a pull request. // this theme is replaced my a css one // import prismTheme from 'prism-react-renderer/themes/nightOwl' @@ -124,7 +124,7 @@ class LiveCode extends PureComponent { (typeof window !== 'undefined' && !( window.location && - window.location.search.split(/\?|&/).includes('test') + window.location.search.split(/\?|&/).includes('data-dnb-test') )) ) { code = code.replace(/\s+data-dnb-test="[^"]*"/g, '') diff --git a/packages/dnb-ui-lib/jest-screenshot.json b/packages/dnb-ui-lib/jest-screenshot.json deleted file mode 100644 index 8a3e12bcca4..00000000000 --- a/packages/dnb-ui-lib/jest-screenshot.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "detectAntialiasing": true, - "pixelThresholdRelative": 0.1 -} diff --git a/packages/dnb-ui-lib/package.json b/packages/dnb-ui-lib/package.json index 92b376ed3ff..377dde45ce4 100644 --- a/packages/dnb-ui-lib/package.json +++ b/packages/dnb-ui-lib/package.json @@ -55,6 +55,7 @@ "test-ci-screenshots": "jest --config=./jest.config.screenshots.js --ci --forceExit --detectOpenHandles", "test:screenshots": "jest --config=./jest.config.screenshots.js --forceExit --detectOpenHandles", "test:screenshots:build": "yarn build && yarn workspace dnb-design-system-portal build-portal && yarn test:screenshots", + "test:screenshots:recreate": "find . -name '*.snap.png' -type f|xargs rm -f && yarn test:screenshots", "test:screenshots:update": "jest --config=./jest.config.screenshots.js --updateSnapshot --forceExit --detectOpenHandles", "test:staged": "jest --bail --findRelatedTests ", "test:update": "jest --updateSnapshot", @@ -147,6 +148,7 @@ "jest-css-modules": "^1.1.0", "jest-raw-loader": "^1.0.1", "jest-screenshot": "^0.2.1", + "jest-screenshot-replacement": "https://github.com/tujoworker/jest-screenshot/tarball/fcf8414704f02716931889fa0a2047e58cad8adb", "jest-tobetype": "^1.2.2", "lint-staged": "^8.1.3", "live-server": "^1.2.1", diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-1-8399a.snap.png b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-1-8399a.snap.png index a9a8793165d..e24653bb64c 100644 Binary files a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-1-8399a.snap.png and b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-1-8399a.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-active-state-1-d4f1f.snap.png b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-active-state-1-d4f1f.snap.png index bf78e420dd2..8cbe5268282 100644 Binary files a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-active-state-1-d4f1f.snap.png and b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-active-state-1-d4f1f.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-focus-state-1-a3c02.snap.png b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-focus-state-1-a3c02.snap.png index e41cd70aa47..4f16e9e9435 100644 Binary files a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-focus-state-1-a3c02.snap.png and b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-focus-state-1-a3c02.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-hover-state-1-a79c3.snap.png b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-hover-state-1-a79c3.snap.png index 29520309f92..2833f563bd9 100644 Binary files a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-hover-state-1-a79c3.snap.png and b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-primary-with-hover-state-1-a79c3.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-secondary-1-b265a.snap.png b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-secondary-1-b265a.snap.png index 9d92fc28c11..e123ac130f1 100644 Binary files a/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-secondary-1-b265a.snap.png and b/packages/dnb-ui-lib/src/components/button/__tests__/__snapshots__/button-screenshot-test-js-button-screenshot-have-to-match-dnb-button-secondary-1-b265a.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/step-indicator/__tests__/__snapshots__/step-indicator-screenshot-test-js-step-indicator-screenshot-have-to-match-1-f4719.snap.png b/packages/dnb-ui-lib/src/components/step-indicator/__tests__/__snapshots__/step-indicator-screenshot-test-js-step-indicator-screenshot-have-to-match-1-f4719.snap.png index d66dd7cf8d6..c0dba284c12 100644 Binary files a/packages/dnb-ui-lib/src/components/step-indicator/__tests__/__snapshots__/step-indicator-screenshot-test-js-step-indicator-screenshot-have-to-match-1-f4719.snap.png and b/packages/dnb-ui-lib/src/components/step-indicator/__tests__/__snapshots__/step-indicator-screenshot-test-js-step-indicator-screenshot-have-to-match-1-f4719.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tablist-1-5ff66.snap.png b/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tablist-1-5ff66.snap.png index b7eed111e04..61351fbecbf 100644 Binary files a/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tablist-1-5ff66.snap.png and b/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tablist-1-5ff66.snap.png differ diff --git a/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tabs-right-aligned-1-2b989.snap.png b/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tabs-right-aligned-1-2b989.snap.png index fdc5f2a28cb..0ced4455dce 100644 Binary files a/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tabs-right-aligned-1-2b989.snap.png and b/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/tabs-screenshot-test-js-tabs-screenshot-have-to-match-the-tabs-right-aligned-1-2b989.snap.png differ diff --git a/packages/dnb-ui-lib/src/core/jest/jestSetupScreenshots.js b/packages/dnb-ui-lib/src/core/jest/jestSetupScreenshots.js index 94d8b5d2238..dab8a47063b 100644 --- a/packages/dnb-ui-lib/src/core/jest/jestSetupScreenshots.js +++ b/packages/dnb-ui-lib/src/core/jest/jestSetupScreenshots.js @@ -69,6 +69,8 @@ module.exports.testPageScreenshot = ({ { id, style: makeStyles({ + 'font-family': 'Arial', + position: 'relative', 'z-index': 9999, @@ -170,13 +172,21 @@ module.exports.setupPageScreenshot = ({ timeout, url, ...rest } = {}) => { const context = await global.__BROWSER__.createIncognitoBrowserContext() const page = await context.newPage() - // await page._client.send('ServiceWorker.enable') - // await page._client.send('ServiceWorker.stopAllWorkers') - // await page._client.send('ServiceWorker.unregister', { - // scopeURL: `http://${testScreenshotOnHost}:${testScreenshotOnPort}` - // }) - await page.setViewport(pageSettings) + + await page.setRequestInterception(true) // is needed in order to use on "request" + page.on('request', req => { + const type = req.resourceType() + switch (type) { + case 'font': + req.abort() + break + + default: + req.continue() + } + }) + await page.goto(useUrl) global.__PAGE__ = page @@ -194,7 +204,7 @@ module.exports.loadImage = async imagePath => // make sure "${url}/" has actually a slash on the end const createUrl = url => - `http://${testScreenshotOnHost}:${testScreenshotOnPort}/${url}/?fullscreen&test`.replace( + `http://${testScreenshotOnHost}:${testScreenshotOnPort}/${url}/?data-dnb-test&fullscreen`.replace( /\/\//g, '/' ) diff --git a/packages/dnb-ui-lib/src/core/jest/setupJestScreenshot.js b/packages/dnb-ui-lib/src/core/jest/setupJestScreenshot.js index 3ae203be600..e6463f6523f 100644 --- a/packages/dnb-ui-lib/src/core/jest/setupJestScreenshot.js +++ b/packages/dnb-ui-lib/src/core/jest/setupJestScreenshot.js @@ -4,7 +4,9 @@ */ const isCI = require('is-ci') -const { setupJestScreenshot } = require('jest-screenshot') + +// we use a replace for now to get this feature of sending the config in here. I made a pull request. +const { setupJestScreenshot } = require('jest-screenshot-replacement') jest.setTimeout(30e3) diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-active-state-1-6b889.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-active-state-1-6b889.snap.png index ad7c2ae9ad5..24448194186 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-active-state-1-6b889.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-active-state-1-6b889.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-default-state-1-facec.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-default-state-1-facec.snap.png index ef1a8dbf7bf..306e5abaa2d 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-default-state-1-facec.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-default-state-1-facec.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-focus-state-1-4a878.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-focus-state-1-4a878.snap.png index 015e9a371e8..a0bfd3d8c44 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-focus-state-1-4a878.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-focus-state-1-4a878.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-hover-state-1-5fc43.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-hover-state-1-5fc43.snap.png index 21cfd7395de..d95a05d7837 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-hover-state-1-5fc43.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/anchor-screenshot-test-js-anchor-screenshot-have-to-match-the-hover-state-1-5fc43.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-blockquote-with-top-aligned-graphic-1-c67e6.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-blockquote-with-top-aligned-graphic-1-c67e6.snap.png index e489799ca2f..7c610233723 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-blockquote-with-top-aligned-graphic-1-c67e6.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-blockquote-with-top-aligned-graphic-1-c67e6.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-defualt-blockquote-1-a99a0.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-defualt-blockquote-1-a99a0.snap.png index 583fbaa4450..ad443a1c572 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-defualt-blockquote-1-a99a0.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/blockquote-screenshot-test-js-blockquote-screenshot-have-to-match-defualt-blockquote-1-a99a0.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/table-screenshot-test-js-table-screenshot-have-to-match-the-default-choice-of-table-styles-1-b0b7d.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/table-screenshot-test-js-table-screenshot-have-to-match-the-default-choice-of-table-styles-1-b0b7d.snap.png index 5154ddaf8a5..4b9b48c52ff 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/table-screenshot-test-js-table-screenshot-have-to-match-the-default-choice-of-table-styles-1-b0b7d.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/table-screenshot-test-js-table-screenshot-have-to-match-the-default-choice-of-table-styles-1-b0b7d.snap.png differ diff --git a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/textarea-screenshot-test-js-textarea-screenshot-have-to-match-the-default-textarea-style-1-2ef6c.snap.png b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/textarea-screenshot-test-js-textarea-screenshot-have-to-match-the-default-textarea-style-1-2ef6c.snap.png index 76983b0dc07..3b7516c6ae5 100644 Binary files a/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/textarea-screenshot-test-js-textarea-screenshot-have-to-match-the-default-textarea-style-1-2ef6c.snap.png and b/packages/dnb-ui-lib/src/style/elements/__tests__/__snapshots__/textarea-screenshot-test-js-textarea-screenshot-have-to-match-the-default-textarea-style-1-2ef6c.snap.png differ diff --git a/yarn.lock b/yarn.lock index d3114262aa9..72e89579206 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11645,6 +11645,16 @@ jest-runtime@^24.1.0: write-file-atomic "2.4.1" yargs "^12.0.2" +"jest-screenshot-replacement@https://github.com/tujoworker/jest-screenshot/tarball/fcf8414704f02716931889fa0a2047e58cad8adb": + version "0.2.0" + resolved "https://github.com/tujoworker/jest-screenshot/tarball/fcf8414704f02716931889fa0a2047e58cad8adb#512c6c4a8544f0b24c15bccc651466f20fec5341" + dependencies: + chalk "^2.3.2" + lodash.kebabcase "^4.1.1" + mkdirp "^0.5.1" + native-image-diff "^0.1.1" + node-libpng "^0.2.0" + jest-screenshot@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/jest-screenshot/-/jest-screenshot-0.2.1.tgz#d3141805a61c7967d890135a3e5247aebc1f6d15" @@ -13698,7 +13708,7 @@ napi-build-utils@^1.0.1: resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.1.tgz#1381a0f92c39d66bf19852e7873432fc2123e508" integrity sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA== -native-image-diff@^0.1.7: +native-image-diff@^0.1.1, native-image-diff@^0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/native-image-diff/-/native-image-diff-0.1.8.tgz#69ffd363603c106347643504556a766b2928625b" integrity sha512-Hbdj4VIOGw2+UwBG8E9juaOQM8e/P3wqhJISsX2CK18j5LqlyKTC01oZgQKtbAooBr05wtag7jfQlYF8QV3Edg== @@ -13858,7 +13868,7 @@ node-int64@^0.4.0: resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs= -node-libpng@^0.2.6: +node-libpng@^0.2.0, node-libpng@^0.2.6: version "0.2.7" resolved "https://registry.yarnpkg.com/node-libpng/-/node-libpng-0.2.7.tgz#f69cf1eb6fb7d8c5005dc12e072b35447a194bff" integrity sha512-A8ct3JfKQUFMI338l6N/58VYCRapM4/HR6tVjXyk/hKATC3Y1kQ9g3k2SxBg7nSJeJRNw+yXnUHwRSQeWbuCjA==