fix: ui error when no auth providers configured
This commit is contained in:
@@ -65,4 +65,8 @@ export const messages = defineMessages<string>({
|
||||
id: 'auth.signout',
|
||||
defaultMessage: 'Sign Out',
|
||||
},
|
||||
noProviders: {
|
||||
id: 'auth.no-providers',
|
||||
defaultMessage: 'No providers available. May be you forgot to enable them?',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -254,6 +254,15 @@ describe('<Auth/>', () => {
|
||||
expect(input).toHaveValue(expected);
|
||||
});
|
||||
|
||||
it('should show error when no auth providers are configured', () => {
|
||||
StaticStore.config.auth_providers = [];
|
||||
|
||||
const { container } = render(<Auth />);
|
||||
|
||||
fireEvent.click(screen.getByText('Sign In'));
|
||||
expect(container.querySelector('.auth-error')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('OAuth providers', () => {
|
||||
it('should not set user if unauthorized', async () => {
|
||||
StaticStore.config.auth_providers = ['google'];
|
||||
|
||||
@@ -201,6 +201,9 @@ export function Auth() {
|
||||
</Button>
|
||||
{isDropdownShown && (
|
||||
<div className={clsx('auth-dropdown', styles.dropdown)} ref={ref}>
|
||||
{!hasOAuthProviders && !hasFormProviders && (
|
||||
<div className={clsx('auth-error', styles.error)}>{intl.formatMessage(messages.noProviders)}</div>
|
||||
)}
|
||||
<form className={clsx('auth-form', styles.form)} onSubmit={handleSubmit}>
|
||||
{view === 'telegram' && telegramParamsRef.current !== null ? (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user