address comments

This commit is contained in:
Christine Betts
2026-02-12 15:54:15 -05:00
parent 3be90e0dea
commit 878f57c1b7
3 changed files with 23 additions and 14 deletions

View File

@@ -40,6 +40,13 @@ export class ExtensionRegistryClient {
ExtensionRegistryClient.fetchPromise = null;
}
/**
* Returns all extensions from the registry.
*/
async getAllExtensions(): Promise<RegistryExtension[]> {
return this.fetchAllExtensions();
}
async getExtensions(
page: number = 1,
limit: number = 10,

View File

@@ -14,7 +14,7 @@ import {
} from '../../../config/extensionRegistryClient.js';
import { type ExtensionManager } from '../../../config/extension-manager.js';
vi.mock('../../config/extensionRegistryClient.js');
vi.mock('../../../config/extensionRegistryClient.js');
const mockExtensions = [
{
@@ -37,6 +37,12 @@ describe('ExtensionRegistryView', () => {
});
it('should render loading state initially', async () => {
// Return a promise that doesn't resolve immediately to keep the loading state active
vi.spyOn(
ExtensionRegistryClient.prototype,
'getAllExtensions',
).mockReturnValue(new Promise(() => {}));
const mockExtensionManager = {
getExtensions: vi.fn().mockReturnValue([]),
};
@@ -52,11 +58,8 @@ describe('ExtensionRegistryView', () => {
it('should render extensions after fetching', async () => {
vi.spyOn(
ExtensionRegistryClient.prototype,
'getExtensions',
).mockResolvedValue({
extensions: mockExtensions as unknown as RegistryExtension[],
total: 2,
});
'getAllExtensions',
).mockResolvedValue(mockExtensions as unknown as RegistryExtension[]);
const mockExtensionManager = {
getExtensions: vi.fn().mockReturnValue([]),
@@ -83,7 +86,7 @@ describe('ExtensionRegistryView', () => {
it('should render error message on fetch failure', async () => {
vi.spyOn(
ExtensionRegistryClient.prototype,
'getExtensions',
'getAllExtensions',
).mockRejectedValue(new Error('Fetch failed'));
const mockExtensionManager = {
@@ -110,11 +113,8 @@ describe('ExtensionRegistryView', () => {
it('should call onSelect when an item is selected', async () => {
vi.spyOn(
ExtensionRegistryClient.prototype,
'getExtensions',
).mockResolvedValue({
extensions: mockExtensions as unknown as RegistryExtension[],
total: 2,
});
'getAllExtensions',
).mockResolvedValue(mockExtensions as unknown as RegistryExtension[]);
const onSelect = vi.fn();
const mockExtensionManager = {

View File

@@ -54,9 +54,11 @@ export function ExtensionRegistryView({
let active = true;
const fetchExtensions = async () => {
try {
const result = await client.getExtensions(1, 1000); // Fetch a large enough batch
// Fetch all extensions to enable comprehensive local fuzzy search.
// Display virtualization/pagination is handled by SearchableList.
const extensions = await client.getAllExtensions();
if (active) {
setExtensions(result.extensions);
setExtensions(extensions);
setLoading(false);
}
} catch (err) {