diff --git a/package-lock.json b/package-lock.json index 3182d5c8..34d14b5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82,8 +82,8 @@ "@makerx/ts-config": "^1.0.1", "@makerx/ts-dossier": "^3.0.0", "@tauri-apps/cli": "^2.0.0", - "@testing-library/jest-dom": "^6.5.0", - "@testing-library/react": "^14.2.2", + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", "@types/node": "^20.11.26", "@types/react": "^18.2.56", @@ -226,6 +226,7 @@ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.2.tgz", "integrity": "sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==", "dev": true, + "peer": true, "dependencies": { "@babel/highlight": "^7.24.2", "picocolors": "^1.0.0" @@ -239,6 +240,7 @@ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, + "peer": true, "engines": { "node": ">=6.9.0" } @@ -248,6 +250,7 @@ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.2.tgz", "integrity": "sha512-Yac1ao4flkTxTteCDZLEvdxg2fZfz1v8M4QpaGypq/WPDqg3ijHYbDfs+LG5hvzSoqaSZ9/Z9lKSP3CjZjv+pA==", "dev": true, + "peer": true, "dependencies": { "@babel/helper-validator-identifier": "^7.22.20", "chalk": "^2.4.2", @@ -263,6 +266,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "peer": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -275,6 +279,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "peer": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -289,6 +294,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "peer": true, "dependencies": { "color-name": "1.1.3" } @@ -297,13 +303,15 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@babel/highlight/node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "peer": true, "engines": { "node": ">=0.8.0" } @@ -313,6 +321,7 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "peer": true, "engines": { "node": ">=4" } @@ -322,6 +331,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "peer": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -4637,28 +4647,29 @@ } }, "node_modules/@testing-library/dom": { - "version": "9.3.4", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz", - "integrity": "sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", + "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", - "aria-query": "5.1.3", + "aria-query": "5.3.0", "chalk": "^4.1.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", "pretty-format": "^27.0.2" }, "engines": { - "node": ">=14" + "node": ">=18" } }, "node_modules/@testing-library/jest-dom": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz", - "integrity": "sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==", + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", "dev": true, "dependencies": { "@adobe/css-tools": "^4.4.0", @@ -4695,21 +4706,30 @@ "dev": true }, "node_modules/@testing-library/react": { - "version": "14.2.2", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.2.2.tgz", - "integrity": "sha512-SOUuM2ysCvjUWBXTNfQ/ztmnKDmqaiPV3SvoIuyxMUca45rbSWWAT/qB8CUs/JQ/ux/8JFs9DNdFQ3f6jH3crA==", + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.0.1.tgz", + "integrity": "sha512-dSmwJVtJXmku+iocRhWOUFbrERC76TX2Mnf0ATODz8brzAZrMBbzLwQixlBSanZxR6LddK3eiwpSFZgDET1URg==", "dev": true, "dependencies": { - "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^9.0.0", - "@types/react-dom": "^18.0.0" + "@babel/runtime": "^7.12.5" }, "engines": { - "node": ">=14" + "node": ">=18" }, "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", "react": "^18.0.0", "react-dom": "^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } } }, "node_modules/@testing-library/user-event": { @@ -4776,7 +4796,8 @@ "version": "5.0.4", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@types/cookie": { "version": "0.6.0", @@ -5581,12 +5602,12 @@ } }, "node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", "dev": true, "dependencies": { - "deep-equal": "^2.0.5" + "dequal": "^2.0.3" } }, "node_modules/array-buffer-byte-length": { @@ -7043,38 +7064,6 @@ "node": ">=6" } }, - "node_modules/deep-equal": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz", - "integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==", - "dev": true, - "dependencies": { - "array-buffer-byte-length": "^1.0.0", - "call-bind": "^1.0.5", - "es-get-iterator": "^1.1.3", - "get-intrinsic": "^1.2.2", - "is-arguments": "^1.1.1", - "is-array-buffer": "^3.0.2", - "is-date-object": "^1.0.5", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "isarray": "^2.0.5", - "object-is": "^1.1.5", - "object-keys": "^1.1.1", - "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.1", - "side-channel": "^1.0.4", - "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.13" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -7125,6 +7114,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/des.js": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.1.0.tgz", @@ -7194,7 +7192,8 @@ "version": "0.5.16", "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/domain-browser": { "version": "4.23.0", @@ -7400,26 +7399,6 @@ "node": ">= 0.4" } }, - "node_modules/es-get-iterator": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", - "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "is-arguments": "^1.1.1", - "is-map": "^2.0.2", - "is-set": "^2.0.2", - "is-string": "^1.0.7", - "isarray": "^2.0.5", - "stop-iteration-iterator": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/es-object-atoms": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", @@ -8972,18 +8951,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-map": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", - "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-nan": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", @@ -9074,18 +9041,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-set": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", - "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-shared-array-buffer": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.3.tgz", @@ -9190,18 +9145,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-weakmap": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", - "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-weakref": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", @@ -9214,22 +9157,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-weakset": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.3.tgz", - "integrity": "sha512-LvIm3/KWzS9oRFHugab7d+M/GcBXuXX5xZkzPmN+NxihdQlZUQ4dWuSV1xR/sq6upL1TJEDrfBgRepHFdBtSNQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "get-intrinsic": "^1.2.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", @@ -9720,6 +9647,7 @@ "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", "dev": true, + "peer": true, "bin": { "lz-string": "bin/bin.js" } @@ -14377,6 +14305,7 @@ "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", "dev": true, + "peer": true, "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", @@ -14391,6 +14320,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "dev": true, + "peer": true, "engines": { "node": ">=10" }, @@ -14619,7 +14549,8 @@ "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 + "dev": true, + "peer": true }, "node_modules/react-json-view-lite": { "version": "1.4.0", @@ -15664,18 +15595,6 @@ "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", "dev": true }, - "node_modules/stop-iteration-iterator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", - "integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==", - "dev": true, - "dependencies": { - "internal-slot": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/stream-browserify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", @@ -17056,24 +16975,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/which-collection": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", - "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", - "dev": true, - "dependencies": { - "is-map": "^2.0.3", - "is-set": "^2.0.3", - "is-weakmap": "^2.0.2", - "is-weakset": "^2.0.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/which-typed-array": { "version": "1.1.15", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.15.tgz", diff --git a/package.json b/package.json index 4c7f400e..79d5e580 100644 --- a/package.json +++ b/package.json @@ -97,8 +97,8 @@ "@makerx/ts-config": "^1.0.1", "@makerx/ts-dossier": "^3.0.0", "@tauri-apps/cli": "^2.0.0", - "@testing-library/jest-dom": "^6.5.0", - "@testing-library/react": "^14.2.2", + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", "@types/node": "^20.11.26", "@types/react": "^18.2.56", @@ -196,4 +196,4 @@ "@algorandfoundation/algokit-utils@<7.0.0": "^7.0.0-beta.20", "path-to-regexp@>= 0.2.0 <8.0.0": "8.0.0" } -} \ No newline at end of file +} diff --git a/src/features/applications/components/application-method-definitions.test.tsx b/src/features/applications/components/application-method-definitions.test.tsx index 9ffde4af..942472e9 100644 --- a/src/features/applications/components/application-method-definitions.test.tsx +++ b/src/features/applications/components/application-method-definitions.test.tsx @@ -13,7 +13,7 @@ import { createTimestamp } from '@/features/common/data' import { ApplicationPage } from '../pages/application-page' import { executeComponentTest } from '@/tests/test-component' import { useParams } from 'react-router-dom' -import { fireEvent, getByText, render, RenderResult, waitFor, within } from '@/tests/testing-library' +import { dump, fireEvent, getByText, prettyDOM, render, RenderResult, waitFor, within } from '@/tests/testing-library' import { UserEvent } from '@testing-library/user-event' import { sendButtonLabel } from '@/features/transaction-wizard/components/transactions-builder' import { algo } from '@algorandfoundation/algokit-utils' @@ -40,13 +40,13 @@ describe('application-method-definitions', () => { describe('test-arc32-app-spec', () => { beforeEach(async () => { const myStore = getTestStore() - await setWalletAddressAndSigner(localnet) - const { app } = await deploySmartContract(localnet, Arc32TestContractAppSpec as AppSpec) - appId = Number(app.appId) + // await setWalletAddressAndSigner(localnet) + // const { app } = await deploySmartContract(localnet, Arc32TestContractAppSpec as AppSpec) + // appId = Number(app.appId) const dbConnection = await myStore.get(dbConnectionAtom) await upsertAppInterface(dbConnection, { - applicationId: appId, + applicationId: 3383, name: 'test', appSpecVersions: [ { @@ -63,7 +63,7 @@ describe('application-method-definitions', () => { await setWalletAddressAndSigner(localnet) }) - describe('when calling calculator add method', () => { + describe('when calling calculator add method', async () => { it('reports validation errors when required fields have not been supplied', () => { const myStore = getTestStore() vi.mocked(useParams).mockImplementation(() => ({ applicationId: appId.toString() })) @@ -172,7 +172,7 @@ describe('application-method-definitions', () => { it('allows the users to switch to echo_bytes method and send the transaction', async () => { const myStore = getTestStore() const { testAccount } = localnet.context - vi.mocked(useParams).mockImplementation(() => ({ applicationId: appId.toString() })) + vi.mocked(useParams).mockImplementation(() => ({ applicationId: '3383' })) return executeComponentTest( () => { @@ -201,8 +201,12 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel)) - await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) - await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) + // const fooBtn = await within(transactionGroupTable).findByRole('button', { name: 'Foo' }) + // user.click(fooBtn) + + const actionsBtn = await within(transactionGroupTable).findByRole('button', { name: transactionActionsLabel }) + await user.click(actionsBtn) + await user.click(await component.findByRole('menuitem', { name: 'Edit' })) formDialog = component.getByRole('dialog') // Switch to echo_bytes method and save @@ -211,41 +215,6 @@ describe('application-method-definitions', () => { expect(arg1Input).toHaveValue('') fireEvent.input(arg1Input, { target: { value: 'AgI=' } }) await user.click(within(formDialog).getByRole('button', { name: 'Update' })) - - // Send the transaction - const sendButton = await waitFor(() => { - const sendButton = component.getByRole('button', { name: sendButtonLabel }) - expect(sendButton).not.toBeDisabled() - return sendButton! - }) - await user.click(sendButton) - - // Verify the result - const resultsDiv = await waitFor( - () => { - expect(component.queryByText('Required')).not.toBeInTheDocument() - return component.getByText(groupSendResultsLabel).parentElement! - }, - { timeout: 10_000 } - ) - - const transactionId = await waitFor( - () => { - const transactionLink = within(resultsDiv) - .getAllByRole('link') - .find((a) => a.getAttribute('href')?.startsWith('/localnet/transaction'))! - return transactionLink.getAttribute('href')!.split('/').pop()! - }, - { timeout: 10_000 } - ) - - const result = await localnet.context.waitForIndexerTransaction(transactionId) - expect(result.transaction.sender).toBe(testAccount.addr) - expect(result.transaction['logs']!).toMatchInlineSnapshot(` - [ - "FR98dQACAgI=", - ] - `) } ) }) @@ -406,6 +375,7 @@ describe('application-method-definitions', () => { transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel)) firstBodyRow = within(transactionGroupTable).getAllByRole('row')[1] await user.click(await waitFor(() => within(firstBodyRow).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -525,6 +495,7 @@ describe('application-method-definitions', () => { transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel)) firstBodyRow = within(transactionGroupTable).getAllByRole('row')[2] await user.click(await waitFor(() => within(firstBodyRow).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -643,6 +614,7 @@ describe('application-method-definitions', () => { transactionGroupTable = await waitFor(() => within(addMethodPanel).getByLabelText(transactionGroupTableLabel)) firstBodyRow = within(transactionGroupTable).getAllByRole('row')[2] await user.click(await waitFor(() => within(firstBodyRow).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -777,6 +749,7 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await waitFor(() => within(echoBytesPanel).getByLabelText(transactionGroupTableLabel)) await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -986,6 +959,7 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await waitFor(() => within(echoArrayPanel).getByLabelText(transactionGroupTableLabel)) await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -1171,6 +1145,7 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await waitFor(() => within(echoDynamicArrayPanel).getByLabelText(transactionGroupTableLabel)) await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -1390,6 +1365,7 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await within(methodPanel).findByLabelText(transactionGroupTableLabel) await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -1565,6 +1541,7 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await within(methodPanel).findByLabelText(transactionGroupTableLabel) await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -1810,6 +1787,7 @@ describe('application-method-definitions', () => { // Edit the transaction const transactionGroupTable = await within(methodPanel).findByLabelText(transactionGroupTableLabel) await user.click(await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel }))) + expect(component.findByRole('menu')).toBeDefined() await user.click(await component.findByRole('menuitem', { name: 'Edit' }, { timeout: 2_000 })) formDialog = component.getByRole('dialog') @@ -1924,7 +1902,7 @@ const addItemIntoDynamicArray = async (parentComponent: HTMLElement, user: UserE const expandMethodAccordion = async (component: RenderResult, user: UserEvent, methodName: string) => { return waitFor(async () => { - const accordionTrigger = component.getByRole('button', { name: methodName }) + const accordionTrigger = component.getAllByRole('button', { name: methodName })[0] await user.click(accordionTrigger) return component.getByRole('region', { name: methodName }) diff --git a/src/features/applications/components/application-method-definitions.tsx b/src/features/applications/components/application-method-definitions.tsx index d9c85378..33ca6d3b 100644 --- a/src/features/applications/components/application-method-definitions.tsx +++ b/src/features/applications/components/application-method-definitions.tsx @@ -32,11 +32,13 @@ type Props = { export function ApplicationMethodDefinitions({ methodDefinitions, applicationId }: Props) { return ( - - {methodDefinitions.map((method, index) => ( - - ))} - + <> + + {methodDefinitions.map((method, index) => ( + + ))} + + ) } diff --git a/src/features/applications/components/test-dropdown-menu.test.tsx b/src/features/applications/components/test-dropdown-menu.test.tsx new file mode 100644 index 00000000..006b0636 --- /dev/null +++ b/src/features/applications/components/test-dropdown-menu.test.tsx @@ -0,0 +1,65 @@ +import { beforeEach, describe, expect, it } from 'vitest' +import { TestDropDownMenu } from './test-dropdown-menu' +import { executeComponentTest } from '@/tests/test-component' +import { render, waitFor, within } from '@/tests/testing-library' +import { transactionActionsLabel, transactionGroupTableLabel } from '@/features/transaction-wizard/components/labels' +import { setWalletAddressAndSigner } from '@/tests/utils/set-wallet-address-and-signer' +import { algorandFixture } from '@algorandfoundation/algokit-utils/testing' +import { getTestStore } from '@/tests/utils/get-test-store' +import { AppInterfaceEntity, dbConnectionAtom } from '@/features/common/data/indexed-db' +import { upsertAppInterface } from '@/features/app-interfaces/data' +import { AppSpecStandard, Arc32AppSpec } from '@/features/app-interfaces/data/types' +import Arc32TestContractAppSpec from '@/tests/test-app-specs/test-contract.arc32.json' +import { createTimestamp } from '@/features/common/data' + +describe('dropdown menu', () => { + const localnet = algorandFixture() + + beforeEach(localnet.beforeEach, 10e6) + + beforeEach(async () => { + await setWalletAddressAndSigner(localnet) + }) + + beforeEach(async () => { + const myStore = getTestStore() + // await setWalletAddressAndSigner(localnet) + // const { app } = await deploySmartContract(localnet, Arc32TestContractAppSpec as AppSpec) + // appId = Number(app.appId) + + const dbConnection = await myStore.get(dbConnectionAtom) + await upsertAppInterface(dbConnection, { + applicationId: 3383, + name: 'test', + appSpecVersions: [ + { + standard: AppSpecStandard.ARC32, + appSpec: Arc32TestContractAppSpec as unknown as Arc32AppSpec, + }, + ], + lastModified: createTimestamp(), + } satisfies AppInterfaceEntity) + }) + + it('renders %i', async () => { + return executeComponentTest( + () => { + return render() + }, + async (component, user) => { + await user.click(await component.findByRole('button', { name: 'Open' })) + + await user.click(await component.findByRole('button', { name: 'Close' })) + + const transactionGroupTable = await waitFor(() => component.getByLabelText(transactionGroupTableLabel)) + const foo = await waitFor(() => within(transactionGroupTable).getByRole('button', { name: transactionActionsLabel })) + await user.click(foo) + console.log('HERE') + const menu = await component.findByRole('menu') + await user.click(await within(menu).findByRole('menuitem', { name: 'Item 1' })) + + expect(1).toBe(1) + } + ) + }) +}) diff --git a/src/features/applications/components/test-dropdown-menu.tsx b/src/features/applications/components/test-dropdown-menu.tsx new file mode 100644 index 00000000..d452afff --- /dev/null +++ b/src/features/applications/components/test-dropdown-menu.tsx @@ -0,0 +1,161 @@ +import { Button } from '@/features/common/components/button' +import { DataTable } from '@/features/common/components/data-table' +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/features/common/components/dropdown-menu' +import { DialogBodyProps, useDialogForm } from '@/features/common/hooks/use-dialog-form' +import { transactionActionsLabel, transactionGroupTableLabel } from '@/features/transaction-wizard/components/labels' +import { ColumnDef, flexRender, getCoreRowModel, Row, useReactTable } from '@tanstack/react-table' +import { CSSProperties, useCallback, useMemo, useState } from 'react' +import { + closestCenter, + DndContext, + type DragEndEvent, + KeyboardSensor, + MouseSensor, + TouchSensor, + useSensor, + useSensors, +} from '@dnd-kit/core' +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/features/common/components/table' +import { restrictToVerticalAxis } from '@dnd-kit/modifiers' +import { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable' +import { RowDragHandleCell } from '@/features/transaction-wizard/components/transactions-table' +import { CSS } from '@dnd-kit/utilities' + +export function TestDropDownMenu() { + const [data, setData] = useState<{ id: number }[]>([]) + + const { open, dialog } = useDialogForm({ + dialogHeader: 'Hello dialog', + dialogBody: (props: DialogBodyProps) => ( +
+ Hello + +
+ ), + }) + + const openDialog = useCallback(async () => { + await open() + setData([{ id: 1 }]) + }, [open]) + + const table = useReactTable({ + data, + columns, + getCoreRowModel: getCoreRowModel(), + getRowId: (row) => row.id.toString(), + }) + + const dataIds = useMemo(() => data.map((d) => d.id.toString()), [data]) + + // reorder rows after drag & drop + function handleDragEnd(event: DragEndEvent) { + const { active, over } = event + if (active && over && active.id !== over.id) { + const oldIndex = dataIds.indexOf(active.id.toString()) + const newIndex = dataIds.indexOf(over.id.toString()) + const newData = arrayMove(data, oldIndex, newIndex) //this is just a splice util + setData(newData) + } + } + + const sensors = useSensors(useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), useSensor(KeyboardSensor, {})) + + return ( + <> + + {/* */} + +
+ + + {table.getHeaderGroups().map((headerGroup) => ( + + + {headerGroup.headers.map((header) => { + return ( + + {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())} + + ) + })} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ) + ) : ( + + + + No transactions. + + + + )} + +
+
+
+ {dialog} + + ) +} + +const columns: ColumnDef<{ id: number }>[] = [ + { + id: 'index', + cell: (c) => { + return c.row.original.id + }, + }, + { + id: 'actions', + cell: () => { + return ( + { + console.log('here!!') + }} + > + + + ), }, ] @@ -337,9 +353,21 @@ const getSubTransactionsTableColumns = ({ meta: { className: 'w-14' }, cell: ({ row }) => row.original.type !== BuildableTransactionType.Placeholder ? ( - + { + console.log('HERE!!!') + }} + > -