mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-06 20:43:27 -05:00
The word "Memory" named collections of documents, notes about the person, and RAM in the same navigation. Collections are now Knowledge: the sidebar item, the page title and text, the Home action, the agent form section and the chat tool group. The tool group "Memory and profile changes" is now "Suggested changes", since it is the generic ask-first mechanism for notes, rules, skills, pages and the dashboard. The Settings section "Memory and models" is now "Models in memory". Only display strings change. Ids, routes, locale keys, group ids, grants and stored data stay as they are. All nine locales are updated; the docs name the Knowledge page and say which search the default engine does. Assisted-by: Claude:claude-sonnet-5-5
67 lines
3.3 KiB
JavaScript
67 lines
3.3 KiB
JavaScript
import { test, expect } from './coverage-fixtures.js'
|
|
|
|
// Knowledge page (src/pages/Collections.jsx) on the real test server. The collections
|
|
// service of the test server never finishes starting, so the list answers 503;
|
|
// the empty-state cases stub an empty list, and one case checks that a 503 is
|
|
// shown as "starting", not as an empty library.
|
|
test.describe('Collections page', () => {
|
|
test.beforeEach(async ({ page }, info) => {
|
|
if (!info.title.includes('starting')) {
|
|
await page.route(/\/api\/collections(\?.*)?$/, route => route.fulfill({ contentType: 'application/json', body: JSON.stringify({ collections: [] }) }))
|
|
}
|
|
await page.goto('/app/collections')
|
|
})
|
|
|
|
test('a knowledge service that is still starting is not shown as an empty library', async ({ page }) => {
|
|
await page.route(/\/api\/collections(\?.*)?$/, route => route.fulfill({ status: 503, contentType: 'application/json', body: JSON.stringify({ error: 'collections are starting, please retry shortly' }) }))
|
|
await page.goto('/app/collections')
|
|
await expect(page.getByTestId('memory-starting')).toContainText('Knowledge is starting.')
|
|
await expect(page.getByTestId('memory-empty')).toHaveCount(0)
|
|
await expect(page.getByTestId('memory-starting').getByRole('button', { name: 'Try again' })).toBeVisible()
|
|
})
|
|
|
|
test('renders knowledge with an empty state and create control', async ({ page }) => {
|
|
await expect(page).toHaveURL(/\/app\/collections$/)
|
|
await expect(page.getByRole('heading', { name: 'Knowledge', exact: true })).toBeVisible()
|
|
await expect(page.getByText(/Knowledge holds documents an agent can search/i)).toBeVisible()
|
|
await expect(page.getByRole('button', { name: 'New collection' }).first()).toBeVisible()
|
|
})
|
|
|
|
test('new-collection name field accepts input', async ({ page }) => {
|
|
await page.getByRole('button', { name: 'New collection' }).first().click()
|
|
const input = page.getByLabel('New collection name')
|
|
await expect(input).toBeVisible()
|
|
await input.fill('my-kb')
|
|
await expect(input).toHaveValue('my-kb')
|
|
})
|
|
|
|
test('posts the source update interval as a JSON number', async ({ page }) => {
|
|
const collectionName = 'interval-regression'
|
|
const collectionPath = encodeURIComponent(collectionName)
|
|
let postedBody
|
|
|
|
await page.route(`**/api/collections/${collectionPath}/entries`, route =>
|
|
route.fulfill({ contentType: 'application/json', body: JSON.stringify({ entries: [] }) }))
|
|
await page.route(`**/api/collections/${collectionPath}/sources`, async route => {
|
|
if (route.request().method() === 'POST') {
|
|
postedBody = route.request().postDataJSON()
|
|
await route.fulfill({ contentType: 'application/json', body: JSON.stringify({ status: 'ok' }) })
|
|
} else {
|
|
await route.fulfill({ contentType: 'application/json', body: JSON.stringify({ sources: [] }) })
|
|
}
|
|
})
|
|
|
|
await page.goto(`/app/collections/${collectionPath}`)
|
|
await page.getByTestId('add-source-toggle').click()
|
|
await page.locator('#source-url').fill('https://example.com/feed')
|
|
await page.locator('#source-interval').fill('3600')
|
|
await page.getByRole('button', { name: 'Add URL' }).click()
|
|
|
|
await expect.poll(() => postedBody).toEqual({
|
|
url: 'https://example.com/feed',
|
|
update_interval: 3600,
|
|
})
|
|
expect(typeof postedBody.update_interval).toBe('number')
|
|
})
|
|
})
|