perf(api): memoise the effective bluesky oauth config (#2156)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-30 22:27:47 +02:00
1 parent 8491872908
commit cbf504dbb8
3 files changed
+57 -3

No files matched your search

@@ -81,6 +81,40 @@ describe('InstanceConfigRepository', () => {
});
});
it('reuses the memoized effective bluesky config until the integrations blob changes', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const repository = createRepository(kvProvider);
const first = await repository.getEffectiveBlueskyConfig();
expect(await repository.getEffectiveBlueskyConfig()).toBe(first);
await repository.setInstanceIntegrationsConfig({bluesky: {client_name: 'Memoized Instance'}});
const updated = await repository.getEffectiveBlueskyConfig();
expect(updated).not.toBe(first);
expect(updated.client_name).toBe('Memoized Instance');
expect(await repository.getEffectiveBlueskyConfig()).toBe(updated);
});
it('recomputes the effective bluesky config after another repository publishes an integrations update', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);
const kvProvider = new MockKVProvider();
const reader = createRepository(kvProvider);
const writer = createRepository(kvProvider);
const before = await reader.getEffectiveBlueskyConfig();
expect(await reader.getEffectiveBlueskyConfig()).toBe(before);
await writer.setInstanceIntegrationsConfig({bluesky: {client_name: 'Refreshed Instance'}});
await vi.waitFor(async () => {
expect((await reader.getEffectiveBlueskyConfig()).client_name).toBe('Refreshed Instance');
});
});
it('uses the registration URL id as the admin-visible registration code', async () => {
const executor = new CountingInMemoryCassandraQueryExecutor();
setCassandraQueryExecutorForTesting(executor);