mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(agent): configure Agent instructions and model Adds the Agent settings fields, readiness and configuration endpoints, an autosaving configuration sidebar and the settings permission. Settings are copied with the Agent and exported only by members who can read them. * test(agent): share Agent page setup and mock helpers Both page specs reuse one setup and one-line route mocks, and API tests share an authenticated client. * fix(agent): lock parent before configuration updates * fix(agent): limit model availability checks to settings readers * refactor(agent): read Agent readiness from the application Readiness travels with the application payload instead of a separate readiness endpoint, so the page load and realtime updates keep it current. The configuration form also stays stable while editing. It no longer reloads on unrelated application updates, saves text fields on blur and selections on change, restores a blank name instead of blocking navigation, keeps the current Agent selected when the save before a switch fails, and ignores re-selecting the current provider. The export permission test now goes through ExportApplicationsActionType. * fix(agent): tighten the Agent configuration API The configuration endpoint now serves only instructions, provider and model behind agent_application.read_configuration, which saving also requires. Renames go through the standard application update, the views return their declared serializers, the length limits come from the model, and the endpoints are documented in the API schema. * fix(agent): rename through the application and fit the assistant panel The configuration sidebar renames the Agent through the regular application update, follows the Agent column width with container queries, offers Retry first without an empty actions row, keeps its focus outline on its own buttons, and names an unavailable provider. The first load starts on mount, and the specs mount with a route record and find fields by label. * fix(agent): keep configuration edits across token refreshes The page reset itself whenever a token refresh reassigned the user, because the watch compared a new array each time; it now watches the Agent and user ids by value. The configuration payload names its readiness `readiness`, like the application payload, and the redundant readiness tests are gone. * fix(agent): explain configuration section errors * fix(agent): address configuration review feedback * refactor(agent): reuse shared menu and button components * fix(agent): align sidebar separators and back control with design * fix(agent): match sidebar close control to design * Remove name input loading spinner and added newline * remove double validation --------- Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
import { afterEach, beforeEach, describe, expect, test } from 'vitest'
|
|
import { flushPromises } from '@vue/test-utils'
|
|
import {
|
|
createAgentPage,
|
|
deferredReply,
|
|
destroyAgentPage,
|
|
mockAvailability,
|
|
warning,
|
|
withoutConfiguration,
|
|
} from './helpers'
|
|
|
|
describe('Agent model availability', () => {
|
|
let testApp, allowed, mount
|
|
|
|
beforeEach(async () => {
|
|
;({ testApp, allowed, mount } = await createAgentPage())
|
|
})
|
|
|
|
afterEach(() => destroyAgentPage(testApp))
|
|
|
|
const modelRequests = () =>
|
|
testApp.mock.history.get.filter(({ url }) => url === '/workspaces/')
|
|
|
|
test('loads models when configuration access is granted', async () => {
|
|
allowed.value = withoutConfiguration
|
|
const wrapper = await mount()
|
|
expect(modelRequests()).toHaveLength(0)
|
|
|
|
allowed.value = () => true
|
|
await flushPromises()
|
|
|
|
expect(modelRequests()).toHaveLength(1)
|
|
expect(wrapper.find('.agent-configuration').exists()).toBe(true)
|
|
expect(warning(wrapper).exists()).toBe(false)
|
|
})
|
|
|
|
test('ignores a pending model failure after configuration access is revoked', async () => {
|
|
testApp.dontFailOnErrorResponses()
|
|
const models = deferredReply()
|
|
mockAvailability(testApp, models.reply)
|
|
const wrapper = await mount()
|
|
|
|
allowed.value = withoutConfiguration
|
|
await flushPromises()
|
|
models.resolve(500, {})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.agent-configuration').exists()).toBe(false)
|
|
expect(warning(wrapper).exists()).toBe(false)
|
|
})
|
|
})
|