import { logIn } from '../../../api/auth';
import { getLoginMessage } from '../../../api/settings';
import { getIdentityProviders } from '../../../api/users';
-import withAvailableFeatures, {
- WithAvailableFeaturesProps
-} from '../../../app/components/available-features/withAvailableFeatures';
import { Location, withRouter } from '../../../components/hoc/withRouter';
import { addGlobalErrorMessage } from '../../../helpers/globalMessages';
import { translate } from '../../../helpers/l10n';
import { getReturnUrl } from '../../../helpers/urls';
-import { Feature } from '../../../types/features';
import { IdentityProvider } from '../../../types/types';
import Login from './Login';
-interface Props extends WithAvailableFeaturesProps {
+interface Props {
location: Location;
}
interface State {
}
async loadLoginMessage() {
- if (this.props.hasFeature(Feature.LoginMessage)) {
- try {
- const { message } = await getLoginMessage();
- if (this.mounted) {
- this.setState({ message });
- }
- } catch (_) {
- /* already handled */
+ try {
+ const { message } = await getLoginMessage();
+ if (this.mounted) {
+ this.setState({ message });
}
+ } catch (_) {
+ /* already handled */
}
}
}
}
-export default withAvailableFeatures(withRouter(LoginContainer));
+export default withRouter(LoginContainer);
}));
jest.mock('../../../../api/settings', () => ({
- getLoginMessage: jest
- .fn()
- .mockResolvedValue({ message: 'Welcome to SQ! Please use your Skynet credentials' })
+ getLoginMessage: jest.fn().mockResolvedValue({ message: '' })
}));
jest.mock('../../../../helpers/globalMessages', () => ({
});
it('should display a login message if enabled & provided', async () => {
- renderLoginContainer({}, true);
+ const message = 'Welcome to SQ! Please use your Skynet credentials';
+ (getLoginMessage as jest.Mock).mockResolvedValueOnce({ message });
+ renderLoginContainer({});
- const message = await screen.findByText('Welcome to SQ! Please use your Skynet credentials');
- expect(message).toBeInTheDocument();
+ expect(await screen.findByText(message)).toBeInTheDocument();
});
it('should handle errors', async () => {
(getLoginMessage as jest.Mock).mockRejectedValueOnce('nope');
- renderLoginContainer({}, true);
+ renderLoginContainer({});
const heading = await screen.findByRole('heading', { name: 'login.login_to_sonarqube' });
expect(heading).toBeInTheDocument();
});
-function renderLoginContainer(
- props: Partial<LoginContainer['props']> = {},
- loginMessageEnabled = false
-) {
+function renderLoginContainer(props: Partial<LoginContainer['props']> = {}) {
return renderComponent(
- <LoginContainer
- hasFeature={jest.fn(() => loginMessageEnabled)}
- location={mockLocation({ query: { return_to: '/some/path' } })}
- {...props}
- />
+ <LoginContainer location={mockLocation({ query: { return_to: '/some/path' } })} {...props} />
);
}