mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
* Run Local Baserow integrations as Agents * fix tests * feat(core): add reusable subject options endpoint * Add beta badge * fix(audit-log): require actor type with actor id * fix(audit-log): avoid duplicate actor export columns * fix(audit-log): guard deprecated actor fields * Restore the feature flag * fix tab alignement * fix(integrations): reject trashed authorized agents * Fix migration conflict * fix(audit-log): assert structured validation error * fix(database): support agent row deletion trash entries * fix(database): support agent row notifications * fix(core): enforce subject option permissions * chore: fix formatting after rebase * fix(core): include agents in member totals * fix(database): batch row history actor migration * fix(integrations): handle trashed authorized agents * fix(core): remove untranslated subject labels * chore: move nodes around * test: mock integration registry in AI agent service tests * fix: resolve database migration conflict * Add changelog entry * feat: use typed subjects for local Baserow integrations * fix: make audit actor migration retry-safe * fix: retain historical audit actors * Please linting * fix: use canonical local integration subjects * fix: order listed workspaces * fix: validate current user integration authorization * fix: preserve integration authorization on update * docs: clarify migration deployment compatibility * fix: paginate local baserow agent selection * fix: validate selectable subject options * fix: preserve integration authorization on update * fix: show saved integration user in subject dropdown * fix(enterprise): protect team subject options * fix(builder): redispatch data sources for trashed agents * fix(database): split row history actor backfill * fix(enterprise): require audit log actor type * fix(enterprise): use audit log actor options * fix(core): prevent blank agent names * fix(integrations): resolve migration conflict * fix(integrations): pass SMTP preparation context * docs: clarify migration rollout guidance * fix: handle trashed integration subjects * fix: reuse local integration authorization column * fix: allow unconfigured local integrations * fix: only update changed integration values * fix: cache local integration subjects * fix: sort field permission subjects by name * fix: include historical audit log actors * fix: center grow tab labels * chore: remove unused AI providers flag * fix: support agent file uploads * Please linter * fix: initialize integration edit values * fix: preserve integration authorization updates * fix: bound audit log actor pagination * fix: support legacy local integration fixtures
191 lines
6.2 KiB
JavaScript
191 lines
6.2 KiB
JavaScript
import { flushPromises } from '@vue/test-utils'
|
|
|
|
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import ConfigureDataSyncHistory from '@baserow/modules/database/components/dataSync/ConfigureDataSyncHistory'
|
|
import { createSyncJob } from '@baserow/test/unit/database/components/dataSync/helpers'
|
|
|
|
describe('ConfigureDataSyncHistory', () => {
|
|
let testApp = null
|
|
let mockServer = null
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
mockServer = testApp.mockServer
|
|
})
|
|
|
|
afterEach(async () => {
|
|
await testApp.afterEach()
|
|
})
|
|
|
|
const database = { id: 10, workspace: { id: 1 } }
|
|
const table = { id: 20, name: 'Synced', data_sync: { id: 42 } }
|
|
|
|
test('renders running, failed and finished runs', async () => {
|
|
mockServer.fakeJobs({
|
|
jobs: [
|
|
createSyncJob({ id: 3, state: 'started', progress_percentage: 40 }),
|
|
createSyncJob({
|
|
id: 2,
|
|
state: 'failed',
|
|
triggered_by: 'periodic',
|
|
user_name: 'Periodic user',
|
|
human_readable_error: 'The sync failed badly.',
|
|
}),
|
|
createSyncJob({ id: 1, state: 'finished' }),
|
|
],
|
|
})
|
|
|
|
const wrapper = await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
const items = wrapper.findAll('.data-sync-runs__item')
|
|
expect(items).toHaveLength(3)
|
|
|
|
expect(items.at(0).html()).toContain('job.stateStarted')
|
|
expect(items.at(0).find('.progress-bar').exists()).toBe(false)
|
|
expect(items.at(0).find('.data-sync-runs__duration').text()).toBe('40%')
|
|
|
|
expect(items.at(1).html()).toContain('job.stateFailed')
|
|
expect(items.at(1).html()).toContain('dataSyncRuns.triggerPeriodic')
|
|
expect(items.at(1).html()).toContain('dataSyncRuns.byUser')
|
|
|
|
// Error details are exposed through an accessible disclosure button.
|
|
const errorToggle = items.at(1).find('.data-sync-runs__head')
|
|
expect(errorToggle.element.tagName).toBe('BUTTON')
|
|
expect(errorToggle.attributes('type')).toBe('button')
|
|
expect(errorToggle.attributes('aria-expanded')).toBe('false')
|
|
expect(items.at(1).find('.data-sync-runs__error').exists()).toBe(false)
|
|
await errorToggle.trigger('click')
|
|
expect(errorToggle.attributes('aria-expanded')).toBe('true')
|
|
expect(items.at(1).find('.data-sync-runs__error').text()).toBe(
|
|
'The sync failed badly.'
|
|
)
|
|
|
|
expect(items.at(2).html()).toContain('job.stateFinished')
|
|
expect(items.at(2).html()).toContain('dataSyncRuns.triggerManual')
|
|
expect(items.at(2).find('.data-sync-runs__head').element.tagName).toBe(
|
|
'DIV'
|
|
)
|
|
})
|
|
|
|
test('seeds unfinished jobs into the job store', async () => {
|
|
mockServer.fakeJobs({
|
|
jobs: [
|
|
createSyncJob({ id: 1, state: 'started', progress_percentage: 40 }),
|
|
createSyncJob({ id: 3, state: 'finished' }),
|
|
],
|
|
})
|
|
|
|
await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
const storeJobIds = testApp.store.getters['job/getAll'].map((job) => job.id)
|
|
expect(storeJobIds).toContain(1)
|
|
expect(storeJobIds).not.toContain(3)
|
|
})
|
|
|
|
test('shows the empty state when there are no runs', async () => {
|
|
mockServer.fakeJobs({ jobs: [] })
|
|
|
|
const wrapper = await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.html()).toContain('dataSyncRuns.noRuns')
|
|
})
|
|
|
|
test('paginates when there are more runs than the page size', async () => {
|
|
mockServer.fakeJobs({
|
|
jobs: Array.from({ length: 10 }, (_, index) =>
|
|
createSyncJob({ id: 100 - index, state: 'finished' })
|
|
),
|
|
count: 25,
|
|
})
|
|
|
|
const wrapper = await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.findAll('.data-sync-runs__item')).toHaveLength(10)
|
|
expect(wrapper.find('.paginator').exists()).toBe(true)
|
|
})
|
|
|
|
test('hides the paginator when everything fits one page', async () => {
|
|
mockServer.fakeJobs({
|
|
jobs: [createSyncJob({ id: 1, state: 'finished' })],
|
|
count: 1,
|
|
})
|
|
|
|
const wrapper = await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.paginator').exists()).toBe(false)
|
|
})
|
|
|
|
test('shows an error when the runs cannot be loaded', async () => {
|
|
testApp.dontFailOnErrorResponses()
|
|
mockServer.mock
|
|
.onGet('jobs/')
|
|
.reply(400, { error: 'ERROR_SOMETHING', detail: '' })
|
|
|
|
const wrapper = await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.alert').exists()).toBe(true)
|
|
expect(wrapper.find('.data-sync-runs').exists()).toBe(false)
|
|
})
|
|
|
|
test('hides a stale loading error after a successful retry', async () => {
|
|
testApp.dontFailOnErrorResponses()
|
|
const firstPage = Array.from({ length: 10 }, (_, index) =>
|
|
createSyncJob({ id: 100 - index, state: 'finished' })
|
|
)
|
|
const requestParams = {
|
|
type: 'sync_data_sync_table',
|
|
sync_data_sync_table_data_sync_id: table.data_sync.id,
|
|
limit: 10,
|
|
}
|
|
mockServer.mock
|
|
.onGet('jobs/', { params: { ...requestParams, offset: 0 } })
|
|
.reply(200, {
|
|
jobs: firstPage,
|
|
count: 20,
|
|
})
|
|
mockServer.mock
|
|
.onGet('jobs/', { params: { ...requestParams, offset: 10 } })
|
|
.replyOnce(400, { error: 'ERROR_SOMETHING', detail: '' })
|
|
mockServer.mock
|
|
.onGet('jobs/', { params: { ...requestParams, offset: 10 } })
|
|
.replyOnce(200, {
|
|
jobs: [createSyncJob({ id: 1, state: 'finished' })],
|
|
count: 20,
|
|
})
|
|
|
|
const wrapper = await testApp.mount(ConfigureDataSyncHistory, {
|
|
propsData: { database, table },
|
|
})
|
|
await flushPromises()
|
|
|
|
const nextPageButton = () => wrapper.findAll('.paginator__button').at(1)
|
|
await nextPageButton().trigger('click')
|
|
await flushPromises()
|
|
expect(wrapper.find('.alert').exists()).toBe(true)
|
|
|
|
await nextPageButton().trigger('click')
|
|
await flushPromises()
|
|
expect(wrapper.find('.alert').exists()).toBe(false)
|
|
expect(wrapper.findAll('.data-sync-runs__item')).toHaveLength(1)
|
|
expect(wrapper.find('.paginator__content-input').element.value).toBe('2')
|
|
})
|
|
})
|