Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-redundant-undefined": "^1.0.0",
"eslint-plugin-simple-import-sort": "^14.0.0",
"eslint-plugin-sonarjs": "^4.0.3",
"eslint-plugin-sonarjs": "^4.2.0",
"eslint-plugin-svelte": "^3.20.0",
"eslint-plugin-unicorn": "^65.0.1",
"globals": "^17.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/managers/GPUManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ beforeEach(() => {

test('post constructor should have no items', () => {
const manager = new GPUManager(rpcExtensionMock);
expect(manager.getAll().length).toBe(0);
expect(manager.getAll()).toHaveLength(0);
});

test('no controller should return empty array', async () => {
Expand Down
24 changes: 12 additions & 12 deletions packages/backend/src/managers/apiServer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe.each([undefined, true, false])('/api/pull endpoint, stream is %o', stre
} else {
const res = await req.expect(200);
const lines = res.text.split('\n');
expect(lines.length).toEqual(3);
expect(lines).toHaveLength(3);
expect(lines[0]).toEqual('{"status":"pulling manifest"}');
expect(lines[1]).toEqual('{"error":"pull model manifest: file does not exist"}');
expect(lines[2]).toEqual('');
Expand All @@ -272,7 +272,7 @@ describe.each([undefined, true, false])('/api/pull endpoint, stream is %o', stre
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(3);
expect(lines).toHaveLength(3);
expect(lines[0]).toEqual('{"status":"pulling manifest"}');
expect(lines[1]).toEqual('{"status":"success"}');
expect(lines[2]).toEqual('');
Expand Down Expand Up @@ -308,7 +308,7 @@ describe.each([undefined, true, false])('/api/pull endpoint, stream is %o', stre
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(4);
expect(lines).toHaveLength(4);
expect(lines[0]).toEqual('{"status":"pulling manifest"}');
expect(lines[1]).toEqual(
'{"status":"pulling 123456","digest":"sha256:123456","total":100000,"completed":100000000}',
Expand Down Expand Up @@ -350,7 +350,7 @@ describe.each([undefined, true, false])('/api/pull endpoint, stream is %o', stre
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(4);
expect(lines).toHaveLength(4);
expect(lines[0]).toEqual('{"status":"pulling manifest"}');
expect(lines[1]).toEqual(
'{"status":"pulling 123456","digest":"sha256:123456","total":100000,"completed":100000000}',
Expand All @@ -375,7 +375,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200);
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"error":"chat: model \\"unknown-model-name\\" does not exist"}');
expect(lines[1]).toEqual('');
}
Expand All @@ -396,7 +396,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"error":"chat: model \\"model-name\\" not found, try pulling it first"}');
expect(lines[1]).toEqual('');
}
Expand Down Expand Up @@ -481,7 +481,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"model":"model-name","response":"","done":true,"done_reason":"load"}');
expect(lines[1]).toEqual('');
}
Expand Down Expand Up @@ -524,7 +524,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"model":"model-name","response":"","done":true,"done_reason":"load"}');
expect(lines[1]).toEqual('');
}
Expand Down Expand Up @@ -590,7 +590,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"model":"model-name","response":"","done":true,"done_reason":"load"}');
expect(lines[1]).toEqual('');
}
Expand Down Expand Up @@ -632,7 +632,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"model":"model-name","response":"","done":true,"done_reason":"load"}');
expect(lines[1]).toEqual('');
}
Expand Down Expand Up @@ -676,7 +676,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(2);
expect(lines).toHaveLength(2);
expect(lines[0]).toEqual('{"model":"model-name","response":"","done":true,"done_reason":"load"}');
expect(lines[1]).toEqual('');
}
Expand Down Expand Up @@ -821,7 +821,7 @@ describe.each([undefined, true, false])('stream is %o', stream => {
} else {
const res = await req.expect(200).expect('transfer-encoding', 'chunked');
const lines = res.text.split('\n');
expect(lines.length).toEqual(expectedStreamed.length);
expect(lines).toHaveLength(expectedStreamed.length);
for (const [i, line] of lines.entries()) {
expect(line).toEqual(expectedStreamed[i]);
}
Expand Down
13 changes: 7 additions & 6 deletions packages/backend/src/managers/inference/inferenceManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe('init Inference Manager', () => {
interval: 200,
timeout: 2000,
});
expect(manager.isInitialize()).toBeTruthy();
});

