Add protected name validation test

This commit is contained in:
Adria Navarro 2024-07-31 17:07:56 +02:00
parent 38da9012ea
commit 785ab12237
1 changed files with 37 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import { context, docIds, events } from "@budibase/backend-core"
import { PROTECTED_EXTERNAL_COLUMNS } from "@budibase/shared-core"
import {
AutoFieldSubType,
BBReferenceFieldSubType,
@ -1053,6 +1054,42 @@ describe.each([
},
})
})
isInternal &&
it.each(PROTECTED_EXTERNAL_COLUMNS)(
"don't allow protected names (%s)",
async columnName => {
const result = await config.api.table.validateNewTableImport(
[
{
id: generator.natural(),
name: generator.first(),
[columnName]: generator.word(),
},
],
{
...basicSchema,
[columnName]: {
name: columnName,
type: FieldType.STRING,
},
}
)
expect(result).toEqual({
allValid: false,
errors: {
[columnName]: `${columnName} is a protected name`,
},
invalidColumns: [],
schemaValidation: {
id: true,
name: true,
[columnName]: false,
},
})
}
)
})
describe("validateExistingTableImport", () => {