Make it allright not to provide validators object on mock data

This commit is contained in:
garronej 2022-09-04 23:19:33 +02:00
parent 6d9e62d2b4
commit e4a46f31de

View File

@ -60,6 +60,8 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
].filter(exclude(undefined)); ].filter(exclude(undefined));
attributes.forEach(attribute => { attributes.forEach(attribute => {
console.log("====>", attribute);
const partialAttribute = partialAttributes.find(({ name }) => name === attribute.name); const partialAttribute = partialAttributes.find(({ name }) => name === attribute.name);
const augmentedAttribute: Attribute = {} as any; const augmentedAttribute: Attribute = {} as any;
@ -82,14 +84,16 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute; id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute;
}); });
partialAttributes.forEach(partialAttribute => { partialAttributes
const { name } = partialAttribute; .map(partialAttribute => ({ "validators": {}, ...partialAttribute }))
.forEach(partialAttribute => {
const { name } = partialAttribute;
assert(name !== undefined, "If you define a mock attribute it must have at least a name"); assert(name !== undefined, "If you define a mock attribute it must have at least a name");
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributes.push(partialAttribute as any); id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributes.push(partialAttribute as any);
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[name] = partialAttribute as any; id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[name] = partialAttribute as any;
}); });
} }
} }