(engine: string, makeHarness: (repo: DataDependencies.DataDependency) => EngineHarness)
| 285 | const self = { id: "MatrixTs.List", handler: () => DataDependencies.read(queryRepo).pipe(Effect.as(++runs)) } |
| 286 | const ctx = makeTanstackContext(queryClient) |
| 287 | const [, , , handle] = ctx.run(() => useQuery(self as any)(ref(undefined) as any, {} as any)) as any |
| 288 | return { |
| 289 | queryFullKey: [...makeQueryKey(self), undefined], |
| 290 | serverInvalidationKey: makeQueryKey(self), |
| 291 | fetchInitial: () => Effect.runPromise(handle.refetch()), |
| 292 | runs: () => runs, |
| 293 | runCommand: (options, command) => |
| 294 | Effect.runPromise(invalidateQueries({ id: "MatrixTs.Save" }, options, invalidator)(command, { id: "x" })), |
| 295 | dispose: () => ctx.dispose() |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | const makeAtomHarness = (queryRepo: DataDependencies.DataDependency): EngineHarness => { |
| 300 | const mrt = ManagedRuntime.make(Reactivity.layer) |
| 301 | const baseContext = mrt.runSync(Effect.context<Reactivity.Reactivity>()) |
| 302 | const reactivity = Context.get(baseContext, Reactivity.Reactivity) |
| 303 | const rt = makeAtomClientRuntime( |
| 304 | () => Layer.succeedContext(baseContext) as Layer.Layer<any, never, never>, |
| 305 | mrt.memoMap |
| 306 | ) |
| 307 | const invalidator = { |
| 308 | invalidateAndAwait: (keys: ReadonlyArray<ReadonlyArray<unknown>>) => |
| 309 | invalidateAndAwait(keys).pipe(Effect.provideService(Reactivity.Reactivity, reactivity)) |
| 310 | } |
| 311 | let runs = 0 |
| 312 | const self = { id: "MatrixAtom.List", handler: () => DataDependencies.read(queryRepo).pipe(Effect.as(++runs)) } |
| 313 | const atom = buildQueryFamily(rt as any, self as any)(undefined) |
| 314 | const unmount = defaultRegistry.mount(atom) |
| 315 | return { |
| 316 | queryFullKey: [...makeQueryKey(self), undefined], |
| 317 | serverInvalidationKey: makeQueryKey(self), |
| 318 | fetchInitial: () => Effect.runPromise(awaitAtomResult(defaultRegistry, atom)), |
| 319 | runs: () => runs, |
| 320 | runCommand: (options, command) => |
| 321 | Effect.runPromise( |
| 322 | invalidateQueries({ id: "MatrixAtom.Save" }, options, invalidator)(command, { id: "x" }) |
| 323 | .pipe(Effect.andThen(awaitAtomResult(defaultRegistry, atom).pipe(Effect.exit))) |
| 324 | ), |
| 325 | dispose: () => { |
| 326 | unmount() |
| 327 | clearQueryReadDependencies([...makeQueryKey(self), undefined]) |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | const runInvalidationMatrix = (engine: string, makeHarness: (repo: DataDependencies.DataDependency) => EngineHarness) => |
| 333 | it(`${engine} engine e2e: invalidation source matrix`, async () => { |
| 334 | const queryRepo = DataDependencies.repo(`${engine}MatrixRepo`) |
| 335 | const otherRepo = DataDependencies.repo(`${engine}MatrixOther`) |
| 336 | const h = makeHarness(queryRepo) |
| 337 | const noop = Effect.succeed(undefined) |
| 338 | |
| 339 | const expectRefetch = async <A, E>( |
| 340 | label: string, |
| 341 | options: MutationOptionsBase | undefined, |
| 342 | command: Effect.Effect<A, E> |
| 343 | ) => { |
| 344 | const before = h.runs() |
no test coverage detected
searching dependent graphs…