Upgrade Cypress dependency

This gets rid of the testing-library-* and cypress-vite-devserver
dependencies and updates the specs according to the latest Cypress
documentation.

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-09-26 16:34:30 +02:00
parent ff267620a6
commit 9b8a9a46dd
16 changed files with 245 additions and 684 deletions
-33
View File
@@ -1,33 +0,0 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { defineConfig } = require("cypress");
const { startDevServer } = require('@cypress/vite-dev-server');
module.exports = defineConfig({
video: false,
defaultCommandTimeout: 10000,
e2e: {
setupNodeEvents(on, config) {
return require('@cypress/code-coverage/task')(on, config);
},
specPattern: 'cypress/e2e/**/*spec.ts',
baseUrl: 'http://localhost:3000',
},
component: {
devServer({ config, specs, devServerEvents }) {
return startDevServer({
options: {
config,
specs,
devServerEvents,
},
viteConfig: {
configFile: "./vite.config.ts",
logLevel: "silent"
},
});
},
specPattern: 'src/**/*spec.ts',
indexHtmlFile: './index.html'
},
});
+17
View File
@@ -0,0 +1,17 @@
import { defineConfig } from "cypress";
export default defineConfig({
video: false,
defaultCommandTimeout: 10000,
e2e: {
specPattern: "cypress/e2e/**/*spec.ts",
baseUrl: "http://localhost:3000",
},
component: {
devServer: {
framework: "svelte",
bundler: "vite",
},
specPattern: "src/**/*spec.ts",
},
});
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="/typography.css" />
<link rel="stylesheet" type="text/css" href="/colors.css" />
<link rel="stylesheet" type="text/css" href="/elevations.css" />
<link rel="stylesheet" type="text/css" href="/index.css" />
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
+12 -1
View File
@@ -1,5 +1,16 @@
import "@testing-library/cypress/add-commands";
import { mount } from "cypress/svelte";
import { Buffer } from "buffer";
//@ts-expect-error We need Buffer on the window object in the test env for component testing
window.Buffer = Buffer;
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
mount: typeof mount;
}
}
}
Cypress.Commands.add("mount", mount);
-1
View File
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import "@cypress/code-coverage/support";
import "@testing-library/cypress/add-commands";
declare global {
interface Window {
+21 -492
View File
@@ -44,11 +44,8 @@
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@cypress/vite-dev-server": "^2.2.2",
"@rsksmart/mock-web3-provider": "^1.0.1",
"@sveltejs/vite-plugin-svelte": "^1.0.1",
"@testing-library/cypress": "^8.0.3",
"@testing-library/svelte": "^3.1.0",
"@tsconfig/svelte": "^1.0.13",
"@types/connect-history-api-fallback": "^1.3.5",
"@types/express-serve-static-core": "^4.17.30",
@@ -56,7 +53,7 @@
"@types/sanitize-html": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"cypress": "^10.3.0",
"cypress": "^10.8.0",
"eslint": "^7.28.0",
"eslint-plugin-radicle": "^0.2.0",
"eslint-plugin-svelte3": "^3.2.0",
@@ -1726,6 +1723,7 @@
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.7.tgz",
"integrity": "sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==",
"dev": true,
"peer": true,
"dependencies": {
"regenerator-runtime": "^0.13.4"
},
@@ -1733,19 +1731,6 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/runtime-corejs3": {
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.8.tgz",
"integrity": "sha512-ZbYSUvoSF6dXZmMl/CYTMOvzIFnbGfv4W3SEHYgMvNsFTeLaF2gkGAF4K2ddmtSK4Emej+0aYcnSC6N5dPCXUQ==",
"dev": true,
"dependencies": {
"core-js-pure": "^3.20.2",
"regenerator-runtime": "^0.13.4"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/template": {
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz",
@@ -1952,19 +1937,6 @@
"node": ">= 6"
}
},
"node_modules/@cypress/vite-dev-server": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/@cypress/vite-dev-server/-/vite-dev-server-2.2.2.tgz",
"integrity": "sha512-02y/Fm0N+CQjKbSjjRtktPgPbp91kOvtc8+WW2l2odIYQkKlG6IOCpmgc898muW0lBAcCszdEIHR/ItdZDiYPw==",
"dev": true,
"dependencies": {
"debug": "^4.3.2",
"get-port": "^5.1.1"
},
"peerDependencies": {
"vite": ">= 2.1.3"
}
},
"node_modules/@cypress/webpack-preprocessor": {
"version": "5.12.0",
"resolved": "https://registry.npmjs.org/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.12.0.tgz",
@@ -2972,22 +2944,6 @@
"node": ">=8"
}
},
"node_modules/@jest/types": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz",
"integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==",
"dev": true,
"dependencies": {
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
"@types/yargs": "^15.0.0",
"chalk": "^4.0.0"
},
"engines": {
"node": ">= 10.14.2"
}
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz",
@@ -3389,116 +3345,12 @@
"node": ">=12"
}
},
"node_modules/@testing-library/cypress": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/@testing-library/cypress/-/cypress-8.0.3.tgz",
"integrity": "sha512-nY2YaSbmuPo5k6kL0iLj/pGPPfka3iwb3kpTx8QN/vOCns92Saz9wfACqB8FJzcR7+lfA4d5HUOWqmTddBzczg==",
"dev": true,
"dependencies": {
"@babel/runtime": "^7.14.6",
"@testing-library/dom": "^8.1.0"
},
"engines": {
"node": ">=12",
"npm": ">=6"
},
"peerDependencies": {
"cypress": "^2.1.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0"
}
},
"node_modules/@testing-library/dom": {
"version": "8.11.3",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.11.3.tgz",
"integrity": "sha512-9LId28I+lx70wUiZjLvi1DB/WT2zGOxUh46glrSNMaWVx849kKAluezVzZrXJfTKKoQTmEOutLes/bHg4Bj3aA==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^4.2.0",
"aria-query": "^5.0.0",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9",
"lz-string": "^1.4.4",
"pretty-format": "^27.0.2"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@testing-library/svelte": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@testing-library/svelte/-/svelte-3.1.0.tgz",
"integrity": "sha512-xTN6v4xRLQb75GTJn2mrjSUJN4PkhpNZFjwvtdzbOTS6OvxMrkRdm6hFRGauwiFd0LPV7/SqdWbbtMAOC7a+Dg==",
"dev": true,
"dependencies": {
"@testing-library/dom": "^7.0.3"
},
"engines": {
"node": ">= 8"
},
"peerDependencies": {
"svelte": "3.x"
}
},
"node_modules/@testing-library/svelte/node_modules/@testing-library/dom": {
"version": "7.31.2",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-7.31.2.tgz",
"integrity": "sha512-3UqjCpey6HiTZT92vODYLPxTBWlM8ZOOjr3LX5F37/VRipW2M1kX6I/Cm4VXzteZqfGfagg8yXywpcOgQBlNsQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^4.2.0",
"aria-query": "^4.2.2",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.6",
"lz-string": "^1.4.4",
"pretty-format": "^26.6.2"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@testing-library/svelte/node_modules/aria-query": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz",
"integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==",
"dev": true,
"dependencies": {
"@babel/runtime": "^7.10.2",
"@babel/runtime-corejs3": "^7.10.2"
},
"engines": {
"node": ">=6.0"
}
},
"node_modules/@testing-library/svelte/node_modules/pretty-format": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz",
"integrity": "sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==",
"dev": true,
"dependencies": {
"@jest/types": "^26.6.2",
"ansi-regex": "^5.0.0",
"ansi-styles": "^4.0.0",
"react-is": "^17.0.1"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/@tsconfig/svelte": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-1.0.13.tgz",
"integrity": "sha512-5lYJP45Xllo4yE/RUBccBT32eBlRDbqN8r1/MIvQbKxW3aFqaYPCNgm8D5V20X4ShHcwvYWNlKg3liDh1MlBoA==",
"dev": true
},
"node_modules/@types/aria-query": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz",
"integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==",
"dev": true
},
"node_modules/@types/bn.js": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz",
@@ -3590,30 +3442,6 @@
"@types/node": "*"
}
},
"node_modules/@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
"integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==",
"dev": true
},
"node_modules/@types/istanbul-lib-report": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz",
"integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==",
"dev": true,
"dependencies": {
"@types/istanbul-lib-coverage": "*"
}
},
"node_modules/@types/istanbul-reports": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz",
"integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==",
"dev": true,
"dependencies": {
"@types/istanbul-lib-report": "*"
}
},
"node_modules/@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@@ -3703,21 +3531,6 @@
"integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==",
"dev": true
},
"node_modules/@types/yargs": {
"version": "15.0.14",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.14.tgz",
"integrity": "sha512-yEJzHoxf6SyQGhBhIYGXQDSCkJjB6HohDShto7m8vaKg9Yp0Yn8+71J9eakh2bnPg6BfsH9PRMhiRTZnd4eXGQ==",
"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",
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==",
"dev": true
},
"node_modules/@types/yauzl": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz",
@@ -4540,15 +4353,6 @@
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
},
"node_modules/aria-query": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz",
"integrity": "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==",
"dev": true,
"engines": {
"node": ">=6.0"
}
},
"node_modules/array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
@@ -5483,17 +5287,6 @@
"semver": "bin/semver.js"
}
},
"node_modules/core-js-pure": {
"version": "3.21.1",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.21.1.tgz",
"integrity": "sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ==",
"dev": true,
"hasInstallScript": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
@@ -5567,9 +5360,9 @@
"integrity": "sha512-FAaLDaplstoRsDR8XGYH51znUN0UY7nMc6Z9/fvE8EXGwvJE9hu7W2vHwx1+bd6gCYnln9nLbzxFTrcO9YQDZw=="
},
"node_modules/cypress": {
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.3.0.tgz",
"integrity": "sha512-txkQWKzvBVnWdCuKs5Xc08gjpO89W2Dom2wpZgT9zWZT5jXxqPIxqP/NC1YArtkpmp3fN5HW8aDjYBizHLUFvg==",
"version": "10.8.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.8.0.tgz",
"integrity": "sha512-QVse0dnLm018hgti2enKMVZR9qbIO488YGX06nH5j3Dg1isL38DwrBtyrax02CANU6y8F4EJUuyW6HJKw1jsFA==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
@@ -5592,7 +5385,7 @@
"dayjs": "^1.10.4",
"debug": "^4.3.2",
"enquirer": "^2.3.6",
"eventemitter2": "^6.4.3",
"eventemitter2": "6.4.7",
"execa": "4.1.0",
"executable": "^4.1.1",
"extract-zip": "2.0.1",
@@ -5916,12 +5709,6 @@
"node": ">=6.0.0"
}
},
"node_modules/dom-accessibility-api": {
"version": "0.5.11",
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.11.tgz",
"integrity": "sha512-7X6GvzjYf4yTdRKuCVScV+aA9Fvh5r8WzWrXBH9w82ZWB/eYDMGCnazoC/YAqAzUJWHzLOnZqr46K3iEyUhUvw==",
"dev": true
},
"node_modules/dom-serializer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
@@ -7017,9 +6804,9 @@
}
},
"node_modules/eventemitter2": {
"version": "6.4.5",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.5.tgz",
"integrity": "sha512-bXE7Dyc1i6oQElDG0jMRZJrRAn9QR2xyyFGmBdZleNmyQX0FqGYmhZIrIrpPfm/w//LTo4tVQGOGQcGCb5q9uw==",
"version": "6.4.7",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz",
"integrity": "sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==",
"dev": true
},
"node_modules/eventemitter3": {
@@ -7476,18 +7263,6 @@
"node": ">=8.0.0"
}
},
"node_modules/get-port": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz",
"integrity": "sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==",
"dev": true,
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/get-stream": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
@@ -8725,15 +8500,6 @@
"node": ">=12"
}
},
"node_modules/lz-string": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz",
"integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=",
"dev": true,
"bin": {
"lz-string": "bin/bin.js"
}
},
"node_modules/magic-string": {
"version": "0.25.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
@@ -9539,32 +9305,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/pretty-format": {
"version": "27.4.6",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.4.6.tgz",
"integrity": "sha512-NblstegA1y/RJW2VyML+3LlpFjzx62cUrtBIKIWDXEDkjNeleA7Od7nrzcs/VLQvAeV4CgSYhrN39DRN88Qi/g==",
"dev": true,
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"react-is": "^17.0.1"
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
}
},
"node_modules/pretty-format/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/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -9885,12 +9625,6 @@
"safe-buffer": "^5.1.0"
}
},
"node_modules/react-is": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true
},
"node_modules/readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
@@ -9963,7 +9697,8 @@
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz",
"integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==",
"dev": true
"dev": true,
"peer": true
},
"node_modules/regenerator-transform": {
"version": "0.15.0",
@@ -13123,20 +12858,11 @@
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.7.tgz",
"integrity": "sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==",
"dev": true,
"peer": true,
"requires": {
"regenerator-runtime": "^0.13.4"
}
},
"@babel/runtime-corejs3": {
"version": "7.17.8",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.17.8.tgz",
"integrity": "sha512-ZbYSUvoSF6dXZmMl/CYTMOvzIFnbGfv4W3SEHYgMvNsFTeLaF2gkGAF4K2ddmtSK4Emej+0aYcnSC6N5dPCXUQ==",
"dev": true,
"requires": {
"core-js-pure": "^3.20.2",
"regenerator-runtime": "^0.13.4"
}
},
"@babel/template": {
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz",
@@ -13329,16 +13055,6 @@
"uuid": "^8.3.2"
}
},
"@cypress/vite-dev-server": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/@cypress/vite-dev-server/-/vite-dev-server-2.2.2.tgz",
"integrity": "sha512-02y/Fm0N+CQjKbSjjRtktPgPbp91kOvtc8+WW2l2odIYQkKlG6IOCpmgc898muW0lBAcCszdEIHR/ItdZDiYPw==",
"dev": true,
"requires": {
"debug": "^4.3.2",
"get-port": "^5.1.1"
}
},
"@cypress/webpack-preprocessor": {
"version": "5.12.0",
"resolved": "https://registry.npmjs.org/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.12.0.tgz",
@@ -13987,19 +13703,6 @@
"integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==",
"dev": true
},
"@jest/types": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz",
"integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==",
"dev": true,
"requires": {
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
"@types/yargs": "^15.0.0",
"chalk": "^4.0.0"
}
},
"@jridgewell/gen-mapping": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz",
@@ -14356,93 +14059,12 @@
}
}
},
"@testing-library/cypress": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/@testing-library/cypress/-/cypress-8.0.3.tgz",
"integrity": "sha512-nY2YaSbmuPo5k6kL0iLj/pGPPfka3iwb3kpTx8QN/vOCns92Saz9wfACqB8FJzcR7+lfA4d5HUOWqmTddBzczg==",
"dev": true,
"requires": {
"@babel/runtime": "^7.14.6",
"@testing-library/dom": "^8.1.0"
}
},
"@testing-library/dom": {
"version": "8.11.3",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.11.3.tgz",
"integrity": "sha512-9LId28I+lx70wUiZjLvi1DB/WT2zGOxUh46glrSNMaWVx849kKAluezVzZrXJfTKKoQTmEOutLes/bHg4Bj3aA==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^4.2.0",
"aria-query": "^5.0.0",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9",
"lz-string": "^1.4.4",
"pretty-format": "^27.0.2"
}
},
"@testing-library/svelte": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@testing-library/svelte/-/svelte-3.1.0.tgz",
"integrity": "sha512-xTN6v4xRLQb75GTJn2mrjSUJN4PkhpNZFjwvtdzbOTS6OvxMrkRdm6hFRGauwiFd0LPV7/SqdWbbtMAOC7a+Dg==",
"dev": true,
"requires": {
"@testing-library/dom": "^7.0.3"
},
"dependencies": {
"@testing-library/dom": {
"version": "7.31.2",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-7.31.2.tgz",
"integrity": "sha512-3UqjCpey6HiTZT92vODYLPxTBWlM8ZOOjr3LX5F37/VRipW2M1kX6I/Cm4VXzteZqfGfagg8yXywpcOgQBlNsQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^4.2.0",
"aria-query": "^4.2.2",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.6",
"lz-string": "^1.4.4",
"pretty-format": "^26.6.2"
}
},
"aria-query": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz",
"integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==",
"dev": true,
"requires": {
"@babel/runtime": "^7.10.2",
"@babel/runtime-corejs3": "^7.10.2"
}
},
"pretty-format": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz",
"integrity": "sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==",
"dev": true,
"requires": {
"@jest/types": "^26.6.2",
"ansi-regex": "^5.0.0",
"ansi-styles": "^4.0.0",
"react-is": "^17.0.1"
}
}
}
},
"@tsconfig/svelte": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-1.0.13.tgz",
"integrity": "sha512-5lYJP45Xllo4yE/RUBccBT32eBlRDbqN8r1/MIvQbKxW3aFqaYPCNgm8D5V20X4ShHcwvYWNlKg3liDh1MlBoA==",
"dev": true
},
"@types/aria-query": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz",
"integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==",
"dev": true
},
"@types/bn.js": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz",
@@ -14534,30 +14156,6 @@
"@types/node": "*"
}
},
"@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
"integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==",
"dev": true
},
"@types/istanbul-lib-report": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz",
"integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==",
"dev": true,
"requires": {
"@types/istanbul-lib-coverage": "*"
}
},
"@types/istanbul-reports": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz",
"integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==",
"dev": true,
"requires": {
"@types/istanbul-lib-report": "*"
}
},
"@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@@ -14647,21 +14245,6 @@
"integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==",
"dev": true
},
"@types/yargs": {
"version": "15.0.14",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.14.tgz",
"integrity": "sha512-yEJzHoxf6SyQGhBhIYGXQDSCkJjB6HohDShto7m8vaKg9Yp0Yn8+71J9eakh2bnPg6BfsH9PRMhiRTZnd4eXGQ==",
"dev": true,
"requires": {
"@types/yargs-parser": "*"
}
},
"@types/yargs-parser": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz",
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==",
"dev": true
},
"@types/yauzl": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz",
@@ -15313,12 +14896,6 @@
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
},
"aria-query": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz",
"integrity": "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==",
"dev": true
},
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
@@ -16032,12 +15609,6 @@
}
}
},
"core-js-pure": {
"version": "3.21.1",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.21.1.tgz",
"integrity": "sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ==",
"dev": true
},
"core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
@@ -16105,9 +15676,9 @@
"integrity": "sha512-FAaLDaplstoRsDR8XGYH51znUN0UY7nMc6Z9/fvE8EXGwvJE9hu7W2vHwx1+bd6gCYnln9nLbzxFTrcO9YQDZw=="
},
"cypress": {
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.3.0.tgz",
"integrity": "sha512-txkQWKzvBVnWdCuKs5Xc08gjpO89W2Dom2wpZgT9zWZT5jXxqPIxqP/NC1YArtkpmp3fN5HW8aDjYBizHLUFvg==",
"version": "10.8.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.8.0.tgz",
"integrity": "sha512-QVse0dnLm018hgti2enKMVZR9qbIO488YGX06nH5j3Dg1isL38DwrBtyrax02CANU6y8F4EJUuyW6HJKw1jsFA==",
"dev": true,
"requires": {
"@cypress/request": "^2.88.10",
@@ -16129,7 +15700,7 @@
"dayjs": "^1.10.4",
"debug": "^4.3.2",
"enquirer": "^2.3.6",
"eventemitter2": "^6.4.3",
"eventemitter2": "6.4.7",
"execa": "4.1.0",
"executable": "^4.1.1",
"extract-zip": "2.0.1",
@@ -16378,12 +15949,6 @@
"esutils": "^2.0.2"
}
},
"dom-accessibility-api": {
"version": "0.5.11",
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.11.tgz",
"integrity": "sha512-7X6GvzjYf4yTdRKuCVScV+aA9Fvh5r8WzWrXBH9w82ZWB/eYDMGCnazoC/YAqAzUJWHzLOnZqr46K3iEyUhUvw==",
"dev": true
},
"dom-serializer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz",
@@ -17147,9 +16712,9 @@
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
},
"eventemitter2": {
"version": "6.4.5",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.5.tgz",
"integrity": "sha512-bXE7Dyc1i6oQElDG0jMRZJrRAn9QR2xyyFGmBdZleNmyQX0FqGYmhZIrIrpPfm/w//LTo4tVQGOGQcGCb5q9uw==",
"version": "6.4.7",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz",
"integrity": "sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==",
"dev": true
},
"eventemitter3": {
@@ -17483,12 +17048,6 @@
"integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==",
"dev": true
},
"get-port": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz",
"integrity": "sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==",
"dev": true
},
"get-stream": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
@@ -18435,12 +17994,6 @@
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.13.2.tgz",
"integrity": "sha512-VJL3nIpA79TodY/ctmZEfhASgqekbT574/c4j3jn4bKXbSCnTTCH/KltZyvL2GlV+tGSMtsWyem8DCX7qKTMBA=="
},
"lz-string": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz",
"integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=",
"dev": true
},
"magic-string": {
"version": "0.25.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
@@ -19042,25 +18595,6 @@
"integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==",
"dev": true
},
"pretty-format": {
"version": "27.4.6",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.4.6.tgz",
"integrity": "sha512-NblstegA1y/RJW2VyML+3LlpFjzx62cUrtBIKIWDXEDkjNeleA7Od7nrzcs/VLQvAeV4CgSYhrN39DRN88Qi/g==",
"dev": true,
"requires": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"react-is": "^17.0.1"
},
"dependencies": {
"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
}
}
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -19304,12 +18838,6 @@
"safe-buffer": "^5.1.0"
}
},
"react-is": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true
},
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
@@ -19378,7 +18906,8 @@
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz",
"integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==",
"dev": true
"dev": true,
"peer": true
},
"regenerator-transform": {
"version": "0.15.0",
+1 -4
View File
@@ -18,11 +18,8 @@
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@cypress/vite-dev-server": "^2.2.2",
"@rsksmart/mock-web3-provider": "^1.0.1",
"@sveltejs/vite-plugin-svelte": "^1.0.1",
"@testing-library/cypress": "^8.0.3",
"@testing-library/svelte": "^3.1.0",
"@tsconfig/svelte": "^1.0.13",
"@types/connect-history-api-fallback": "^1.3.5",
"@types/express-serve-static-core": "^4.17.30",
@@ -30,7 +27,7 @@
"@types/sanitize-html": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"cypress": "^10.3.0",
"cypress": "^10.8.0",
"eslint": "^7.28.0",
"eslint-plugin-radicle": "^0.2.0",
"eslint-plugin-svelte3": "^3.2.0",
+58 -43
View File
@@ -1,56 +1,71 @@
import BlockTimer from "./BlockTimer.svelte";
import { render } from "@testing-library/svelte";
import "@public/index.css";
import type { EventType, Listener } from "@ethersproject/abstract-provider";
describe("BlockTimer", () => {
it("increases correctly the loading bar", () => {
let block = 1;
const props = {
config: {
provider: {
on: (event: EventType, listener: Listener) => {
if (event === "block") {
listener(block);
}
},
describe("when latestBlock === startBlock", () => {
it("shows 0% progress", () => {
cy.mount(BlockTimer, {
props: {
latestBlock: 1,
startBlock: 1,
duration: 3,
},
},
startBlock: 1,
duration: 3,
};
const { rerender } = render(BlockTimer, props);
cy.get("div.loader")
.should("have.attr", "style", "width: 0%;")
.then(() => {
block += 1;
rerender(props);
});
cy.get("div.loader")
.last()
.should("have.attr", "style", "width: 33%;")
.then(() => {
block += 1;
rerender(props);
cy.get(".progress-bar").should("have.attr", "style", "width: 0%;");
});
});
describe("when latestBlock < duration + startBlock", () => {
it("shows 33% progress", () => {
cy.mount(BlockTimer, {
props: {
latestBlock: 2,
startBlock: 1,
duration: 3,
},
});
cy.get("div.loader")
.last()
.should("have.attr", "style", "width: 66%;")
.then(() => {
block += 1;
rerender(props);
cy.get(".progress-bar").should("have.attr", "style", "width: 33%;");
});
it("shows 66% progress", () => {
cy.mount(BlockTimer, {
props: {
latestBlock: 3,
startBlock: 1,
duration: 3,
},
});
cy.get("div.loader")
.last()
.should("have.attr", "style", "width: 99%;")
.then(() => {
block += 1;
rerender(props);
cy.get(".progress-bar").should("have.attr", "style", "width: 66%;");
});
});
describe("when latestBlock === duration + startBlock", () => {
it("shows 100% progress", () => {
cy.mount(BlockTimer, {
props: {
latestBlock: 4,
startBlock: 1,
duration: 3,
},
});
cy.get(".progress-bar").should("have.attr", "style", "width: 100%;");
});
});
describe("when latestBlock > duration + startBlock", () => {
it("shows 100% progress", () => {
cy.mount(BlockTimer, {
props: {
latestBlock: 6,
startBlock: 1,
duration: 3,
},
});
cy.get(".progress-bar").should("have.attr", "style", "width: 100%;");
});
});
});
+11 -14
View File
@@ -1,26 +1,26 @@
<script lang="ts">
import type { Config } from "@app/config";
export let config: Config;
export let startBlock: number;
export let duration: number;
export let latestBlock: number;
let currentBlock: number = startBlock;
let progress: number = 0;
config.provider.on("block", (latestBlock: number) => {
if (startBlock + duration > currentBlock) currentBlock = latestBlock;
});
$: if (latestBlock < startBlock + duration) {
progress = (latestBlock - startBlock) * Math.floor(100 / duration);
} else {
progress = 100;
}
</script>
<style>
.parent {
.container {
text-align: center;
height: 0.5rem;
width: 100%;
border-radius: var(--border-radius-small);
background-color: var(--color-secondary-2);
}
.loader {
.progress-bar {
height: 0.5rem;
width: 0px;
border-radius: var(--border-radius-small);
@@ -28,9 +28,6 @@
}
</style>
<div class="parent">
<div
class="loader"
style="width: {(currentBlock - startBlock) *
Math.floor(100 / duration)}%" />
<div class="container">
<div class="progress-bar" style:width={`${progress}%`} />
</div>
+9 -11
View File
@@ -1,11 +1,9 @@
import Error from "./Error.svelte";
import { render } from "@testing-library/svelte";
import { Failure } from "@app/error";
import "@public/index.css";
describe("Error", () => {
it("should show passed in props", () => {
render(Error, {
cy.mount(Error, {
props: {
subtitle: "Subtitle of Modal",
error: {
@@ -16,24 +14,24 @@ describe("Error", () => {
},
},
});
cy.findByText("Error");
cy.findByText("Subtitle of Modal");
cy.findByText("Not enough RAD");
cy.findByText("Back");
cy.get("body").contains("Error").should("be.visible");
cy.get("body").contains("Subtitle of Modal").should("be.visible");
cy.get("body").contains("Not enough RAD").should("be.visible");
cy.get("button").contains("Back").should("be.visible");
});
it("should show custom error message", () => {
render(Error, {
cy.mount(Error, {
props: {
subtitle: "Subtitle of Modal",
message: "Error message to check for",
},
});
cy.findByText("Error message to check for");
cy.get("body").contains("Error message to check for").should("be.visible");
});
it("should change button label to Close when floating", () => {
render(Error, {
cy.mount(Error, {
props: {
title: "Title of Modal",
subtitle: "Subtitle of Modal",
@@ -41,6 +39,6 @@ describe("Error", () => {
floating: true,
},
});
cy.findByText("Close");
cy.get("button").contains("Close").should("be.visible");
});
});
+6 -6
View File
@@ -1,17 +1,17 @@
import NotFound from "./NotFound.svelte";
import { render } from "@testing-library/svelte";
import "@public/index.css";
describe("NotFound", () => {
it("shows passed props correctly", () => {
render(NotFound, {
cy.mount(NotFound, {
props: {
title: "nakamoto",
subtitle: "Sorry, the requested project was not found.",
},
});
cy.findByText("nakamoto");
cy.findByText("Sorry, the requested project was not found.");
cy.findByText("Back");
cy.get("body").contains("nakamoto").should("be.visible");
cy.get("body")
.contains("Sorry, the requested project was not found.")
.should("be.visible");
cy.get("button").contains("Back").should("be.visible");
});
});
+38 -24
View File
@@ -1,39 +1,53 @@
import { Seed } from "@app/base/seeds/Seed";
import { getConfig } from "@app/config";
import SeedAddress from "./SeedAddress.svelte";
import { render } from "@testing-library/svelte";
import "@public/index.css";
describe("SeedAddress", () => {
it("shows the seed emoji and seed host", () => {
render(SeedAddress, {
props: {
seed: {
id: "hydkkkf5ksbe5fuszdhpqhytu3q36gwagj874wxwpo5a8ti8coygh1",
emoji: "🐱",
getConfig().then(cfg => {
const seed = new Seed(
{
host: "seed.cloudhead.io",
id: "hydkkkf5ksbe5fuszdhpqhytu3q36gwagj874wxwpo5a8ti8coygh1",
},
port: 8776,
},
cfg,
);
cy.mount(SeedAddress, {
props: {
seed,
port: 8776,
},
});
cy.get("span.seed-icon").should("have.text", "🐱");
cy.contains("seed.cloudhead.io")
.should("have.attr", "href", "/seeds/seed.cloudhead.io")
.should("be.visible");
});
cy.get("span.seed-icon").should("have.text", "🐱");
cy.findByText("seed.cloudhead.io")
.should("have.attr", "href", "/seeds/seed.cloudhead.io")
.should("be.visible");
});
it("shows the full seed id", () => {
render(SeedAddress, {
props: {
seed: {
id: "hydkkkf5ksbe5fuszdhpqhytu3q36gwagj874wxwpo5a8ti8coygh1",
emoji: "🐱",
getConfig().then(cfg => {
const seed = new Seed(
{
host: "seed.cloudhead.io",
id: "hydkkkf5ksbe5fuszdhpqhytu3q36gwagj874wxwpo5a8ti8coygh1",
},
port: 8776,
full: true,
},
cfg,
);
cy.mount(SeedAddress, {
props: {
seed,
port: 8776,
full: true,
},
});
cy.get("span.seed-icon").should("have.text", "🐱");
cy.get("body")
.contains("hydkkk…coygh1@seed.cloudhead.io")
.should("be.visible");
cy.get("body").contains(":8776").should("be.visible");
});
cy.get("span.seed-icon").should("have.text", "🐱");
cy.findByText("hydkkk…coygh1@seed.cloudhead.io").should("be.visible");
cy.findByText(":8776").should("be.visible");
});
});
+36 -34
View File
@@ -1,25 +1,31 @@
import type { ProjectInfo } from "@app/project";
import BranchSelector from "./BranchSelector.svelte";
import { fireEvent, render } from "@testing-library/svelte";
import "@public/index.css";
const project: ProjectInfo = {
head: "e678629cd37c770c640a2cd997fc76303c815772",
urn: "rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio",
name: "nakamoto",
description: "Privacy-preserving Bitcoin light-client implementation in Rust",
defaultBranch: "master",
remotes: ["rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio"],
delegates: [
{
type: "direct",
id: "hyn9diwfnytahjq8u3iw63h9jte1ydcatxax3saymwdxqu1zo645pe",
},
],
};
const defaultProps = {
project: {
head: "e678629cd37c770c640a2cd997fc76303c815772",
urn: "rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio",
name: "nakamoto",
description:
"Privacy-preserving Bitcoin light-client implementation in Rust",
defaultBranch: "master",
maintainers: ["rad:git:hnrkqdpm9ub19oc8dccx44echy76hzfsezyio"],
delegates: ["hyn9diwfnytahjq8u3iw63h9jte1ydcatxax3saymwdxqu1zo645pe"],
},
project,
branches: { master: "e678629cd37c770c640a2cd997fc76303c815772" },
revision: "e678629cd37c770c640a2cd997fc76303c815772",
};
describe("Logic", () => {
it("should show defaultBranch label and head commit if revision === head", () => {
const { rerender } = render(BranchSelector, {
cy.mount(BranchSelector, {
props: defaultProps,
});
cy.get("div.stat.branch")
@@ -28,9 +34,9 @@ describe("Logic", () => {
cy.get("div.hash.mobile")
.should("be.visible")
.should("have.text", "e678629");
// If project.head is null we should get the head from branches.
rerender({
});
it("if project.head is null we should get the head from branches", () => {
cy.mount(BranchSelector, {
props: {
...defaultProps,
project: {
@@ -54,7 +60,7 @@ describe("Logic", () => {
});
it("should show the branch dropdown if branches available", () => {
render(BranchSelector, {
cy.mount(BranchSelector, {
props: {
...defaultProps,
branches: {
@@ -76,7 +82,7 @@ describe("Logic", () => {
});
it("should show feature-branch label and head commit, if branch label is passed as revision", () => {
render(BranchSelector, {
cy.mount(BranchSelector, {
props: {
...defaultProps,
branches: {
@@ -96,7 +102,7 @@ describe("Logic", () => {
});
it("should show only commit if no branchLabel nor branches are available", () => {
render(BranchSelector, {
cy.mount(BranchSelector, {
props: {
...defaultProps,
revision: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
@@ -113,7 +119,7 @@ describe("Logic", () => {
});
it("should show only commit if branches are available but no branchLabel", () => {
render(BranchSelector, {
cy.mount(BranchSelector, {
props: {
...defaultProps,
revision: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
@@ -129,7 +135,7 @@ describe("Logic", () => {
});
it("should show defaultBranch label if revision === head", () => {
render(BranchSelector, {
cy.mount(BranchSelector, {
props: {
...defaultProps,
revision: "e678629cd37c770c640a2cd997fc76303c815772",
@@ -144,7 +150,7 @@ describe("Logic", () => {
describe("Layout", () => {
it("should show shortened commit when on mobile, and full hash when on desktop", () => {
render(BranchSelector, {
cy.mount(BranchSelector, {
props: {
...defaultProps,
revision: "e678629cd37c770c640a2cd997fc76303c815772",
@@ -161,7 +167,9 @@ describe("Layout", () => {
describe("Events", () => {
it("should dispatch a 'branchChanged' event on click", () => {
const { getByText, component } = render(BranchSelector, {
const branchChangedSpy = cy.spy().as("branchChangedSpy");
cy.mount(BranchSelector, {
props: {
...defaultProps,
revision: "feature-branch",
@@ -170,18 +178,12 @@ describe("Events", () => {
xyz: "debf82ef3623ec11751a993bda85bac2ff1c6f00",
},
},
}).then(({ component }) => {
component.$on("branchChanged", branchChangedSpy);
});
cy.get("div.commit div.stat.branch")
.click()
.then(() => {
const branchLabel = getByText("xyz");
const mock = cy.spy();
component.$on("branchChanged", mock);
fireEvent.click(branchLabel);
expect(mock).to.have.been.calledOnce;
});
cy.get("body").contains("feature-branch").click();
cy.get("body").contains("xyz").click();
cy.get("@branchChangedSpy").should("have.been.called");
});
});
+13 -18
View File
@@ -1,6 +1,4 @@
import PeerSelector from "./PeerSelector.svelte";
import { fireEvent, render } from "@testing-library/svelte";
import "@public/index.css";
const defaultProps = {
peer: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
@@ -15,7 +13,7 @@ const defaultProps = {
describe("Logic", () => {
it("show delegate name and badge", () => {
render(PeerSelector, {
cy.mount(PeerSelector, {
props: defaultProps,
});
cy.get("span.peer-id").should("have.text", "sebastinez");
@@ -23,7 +21,7 @@ describe("Logic", () => {
});
it("show peer id with badge if no name available", () => {
render(PeerSelector, {
cy.mount(PeerSelector, {
props: {
...defaultProps,
peers: [
@@ -39,12 +37,13 @@ describe("Logic", () => {
});
it("show only peer id if no additional data available", () => {
render(PeerSelector, {
cy.mount(PeerSelector, {
props: {
...defaultProps,
peers: [
{
id: "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue",
delegate: false,
},
],
},
@@ -55,7 +54,7 @@ describe("Logic", () => {
describe("Layout", () => {
it("should highlight the current peer", () => {
render(PeerSelector, {
cy.mount(PeerSelector, {
props: { ...defaultProps },
});
cy.get("div.selector").click();
@@ -65,8 +64,9 @@ describe("Layout", () => {
describe("Events", () => {
it("dispatch peerChanged event if clicking on a peer", () => {
cy.viewport("macbook-13");
const { getByText, component } = render(PeerSelector, {
const peerChangedSpy = cy.spy().as("peerChangedSpy");
cy.mount(PeerSelector, {
props: {
...defaultProps,
peers: [
@@ -82,17 +82,12 @@ describe("Events", () => {
},
],
},
}).then(({ component }) => {
component.$on("peerChanged", peerChangedSpy);
});
cy.get("div.selector")
.click()
.then(() => {
const peer = getByText("cloudhead");
const mock = cy.spy();
component.$on("peerChanged", mock);
fireEvent.click(peer);
expect(mock).to.have.been.calledOnce;
});
cy.get("body").contains("sebastinez").click();
cy.get("body").contains("cloudhead").click();
cy.get("@peerChangedSpy").should("have.been.called");
});
});
+6 -1
View File
@@ -34,6 +34,11 @@
error = e;
}
});
let latestBlock: number;
config.provider.on("block", (block: number) => {
latestBlock = block;
});
</script>
<style>
@@ -91,7 +96,7 @@
<span class="highlight">{registrationOwner}</span>
{:else if $state.connection === State.WaitingToRegister && $state.commitmentBlock}
<BlockTimer
{config}
{latestBlock}
startBlock={$state.commitmentBlock}
duration={$state.minAge} />
{:else}
+2 -2
View File
@@ -1,11 +1,11 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"include": ["src"],
"include": ["src", "cypress/support"],
"exclude": ["node_modules/*"],
"compilerOptions": {
"target": "es2020",
"module": "es2020",
"types": ["svelte", "vite/client", "cypress", "@testing-library/cypress"],
"types": ["svelte", "vite/client", "cypress"],
"sourceMap": true,
"baseUrl": "./",
"moduleResolution": "node",