test('should have listed containers', async () => {
Expand All @@ -183,7 +184,7 @@ describe('init Inference Manager', () => {
]);

const inferenceManager = await getInitializedInferenceManager();
expect(inferenceManager.getServers().length).toBe(0);
expect(inferenceManager.getServers()).toHaveLength(0);
});

test('should have adopted the existing container', async () => {
Expand Down Expand Up @@ -242,7 +243,7 @@ describe('init Inference Manager', () => {

const inferenceManager = await getInitializedInferenceManager();
const servers = inferenceManager.getServers();
expect(servers.length).toBe(2);
expect(servers).toHaveLength(2);
expect(servers.some(server => server.container.containerId === 'dummyContainerId-1')).toBeTruthy();
expect(servers.some(server => server.container.containerId === 'dummyContainerId-3')).toBeTruthy();
});
Expand Down Expand Up @@ -346,7 +347,7 @@ describe('Start Inference Server', () => {
expect(containerEngine.startContainer).toHaveBeenCalledWith('dummyEngineId', 'dummyId');

const servers = inferenceManager.getServers();
expect(servers.length).toBe(1);
expect(servers).toHaveLength(1);
expect(servers[0].status).toBe('running');
});
});
Expand Down Expand Up @@ -378,7 +379,7 @@ describe('Stop Inference Server', () => {
expect(containerEngine.stopContainer).toHaveBeenCalledWith('dummyEngineId', 'dummyId');

const servers = inferenceManager.getServers();
expect(servers.length).toBe(1);
expect(servers).toHaveLength(1);
expect(servers[0].status).toBe('stopped');
});
});
Expand Down Expand Up @@ -408,7 +409,7 @@ describe('Delete Inference Server', () => {
expect(containerEngine.deleteContainer).toHaveBeenCalledWith('dummyEngineId', 'dummyId');

const servers = inferenceManager.getServers();
expect(servers.length).toBe(0);
expect(servers).toHaveLength(0);
});

test('valid stopped containerId', async () => {
Expand All @@ -435,7 +436,7 @@ describe('Delete Inference Server', () => {
expect(containerEngine.deleteContainer).toHaveBeenCalledWith('dummyEngineId', 'dummyId');

const servers = inferenceManager.getServers();
expect(servers.length).toBe(0);
expect(servers).toHaveLength(0);
});
});

