mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +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>
99 lines
3.1 KiB
JavaScript
99 lines
3.1 KiB
JavaScript
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import ButtonText from '@baserow/modules/core/components/ButtonText'
|
|
|
|
describe('ButtonText.vue', () => {
|
|
it('renders the button text', async () => {
|
|
const text = 'Click me'
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
slots: {
|
|
default: text,
|
|
},
|
|
})
|
|
expect(wrapper.text()).toMatch(text)
|
|
})
|
|
|
|
it('renders an anchor tag when href prop is provided', async () => {
|
|
const href = 'https://example.com'
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { href },
|
|
})
|
|
expect(wrapper.element.tagName).toBe('A')
|
|
})
|
|
|
|
it('keeps the native button type unset by default', async () => {
|
|
const wrapper = await mountSuspended(ButtonText)
|
|
expect(wrapper.attributes('type')).toBeUndefined()
|
|
})
|
|
|
|
it('only submits the enclosing form when configured as a submit button', async () => {
|
|
const form = document.createElement('form')
|
|
const submit = vi.fn((event) => event.preventDefault())
|
|
form.addEventListener('submit', submit)
|
|
document.body.appendChild(form)
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { buttonType: 'button' },
|
|
attachTo: form,
|
|
})
|
|
|
|
try {
|
|
wrapper.element.click()
|
|
expect(submit).not.toHaveBeenCalled()
|
|
|
|
await wrapper.setProps({ buttonType: 'submit' })
|
|
wrapper.element.click()
|
|
expect(submit).toHaveBeenCalledOnce()
|
|
} finally {
|
|
wrapper.unmount()
|
|
form.remove()
|
|
}
|
|
})
|
|
|
|
it.each([{ tag: 'a' }, { href: 'https://example.com' }])(
|
|
'does not forward the native button type to a link with props %o',
|
|
async (props) => {
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { ...props, buttonType: 'button' },
|
|
})
|
|
expect(wrapper.element.tagName).toBe('A')
|
|
expect(wrapper.attributes('type')).toBeUndefined()
|
|
}
|
|
)
|
|
|
|
it('emits the click event when clicked', async () => {
|
|
const wrapper = await mountSuspended(ButtonText)
|
|
wrapper.vm.$emit('click')
|
|
expect(wrapper.emitted().click).toBeTruthy()
|
|
})
|
|
|
|
it('disables the button when disabled prop is true', async () => {
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { disabled: true },
|
|
})
|
|
expect(wrapper.attributes('disabled')).toBeDefined()
|
|
})
|
|
|
|
it('renders the button with the correct class when type prop is provided', async () => {
|
|
const type = 'secondary'
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { type },
|
|
})
|
|
expect(wrapper.classes()).toContain(`button-text--${type}`)
|
|
})
|
|
|
|
it('renders the button with the correct size when size prop is provided', async () => {
|
|
const size = 'small'
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { size },
|
|
})
|
|
expect(wrapper.classes()).toContain(`button-text--${size}`)
|
|
})
|
|
|
|
it('renders the button with the correct icon when icon prop is provided', async () => {
|
|
const icon = 'iconoir-plus'
|
|
const wrapper = await mountSuspended(ButtonText, {
|
|
props: { icon },
|
|
})
|
|
expect(wrapper.find('.button-text__icon').classes()).toContain(`${icon}`)
|
|
})
|
|
})
|