0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-24 22:41:28 -05:00

fix(console): update terms of use (#1122)

This commit is contained in:
Xiao Yijun 2022-06-15 12:16:37 +08:00 committed by GitHub
parent 65f9a6fa39
commit 9262a6f3be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -24,7 +24,7 @@ const TermsForm = () => {
<div className={styles.title}>{t('sign_in_exp.terms_of_use.title')}</div>
<FormField title="admin_console.sign_in_exp.terms_of_use.enable">
<Switch
{...register('termsOfUse.enabled', { required: true })}
{...register('termsOfUse.enabled')}
label={t('sign_in_exp.terms_of_use.description')}
/>
</FormField>

View file

@ -67,10 +67,24 @@ describe('terms of use', () => {
}
);
test.each([null, '', ' \t\n\r', 'non-url'])('%p should fail', async (contentUrl) => {
test.each([null, ' \t\n\r', 'non-url'])('%p should fail', async (contentUrl) => {
const signInExperience = { termsOfUse: { ...mockTermsOfUse, enabled: false, contentUrl } };
await expectPatchResponseStatus(signInExperience, 400);
});
test('should allow empty contentUrl if termsOfUse is disabled', async () => {
const signInExperience = {
termsOfUse: { ...mockTermsOfUse, enabled: false, contentUrl: '' },
};
await expectPatchResponseStatus(signInExperience, 200);
});
test('should not allow empty contentUrl if termsOfUse is enabled', async () => {
const signInExperience = {
termsOfUse: { ...mockTermsOfUse, enabled: true, contentUrl: '' },
};
await expectPatchResponseStatus(signInExperience, 400);
});
});
});

View file

@ -91,7 +91,7 @@ export type Branding = z.infer<typeof brandingGuard>;
export const termsOfUseGuard = z.object({
enabled: z.boolean(),
contentUrl: z.string().url().optional(),
contentUrl: z.string().url().optional().or(z.literal('')),
});
export type TermsOfUse = z.infer<typeof termsOfUseGuard>;