Skip to content

Commit 583c9b5

Browse files
PoulphunterPoulphunter
authored andcommitted
add test
1 parent aac2ea3 commit 583c9b5

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

e2e/start.spec.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
function error_def(page) {
4+
const consoleErrors: unknown[] = [];
5+
page.on('console', (msg) => {
6+
if (msg.type() === 'error') {
7+
consoleErrors.push(msg.text());
8+
}
9+
});
10+
return consoleErrors;
11+
}
12+
test('check title', async ({ page }) => {
13+
const consoleErrors: unknown[] = error_def(page);
14+
await page.goto('');
15+
16+
// Expect a title "to contain" a substring.
17+
await expect(page).toHaveTitle(/llama.cpp - chat/);
18+
expect(consoleErrors).toEqual([]);
19+
});
20+
21+
test('Verify Main Page UI Elements and Default Values', async ({ page }) => {
22+
const consoleErrors: unknown[] = error_def(page);
23+
await page.goto('');
24+
await page.getByText('llama.cpp').click();
25+
await expect(
26+
page.locator('div').filter({ hasText: /^Settings$/ })
27+
).toBeVisible();
28+
await expect(
29+
page.getByRole('heading', { name: 'Conversations' })
30+
).toBeVisible();
31+
await expect(
32+
page.getByRole('textbox', { name: 'Type a message (Shift+Enter' })
33+
).toBeVisible();
34+
await expect(page.getByRole('textbox', { name: 'Default: 0.8' })).toHaveValue(
35+
'0.8'
36+
);
37+
await expect(
38+
page.getByRole('textbox', { name: 'Default: 1.75' })
39+
).toHaveValue('1.75');
40+
expect(consoleErrors).toEqual([]);
41+
});
42+
43+
test('test chat', async ({ page }) => {
44+
const consoleErrors: unknown[] = error_def(page);
45+
await page.goto('');
46+
await page
47+
.getByRole('textbox', { name: 'Type a message (Shift+Enter' })
48+
.click();
49+
await page
50+
.getByRole('textbox', { name: 'Type a message (Shift+Enter' })
51+
.fill('test');
52+
await page.getByRole('button', { name: 'Send' }).click();
53+
await expect(page.locator('#messages-list')).toContainText(
54+
'Hello! It seems like you sent a "test" message. Could you please clarify what you need help with? I\'m here to assist with any questions or tasks you have! 😊'
55+
);
56+
await expect(page.locator('#messages-list')).toContainText('🔄 Regenerate');
57+
await expect(page.locator('#messages-list')).toContainText('📋 Copy');
58+
expect(consoleErrors).toEqual([]);
59+
});

0 commit comments

Comments
 (0)