feat: complete phase 2 UX improvements
This commit is contained in:
@@ -20,12 +20,12 @@ const mockedApi = api as jest.Mocked<typeof api>;
|
||||
|
||||
let consoleErrorSpy: jest.SpyInstance;
|
||||
|
||||
function renderLoginPage() {
|
||||
function renderLoginPage(initialMode: "login" | "register" = "login") {
|
||||
return render(
|
||||
<MemoryRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
|
||||
<I18nProvider>
|
||||
<ToastProvider>
|
||||
<LoginPage />
|
||||
<LoginPage initialMode={initialMode} />
|
||||
</ToastProvider>
|
||||
</I18nProvider>
|
||||
</MemoryRouter>,
|
||||
@@ -33,6 +33,19 @@ function renderLoginPage() {
|
||||
}
|
||||
|
||||
describe('LoginPage', () => {
|
||||
it('renders a dedicated registration screen and explains when registration is disabled', async () => {
|
||||
mockedApi.get.mockResolvedValueOnce({
|
||||
data: { requireAuth: true, googleEnabled: false, microsoftEnabled: false, localEnabled: true, allowRegistration: false, requireEmailVerification: true },
|
||||
} as any);
|
||||
|
||||
renderLoginPage("register");
|
||||
|
||||
expect(await screen.findByText('Registration is currently unavailable.')).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Create account' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Create account' })).toBeDisabled();
|
||||
expect(screen.queryByRole('tab')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
const originalConsoleError = console.error.bind(console);
|
||||
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {
|
||||
|
||||
Reference in New Issue
Block a user