Expand Down
19 changes: 6 additions & 13 deletions packages/backend/src/managers/monitoringManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function simplifiedCallback(callback: (arg: ContainerStatsInfo) => void, cpu: nu
test('expect constructor to do nothing', () => {
const manager = new MonitoringManager(rpcExtensionMock);
expect(containerEngine.statsContainer).not.toHaveBeenCalled();
expect(manager.getStats().length).toBe(0);
expect(manager.getStats()).toHaveLength(0);
expect(rpcExtensionMock.fire).not.toHaveBeenCalled();
});

Expand All @@ -74,13 +74,6 @@ test('expect monitor method to start stats container', async () => {
expect(containerEngine.statsContainer).toHaveBeenCalledWith('dummyEngineId', 'randomContainerId', expect.anything());
});

test('expect monitor method to start stats container', async () => {
const manager = new MonitoringManager(rpcExtensionMock);
await manager.monitor('randomContainerId', 'dummyEngineId');

expect(containerEngine.statsContainer).toHaveBeenCalledWith('dummyEngineId', 'randomContainerId', expect.anything());
});

test('expect dispose to dispose stats container', async () => {
const manager = new MonitoringManager(rpcExtensionMock);
const fakeDisposable = vi.fn();
Expand Down Expand Up @@ -149,8 +142,8 @@ test('expect stats to cumulate', async () => {
simplifiedCallback(mCallback, 3, 3);

const stats = manager.getStats();
expect(stats.length).toBe(1);
expect(stats[0].stats.length).toBe(4);
expect(stats).toHaveLength(1);
expect(stats[0].stats).toHaveLength(4);
});

test('expect old stats to be removed', async () => {
Expand Down Expand Up @@ -179,8 +172,8 @@ test('expect old stats to be removed', async () => {
simplifiedCallback(mCallback, 3, 3);

const stats = manager.getStats();
expect(stats.length).toBe(1);
expect(stats[0].stats.length).toBe(3);
expect(stats).toHaveLength(1);
expect(stats[0].stats).toHaveLength(3);
});

test('expect stats to be disposed if stats result is an error', async () => {
Expand All @@ -202,6 +195,6 @@ test('expect stats to be disposed if stats result is an error', async () => {
mCallback({ cause: 'container is stopped' } as unknown as ContainerStatsInfo);

const stats = manager.getStats();
expect(stats.length).toBe(0);
expect(stats).toHaveLength(0);
expect(fakeDisposable).toHaveBeenCalled();
});
20 changes: 10 additions & 10 deletions packages/backend/src/managers/playgroundV2Manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ test('manager should be properly initialized', () => {
cancellationTokenRegistryMock,
mcpServerManager,
);
expect(manager.getConversations().length).toBe(0);
expect(manager.getConversations()).toHaveLength(0);
});

test('submit should throw an error if the server is stopped', async () => {
Expand Down Expand Up @@ -186,11 +186,11 @@ test('create playground should create conversation.', async () => {
cancellationTokenRegistryMock,
mcpServerManager,
);
expect(manager.getConversations().length).toBe(0);
expect(manager.getConversations()).toHaveLength(0);
await manager.createPlayground('playground 1', { id: 'model-1' } as ModelInfo, 'tracking-1');

const conversations = manager.getConversations();
expect(conversations.length).toBe(1);
expect(conversations).toHaveLength(1);
});

test('valid submit should create IPlaygroundMessage and notify the webview', async () => {
Expand Down Expand Up @@ -255,8 +255,8 @@ test('valid submit should create IPlaygroundMessage and notify the webview', asy

const conversations = manager.getConversations();

expect(conversations.length).toBe(1);
expect(conversations[0].messages.length).toBe(2);
expect(conversations).toHaveLength(1);
expect(conversations[0].messages).toHaveLength(2);
expect(conversations[0].messages[0]).toStrictEqual({
content: 'dummyUserInput',
id: expect.anything(),
Expand Down Expand Up @@ -332,8 +332,8 @@ test('error', async () => {

const conversations = manager.getConversations();

expect(conversations.length).toBe(1);
expect(conversations[0].messages.length).toBe(2);
expect(conversations).toHaveLength(1);
expect(conversations[0].messages).toHaveLength(2);
expect(conversations[0].messages[0]).toStrictEqual({
content: 'dummyUserInput',
id: expect.anything(),
Expand Down Expand Up @@ -528,7 +528,7 @@ test('delete conversation should delete the conversation', async () => {
cancellationTokenRegistryMock,
mcpServerManager,
);
expect(manager.getConversations().length).toBe(0);
expect(manager.getConversations()).toHaveLength(0);
await manager.createPlayground(
'a name',
{
Expand All @@ -539,9 +539,9 @@ test('delete conversation should delete the conversation', async () => {
);

const conversations = manager.getConversations();
expect(conversations.length).toBe(1);
expect(conversations).toHaveLength(1);
manager.deleteConversation(conversations[0].id);
expect(manager.getConversations().length).toBe(0);
expect(manager.getConversations()).toHaveLength(0);
expect(rpcExtensionMock.fire).toHaveBeenCalled();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/managers/podmanConnection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ describe('container connection event', () => {
});

// ensure it has properly been added
expect(podmanConnection.getContainerProviderConnectionInfo().length).toBe(1);
expect(podmanConnection.getContainerProviderConnectionInfo()).toHaveLength(1);
});

test('onDidRegisterContainerConnection should fire PodmanConnectionEvent', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/managers/recipes/BuilderManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ describe('buildImages', () => {
state: 'success',
labels: {},
});
expect(imageInfoList.length).toBe(1);
expect(imageInfoList[0].ports.length).toBe(1);
expect(imageInfoList).toHaveLength(1);
expect(imageInfoList[0].ports).toHaveLength(1);
expect(imageInfoList[0].ports[0]).equals('8080');

expect(containerEngine.buildImage).toHaveBeenCalledWith(
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/managers/recipes/PodManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ test('getPodsWithLabels should only return pods with proper labels', async () =>
},
] as unknown as PodInfo[]);
const pods = await new PodManager().getPodsWithLabels(['dummy-key']);
expect(pods.length).toBe(2);
expect(pods).toHaveLength(2);
expect(pods.find(pod => pod.Id === 'pod-id-1')).toBeDefined();
expect(pods.find(pod => pod.Id === 'pod-id-2')).toBeDefined();
expect(pods.find(pod => pod.Id === 'pod-id-3')).toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ beforeEach(() => {

test('should not have any repositories by default', () => {
const localRepositories = new LocalRepositoryRegistry(rpcExtensionMock, '/appUserDirectory', catalogManagerMock);
expect(localRepositories.getLocalRepositories().length).toBe(0);
expect(localRepositories.getLocalRepositories()).toHaveLength(0);
});

test('should notify webview when register', () => {
Expand Down
14 changes: 7 additions & 7 deletions packages/backend/src/registries/TaskRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ beforeEach(() => {

test('should not have any tasks by default', () => {
const taskRegistry = new TaskRegistry(rpcExtension);
expect(taskRegistry.getTasks().length).toBe(0);
expect(taskRegistry.getTasks()).toHaveLength(0);
});

test('dispose should cleanup all tasks', () => {
Expand Down Expand Up @@ -66,8 +66,8 @@ test('should get tasks by label', () => {
const tasksWithIndex1 = taskRegistry.getTasksByLabels({ index: '1' });
const tasksWithIndex2 = taskRegistry.getTasksByLabels({ index: '2' });

expect(tasksWithIndex1.length).toBe(1);
expect(tasksWithIndex2.length).toBe(1);
expect(tasksWithIndex1).toHaveLength(1);
expect(tasksWithIndex2).toHaveLength(1);
expect(tasksWithIndex1[0].name).toBe('random-1');
expect(tasksWithIndex2[0].name).toBe('random-2');
});
Expand All @@ -80,7 +80,7 @@ test('should delete tasks by label', () => {

taskRegistry.deleteByLabels({ index: '1' });

expect(taskRegistry.getTasks().length).toBe(1);
expect(taskRegistry.getTasks()).toHaveLength(1);
expect(taskRegistry.getTasks()[0].name).toBe('random-2');
});

Expand All @@ -95,8 +95,8 @@ test('should get tasks by multiple labels', () => {
const tasksWithHighPriority = taskRegistry.getTasksByLabels({ priority: 'high' });
const tasksWithTypeAAndHighPriority = taskRegistry.getTasksByLabels({ type: 'A', priority: 'high' });

expect(tasksWithTypeA.length).toBe(2);
expect(tasksWithHighPriority.length).toBe(1);
expect(tasksWithTypeAAndHighPriority.length).toBe(1);
expect(tasksWithTypeA).toHaveLength(2);
expect(tasksWithHighPriority).toHaveLength(1);
expect(tasksWithTypeAAndHighPriority).toHaveLength(1);
expect(tasksWithTypeAAndHighPriority[0].name).toBe('task-1');
});
Loading
Loading