Skip to content

Commit

Permalink
Add Prerelease tag for Users Role (#2930)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-codaio authored Mar 13, 2024
1 parent 75aa33a commit 76b0eda
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/testing/upload_validation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codahq/packs-sdk",
"version": "1.7.6-prerelease.2",
"version": "1.7.6-prerelease.3",
"license": "MIT",
"workspaces": [
"dev/eslint"
Expand Down
28 changes: 28 additions & 0 deletions test/upload_validation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4735,6 +4735,34 @@ describe('Pack metadata Validation', async () => {
await validateJsonAndAssertFails(metadata);
});

it('Fail when both required fields are missing for users', async () => {
assert.throws(
() =>
makeSyncTable({
name: 'Users',
identityName: 'User',
role: TableRole.Users,
schema: makeObjectSchema({
idProperty: 'email',
displayProperty: 'email',
properties: {
email: {type: ValueType.String, codaType: ValueHintType.Email},
},
}),
formula: {
name: 'Users',
description: '',
async execute([], _context) {
return {result: []};
},
parameters: [],
examples: [],
},
}),
'Sync table schemas with role users must set a userEmailProperty',
);
});

it('Fail when fields are of the wrong type', async () => {
const syncTable = makeSyncTable({
name: 'Users',
Expand Down
4 changes: 2 additions & 2 deletions testing/upload_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,8 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): {
return validateProperty(
'userEmailProperty',
userEmail =>
(userEmail.type === ValueType.Object || userEmail.type === ValueType.String) &&
(userEmail.codaType === ValueHintType.Person || userEmail.codaType === ValueHintType.Email),
(userEmail.type === ValueType.String && userEmail.codaType === ValueHintType.Email) ||
(userEmail.type === ValueType.Object && userEmail.codaType === ValueHintType.Person),
`must refer to a "ValueType.Object" or "ValueType.String" property with a "ValueHintType.Person" or "ValueHintType.Email" "codaType".`,
);
};
Expand Down

0 comments on commit 76b0eda

Please sign in to comment.