From f5fb92c80ffe3001e117b592233ffbd316d49fc0 Mon Sep 17 00:00:00 2001 From: jeski-bright <105912742+jeski-bright@users.noreply.github.com> Date: Sat, 8 Oct 2022 17:36:12 +0200 Subject: [PATCH] test(solid-query): Add test for transition (#4224) * test(solid-query) Add test for transition * change! * chore(solid-js) update to most recent version and enable test * Delete change Co-authored-by: Jedrzej Sadowski Co-authored-by: Dominik Dorfmeister --- package.json | 2 +- packages/solid-query/package.json | 2 +- .../src/__tests__/transition.test.tsx | 58 +++++++++++++++++ pnpm-lock.yaml | 64 +++++++++++++++---- 4 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 packages/solid-query/src/__tests__/transition.test.tsx diff --git a/package.json b/package.json index 4e0c9b36c9..f77fa0676c 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "rollup-plugin-terser": "^7.0.2", "rollup-plugin-visualizer": "^5.6.0", "solid-jest": "^0.2.0", - "solid-js": "^1.5.4", + "solid-js": "^1.5.7", "solid-testing-library": "^0.3.0", "stream-to-array": "^2.3.0", "svelte": "^3.48.0", diff --git a/packages/solid-query/package.json b/packages/solid-query/package.json index 0b35de092a..fe46f6a3a0 100644 --- a/packages/solid-query/package.json +++ b/packages/solid-query/package.json @@ -46,7 +46,7 @@ "@tanstack/query-core": "workspace:*" }, "peerDependencies": { - "solid-js": "^1.5.4" + "solid-js": "^1.5.7" }, "peerDependenciesMeta": {} } diff --git a/packages/solid-query/src/__tests__/transition.test.tsx b/packages/solid-query/src/__tests__/transition.test.tsx new file mode 100644 index 0000000000..af26437cef --- /dev/null +++ b/packages/solid-query/src/__tests__/transition.test.tsx @@ -0,0 +1,58 @@ +import { fireEvent, render, screen, waitFor } from 'solid-testing-library' + +import { createSignal, Show, startTransition, Suspense } from 'solid-js' +import { createQuery, QueryCache, QueryClientProvider } from '..' +import { createQueryClient, queryKey, sleep } from './utils' + +describe("useQuery's in Suspense mode with transitions", () => { + const queryCache = new QueryCache() + const queryClient = createQueryClient({ queryCache }) + + it('should render the content when the transition is done', async () => { + const key = queryKey() + + function Suspended() { + const state = createQuery(key, async () => { + await sleep(10) + return true + }) + + return Message + } + + function Page() { + const [showSignal, setShowSignal] = createSignal(false) + + return ( +
+ + + + + + +
+ ) + } + + render(() => ( + + + + )) + + await waitFor(() => screen.getByText('Show')) + fireEvent.click(screen.getByLabelText('toggle')) + + await waitFor(() => screen.getByText('Message')) + // verify that the button also updated. See https://github.com/solidjs/solid/issues/1249 + await waitFor(() => screen.getByText('Hide')) + }) +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f5fdba290..ac262d67a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,7 +65,7 @@ importers: rollup-plugin-terser: ^7.0.2 rollup-plugin-visualizer: ^5.6.0 solid-jest: ^0.2.0 - solid-js: ^1.5.4 + solid-js: ^1.5.7 solid-testing-library: ^0.3.0 stream-to-array: ^2.3.0 svelte: ^3.48.0 @@ -134,8 +134,8 @@ importers: rollup-plugin-terser: 7.0.2_rollup@2.78.1 rollup-plugin-visualizer: 5.6.0_rollup@2.78.1 solid-jest: 0.2.0_zy3poetcogmvcndrkzqtylmjuq - solid-js: 1.5.4 - solid-testing-library: 0.3.0_solid-js@1.5.4 + solid-js: 1.5.7 + solid-testing-library: 0.3.0_solid-js@1.5.7 stream-to-array: 2.3.0 svelte: 3.49.0 ts-node: 10.8.2_rb7lfb2dlgdf5f7m6mcvvespxa @@ -3136,6 +3136,12 @@ packages: dependencies: regenerator-runtime: 0.13.9 + /@babel/runtime/7.19.0: + resolution: {integrity: sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.13.9 + /@babel/runtime/7.9.0: resolution: {integrity: sha512-cTIudHnzuWLS56ik4DnRnqqNf8MkdUzV4iFFI1h7Jo9xvrpQROYaAnaSd2mHLQAzzZAPfATynX5ord6YlNYNMA==} dependencies: @@ -5207,7 +5213,7 @@ packages: engines: {node: '>=10'} dependencies: '@babel/code-frame': 7.18.6 - '@babel/runtime': 7.18.9 + '@babel/runtime': 7.19.0 '@types/aria-query': 4.2.2 aria-query: 4.2.2 chalk: 4.1.2 @@ -5230,6 +5236,20 @@ packages: pretty-format: 27.5.1 dev: true + /@testing-library/dom/8.18.1: + resolution: {integrity: sha512-oEvsm2B/WtcHKE+IcEeeCqNU/ltFGaVyGbpcm4g/2ytuT49jrlH9x5qRKL/H3A6yfM4YAbSbC0ceT5+9CEXnLg==} + engines: {node: '>=12'} + dependencies: + '@babel/code-frame': 7.18.6 + '@babel/runtime': 7.19.0 + '@types/aria-query': 4.2.2 + aria-query: 5.0.2 + chalk: 4.1.2 + dom-accessibility-api: 0.5.14 + lz-string: 1.4.4 + pretty-format: 27.5.1 + dev: true + /@testing-library/jest-dom/5.16.4: resolution: {integrity: sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA==} engines: {node: '>=8', npm: '>=6', yarn: '>=1'} @@ -5274,8 +5294,8 @@ packages: react: '*' react-dom: '*' dependencies: - '@babel/runtime': 7.18.9 - '@testing-library/dom': 8.14.0 + '@babel/runtime': 7.19.0 + '@testing-library/dom': 8.18.1 '@types/react-dom': 18.0.6 react: 18.2.0 react-dom: 18.2.0_react@18.2.0 @@ -6543,6 +6563,11 @@ packages: engines: {node: '>=6.0'} dev: true + /aria-query/5.0.2: + resolution: {integrity: sha512-eigU3vhqSO+Z8BKDnVLN/ompjhf3pYzecKXz8+whRy+9gZu8n1TCGfwzQUUPnqdHl9ax1Hr9031orZ+UOEYr7Q==} + engines: {node: '>=6.0'} + dev: true + /arr-diff/4.0.0: resolution: {integrity: sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==} engines: {node: '>=0.10.0'} @@ -6748,7 +6773,7 @@ packages: /axios/0.24.0: resolution: {integrity: sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==} dependencies: - follow-redirects: 1.15.1_debug@4.3.4 + follow-redirects: 1.15.1 transitivePeerDependencies: - debug dev: true @@ -6756,7 +6781,7 @@ packages: /axios/0.26.1: resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==} dependencies: - follow-redirects: 1.15.1_debug@4.3.4 + follow-redirects: 1.15.1 transitivePeerDependencies: - debug @@ -8166,8 +8191,8 @@ packages: engines: {node: '>=10'} hasBin: true dependencies: - JSONStream: 1.3.5 is-text-path: 1.0.1 + JSONStream: 1.3.5 lodash: 4.17.21 meow: 8.1.2 split2: 3.2.2 @@ -10894,6 +10919,15 @@ packages: inherits: 2.0.4 readable-stream: 2.3.7 + /follow-redirects/1.15.1: + resolution: {integrity: sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + /follow-redirects/1.15.1_debug@4.3.4: resolution: {integrity: sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==} engines: {node: '>=4.0'} @@ -17413,7 +17447,7 @@ packages: /regenerator-transform/0.15.0: resolution: {integrity: sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==} dependencies: - '@babel/runtime': 7.18.9 + '@babel/runtime': 7.19.0 /regex-not/1.0.2: resolution: {integrity: sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==} @@ -18284,6 +18318,12 @@ packages: dependencies: csstype: 3.1.0 + /solid-js/1.5.7: + resolution: {integrity: sha512-L1UuyMuZZARAwzXo5NZDhE6yxc14aqNbVOUoGzvlcxRZo1Cm4ExhPV0diEfwDyiKG/igqNNLkNurHkXiI5sVEg==} + dependencies: + csstype: 3.1.0 + dev: true + /solid-refresh/0.4.1_solid-js@1.5.4: resolution: {integrity: sha512-v3tD/OXQcUyXLrWjPW1dXZyeWwP7/+GQNs8YTL09GBq+5FguA6IejJWUvJDrLIA4M0ho9/5zK2e9n+uy+4488g==} peerDependencies: @@ -18295,14 +18335,14 @@ packages: solid-js: 1.5.4 dev: true - /solid-testing-library/0.3.0_solid-js@1.5.4: + /solid-testing-library/0.3.0_solid-js@1.5.7: resolution: {integrity: sha512-6NWVbySNVzyReBm2N6p3eF8bzxRZXHZTAmPix4vFWYol16QWVjNQsEUxvr+ZOutb0yuMZmNuGx3b6WIJYmjwMQ==} engines: {node: '>= 14'} peerDependencies: solid-js: '>=1.0.0' dependencies: '@testing-library/dom': 7.31.2 - solid-js: 1.5.4 + solid-js: 1.5.7 dev: true /sort-by/1.2.0: