Skip to content

Beautiful Open-Source Form Builder

Fix saving edits to existing integration settings (#1385)

Julien Nahum436ed1c2ed07
diff --git a/AGENTS.md b/AGENTS.md
index f55a104b0..51c88cfc5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -73,7 +73,8 @@ Instructions for AI coding agents working in this repository.
## Documentation Changes
-- When behavior, configuration, or workflows change, update docs in `README.md`, `docs/`, or both.
+- Do not modify Markdown or documentation files as a routine part of a bug fix.
+- Update `README.md`, `docs/`, or other Markdown files only when the change creates a genuine documentation need (such as new usage, configuration, or workflow instructions), or when explicitly requested. Restoring intended behavior does not by itself require a documentation update.
## Safety
diff --git a/client/components/open/integrations/components/IntegrationModal.vue b/client/components/open/integrations/components/IntegrationModal.vue
index d4173b676..17060ec98 100644
--- a/client/components/open/integrations/components/IntegrationModal.vue
+++ b/client/components/open/integrations/components/IntegrationModal.vue
@@ -75,6 +75,7 @@
<script setup>
import { computed, toValue } from "vue"
+import cloneDeep from "clone-deep"
import { useComponentRegistry } from "~/composables/components/useComponentRegistry"
import PlanTag from "~/components/app/PlanTag.vue"
@@ -162,13 +163,14 @@ const initIntegrationData = () => {
status: props.formIntegrationId && formIntegration.value
? formIntegration.value.status
: 'active',
- data: props.formIntegrationId && formIntegration.value
- ? formIntegration.value.data ?? {}
+ // Query results are readonly; edits must stay local until Save.
+ data: props.formIntegrationId && formIntegration.value
+ ? cloneDeep(toRaw(formIntegration.value.data) ?? {})
: {},
logic: props.formIntegrationId && formIntegration.value
? !Array.isArray(formIntegration.value.logic) &&
formIntegration.value.logic
- ? formIntegration.value.logic
+ ? cloneDeep(toRaw(formIntegration.value.logic))
: null
: null,
oauth_id: formIntegration.value?.oauth_id ?? null,
diff --git a/client/test/nuxt/integration-modal.spec.ts b/client/test/nuxt/integration-modal.spec.ts
new file mode 100644
index 000000000..f57637a9f
--- /dev/null
+++ b/client/test/nuxt/integration-modal.spec.ts
@@ -0,0 +1,114 @@
+import { flushPromises, mount } from '@vue/test-utils'
+import { mockNuxtImport } from '@nuxt/test-utils/runtime'
+import { defineComponent, readonly, ref } from 'vue'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import IntegrationModal from '~/components/open/integrations/components/IntegrationModal.vue'
+
+const integrationMocks = vi.hoisted(() => ({ integrations: { value: [] as any[] }, create: vi.fn(), update: vi.fn(), success: vi.fn() }))
+vi.mock('~/api', () => ({ apiService: { mutate: vi.fn() } }))
+mockNuxtImport('useFormIntegrations', () => () => ({
+ list: () => ({ data: integrationMocks.integrations }),
+ createIntegration: () => ({ isPending: { value: false }, mutateAsync: integrationMocks.create }),
+ updateIntegration: () => ({ isPending: { value: false }, mutateAsync: integrationMocks.update }),
+}))
+mockNuxtImport('useAlert', () => () => ({ success: integrationMocks.success, error: vi.fn() }))
+mockNuxtImport('useCrisp', () => () => ({}))
+
+// Keep the real useForm and modal, with a small editor for nested values.
+vi.mock('~/composables/components/useComponentRegistry', () => ({
+ useComponentRegistry: () => ({ getIntegrationComponent: () => defineComponent({
+ name: 'TestIntegrationEditor',
+ props: ['integrationData'],
+ template: `<div>
+ <input aria-label="Send To" v-model="integrationData.data.send_to" />
+ <input aria-label="Subject" v-model="integrationData.data.subject" />
+ <input v-if="integrationData.data.appearance" aria-label="Header" v-model="integrationData.data.appearance.header" />
+ <input v-if="integrationData.logic" aria-label="Condition" v-model="integrationData.logic.conditions[0].value" />
+ </div>`,
+ }) }),
+}))
+
+function mountModal(formIntegrationId: number | null = 2) {
+ return mount(IntegrationModal, {
+ props: { show: true, form: { id: 1 }, integrationKey: 'email', integration: { id: 'email', name: 'Email Notification' }, formIntegrationId },
+ global: { stubs: {
+ UModal: { template: '<section><slot name="body" /><slot name="footer" /></section>' },
+ VForm: { template: '<div><slot /></div>' },
+ OverlayScrollbarsComponent: { template: '<div><slot /></div>' },
+ UButton: { template: '<button><slot /></button>' },
+ Icon: true, USkeleton: true,
+ } },
+ })
+}
+function cachedIntegration() {
+ return {
+ id: 2, integration_id: 'email', status: 'active', oauth_id: null,
+ data: { send_to: '[email protected]', subject: 'Old', appearance: { header: 'Old header' } },
+ logic: { conditions: [{ value: 'old condition' }] },
+ }
+}
+
+describe('integration editor query data isolation', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ vi.useFakeTimers()
+ integrationMocks.integrations = readonly(ref([cachedIntegration()]))
+ integrationMocks.update.mockResolvedValue({ message: 'Form Integration was updated.' })
+ integrationMocks.create.mockResolvedValue({ message: 'Form Integration was created.' })
+ })
+ afterEach(() => vi.useRealTimers())
+
+ it('submits edited settings and nested logic without changing the readonly cache', async () => {
+ const wrapper = mountModal()
+ await wrapper.get('[aria-label="Send To"]').setValue('[email protected]')
+ await wrapper.get('[aria-label="Subject"]').setValue('New')
+ await wrapper.get('[aria-label="Header"]').setValue('New header')
+ await wrapper.get('[aria-label="Condition"]').setValue('new condition')
+ expect(integrationMocks.integrations.value).toEqual([cachedIntegration()])
+ await wrapper.findAll('button')[0].trigger('click')
+ await flushPromises()
+ expect(integrationMocks.update).toHaveBeenCalledWith({
+ integration_id: 'email', status: 'active', oauth_id: null,
+ data: { send_to: '[email protected]', subject: 'New', appearance: { header: 'New header' } },
+ logic: { conditions: [{ value: 'new condition' }] },
+ })
+ expect(integrationMocks.success).toHaveBeenCalledWith('Form Integration was updated.')
+ expect(wrapper.emitted('close')).toHaveLength(1)
+ expect(integrationMocks.integrations.value).toEqual([cachedIntegration()])
+ wrapper.unmount()
+ })
+
+ it('leaves mutable cached settings unchanged when closing without saving', async () => {
+ integrationMocks.integrations = ref([cachedIntegration()])
+ const wrapper = mountModal()
+ await wrapper.get('[aria-label="Send To"]').setValue('[email protected]')
+ await wrapper.get('[aria-label="Condition"]').setValue('unsaved condition')
+ await wrapper.findAll('button')[1].trigger('click')
+ expect(integrationMocks.update).not.toHaveBeenCalled()
+ expect(integrationMocks.integrations.value).toEqual([cachedIntegration()])
+ wrapper.unmount()
+ })
+
+ it.each([{ logic: null }, { logic: [] }])('normalizes empty saved logic ($logic) and allows missing data', ({ logic }) => {
+ integrationMocks.integrations = readonly(ref([{ ...cachedIntegration(), data: null, logic }]))
+ const wrapper = mountModal()
+ const form = wrapper.findComponent({ name: 'TestIntegrationEditor' }).props('integrationData')
+ expect(form.data).toEqual({})
+ expect(form.logic).toBeNull()
+ wrapper.unmount()
+ })
+
+ it('creates an integration with editable defaults', async () => {
+ integrationMocks.integrations = readonly(ref([]))
+ const wrapper = mountModal(null)
+ await wrapper.get('[aria-label="Send To"]').setValue('[email protected]')
+ await wrapper.findAll('button')[0].trigger('click')
+ await flushPromises()
+ expect(integrationMocks.create).toHaveBeenCalledWith({
+ integration_id: 'email', status: 'active', oauth_id: null,
+ data: { send_to: '[email protected]' }, logic: null,
+ })
+ expect(integrationMocks.update).not.toHaveBeenCalled()
+ wrapper.unmount()
+ })
+})
diff --git a/scripts/npm-exceptions.json b/scripts/npm-exceptions.json
index f4e695af2..1495b4333 100644
--- a/scripts/npm-exceptions.json
+++ b/scripts/npm-exceptions.json
@@ -80,10 +80,10 @@
"node_modules/@eslint/eslintrc/node_modules/minimatch",
"node_modules/eslint/node_modules/minimatch"
],
- "reviewed": "2026-11-01",
+ "reviewed": "2026-11-02",
"expires": "2026-11-06",
"reason": "The advisory concerns optimizationLevel >= 2 and firstPhasePreProcess/globParts amplification. Locked minimatch 3.1.5 has neither that option nor that preprocessing function; its legacy CommonJS callable API is still required by these parents. A forced v11 override breaks those consumers. The package remains flagged by the scanner broad version range. Keep lint/build and CDK glob patterns repository-controlled. Do not expose legacy pattern evaluation to untrusted requests. Upgrade parents and remove this exact exception before expiry.",
- "upstreamLatest": "11.0.3"
+ "upstreamLatest": "11.0.4"
}
]
}