diff --git a/package.json b/package.json index 07e967fe5..f2dee1b5e 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "build": "pnpm run build:core && pnpm run build:runtime", "build:core": "tsup", "build:runtime": "tsup --config tsup-runtime.config.ts", - "dev": "pnpm run test", + "dev": "pnpm run test --ui", "docs": "vitepress dev docs", "docs:build": "vitepress build docs", "lint": "prettier -c '{src,examples,playground}/**/*.{ts,vue}'", @@ -149,7 +149,7 @@ "play:build": "npm -C playground run build", "release": "node scripts/release.mjs", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1", - "test": "vitest --typecheck --ui" + "test": "vitest --typecheck" }, "gitHooks": { "pre-commit": "lint-staged", diff --git a/src/data-loaders/defineColadaLoader.spec.ts b/src/data-loaders/defineColadaLoader.spec.ts index a310bc051..b69acb855 100644 --- a/src/data-loaders/defineColadaLoader.spec.ts +++ b/src/data-loaders/defineColadaLoader.spec.ts @@ -23,7 +23,7 @@ import { getRouter } from 'vue-router-mock' import { enableAutoUnmount, mount } from '@vue/test-utils' import RouterViewMock from '../../tests/data-loaders/RouterViewMock.vue' import { setActivePinia, createPinia, getActivePinia } from 'pinia' -import { QueryPlugin, useQuery } from '@pinia/colada' +import { useQuery, PiniaColada } from '@pinia/colada' import { RouteLocationNormalizedLoaded } from 'vue-router' describe( @@ -55,7 +55,7 @@ describe( setActivePinia(pinia) return { pinia } }, - plugins: ({ pinia }) => [pinia, QueryPlugin], + plugins: ({ pinia }) => [pinia, PiniaColada], } ) @@ -95,7 +95,7 @@ describe( plugins: [ [DataLoaderPlugin, { router, ...pluginOptions }], createPinia(), - QueryPlugin, + PiniaColada, ], }, }) @@ -168,7 +168,7 @@ describe( }), { global: { - plugins: [getActivePinia()!, QueryPlugin], + plugins: [getActivePinia()!, PiniaColada], }, } ) diff --git a/src/data-loaders/defineColadaLoader.ts b/src/data-loaders/defineColadaLoader.ts index b9bfd7d36..747b82ed8 100644 --- a/src/data-loaders/defineColadaLoader.ts +++ b/src/data-loaders/defineColadaLoader.ts @@ -179,6 +179,11 @@ export function defineColadaLoader( // entries.delete(loader) // } }) + // avoid double reload since calling `useQuery()` will trigger a refresh + // and we might also do it below for nested loaders + if (entry.ext.status.value === 'loading') { + reload = false + } } const { isLoading, data, error, ext } = entry diff --git a/tests/data-loaders/tester.ts b/tests/data-loaders/tester.ts index 645dfbb4a..ebc33438c 100644 --- a/tests/data-loaders/tester.ts +++ b/tests/data-loaders/tester.ts @@ -793,9 +793,11 @@ export function testDefineLoader( it('can nest loaders', async () => { const spyOne = vi .fn<(...args: unknown[]) => Promise>() + .mockResolvedValue('ko') .mockResolvedValueOnce('one') const spyTwo = vi .fn<(...args: unknown[]) => Promise>() + .mockResolvedValue('ko') .mockResolvedValueOnce('two') const useLoaderOne = loaderFactory({ fn: spyOne, key: 'one' }) const useLoaderTwo = loaderFactory({