This commit is contained in:
2026-09-04 13:46:18 +03:00
parent f5c9132422
commit de5a6ed3a2
7 changed files with 181 additions and 3 deletions
@@ -40,4 +40,40 @@ test.group('Custom fields API', (group) => {
response.assertStatus(200)
assert.equal(response.body().data[0].key, 'customer_tier')
})
test('creates a contact field owned by the resolved tenant', async ({ assert, client }) => {
const { admin, token } = await createAdminWithToken([])
const tenant = await Tenant.create({
name: 'Create Metadata GmbH',
slug: 'create-metadata-gmbh',
status: 'active',
})
await tenant.related('admins').attach([admin.id])
const response = await client
.post('/api/custom-fields')
.header('X-Tenant-Id', String(tenant.id))
.bearerToken(token)
.json({
entity_type: 'contact',
name: 'Customer tier',
key: 'customer_tier',
field_type: 'select',
required: true,
options: { values: ['bronze', 'silver', 'gold'] },
})
response.assertStatus(201)
assert.deepInclude(response.body().data, {
entity_type: 'contact',
name: 'Customer tier',
key: 'customer_tier',
field_type: 'select',
required: true,
options: { values: ['bronze', 'silver', 'gold'] },
status: 'active',
})
const created = await CustomField.find(response.body().data.id)
assert.equal(created?.tenantId, tenant.id)
})
})