Merge remote-tracking branch 'origin/develop' into edit-profile-fixes
This commit is contained in:
@ -56,26 +56,41 @@ describe('<Datepicker />', () => {
|
||||
it('calls the onChange function when the inputs change', async() => {
|
||||
const handler = jest.fn();
|
||||
render(<Datepicker onChange={handler} />);
|
||||
const today = new Date();
|
||||
|
||||
/**
|
||||
* A date with a different day, month, and year than today
|
||||
* so this test will always pass!
|
||||
*/
|
||||
const notToday = new Date(
|
||||
today.getFullYear() - 1, // last year
|
||||
(today.getMonth() + 2) % 11, // two months from now (mod 11 because it's 0-indexed)
|
||||
(today.getDate() + 2) % 28, // 2 days from now (for timezone stuff)
|
||||
);
|
||||
|
||||
const month = notToday.toLocaleString('en-us', { month: 'long' });
|
||||
const year = String(notToday.getFullYear());
|
||||
const day = String(notToday.getDate());
|
||||
|
||||
expect(handler.mock.calls.length).toEqual(1);
|
||||
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('datepicker-month'),
|
||||
screen.getByRole('option', { name: 'February' }),
|
||||
screen.getByRole('option', { name: month }),
|
||||
);
|
||||
|
||||
expect(handler.mock.calls.length).toEqual(2);
|
||||
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('datepicker-year'),
|
||||
screen.getByRole('option', { name: '2020' }),
|
||||
screen.getByRole('option', { name: year }),
|
||||
);
|
||||
|
||||
expect(handler.mock.calls.length).toEqual(3);
|
||||
|
||||
await userEvent.selectOptions(
|
||||
screen.getByTestId('datepicker-day'),
|
||||
screen.getByRole('option', { name: '5' }),
|
||||
screen.getByRole('option', { name: day }),
|
||||
);
|
||||
|
||||
expect(handler.mock.calls.length).toEqual(4);
|
||||
|
||||
@ -83,7 +83,7 @@ const Modal: React.FC<IModal> = ({
|
||||
}, [skipFocus, buttonRef]);
|
||||
|
||||
return (
|
||||
<div data-testid='modal' className={classNames('block w-full p-6 mx-auto overflow-hidden text-left align-middle transition-all transform bg-white dark:bg-slate-800 text-black dark:text-white shadow-xl rounded-2xl pointer-events-auto', widths[width])}>
|
||||
<div data-testid='modal' className={classNames('block w-full p-6 mx-auto text-left align-middle transition-all transform bg-white dark:bg-slate-800 text-black dark:text-white shadow-xl rounded-2xl pointer-events-auto', widths[width])}>
|
||||
<div className='sm:flex sm:items-start w-full justify-between'>
|
||||
<div className='w-full'>
|
||||
{title && (
|
||||
|
||||
@ -5,6 +5,8 @@ import React, { useState, useEffect } from 'react';
|
||||
import { IntlProvider } from 'react-intl';
|
||||
import { Provider } from 'react-redux';
|
||||
import { BrowserRouter, Switch, Redirect, Route } from 'react-router-dom';
|
||||
// @ts-ignore: it doesn't have types
|
||||
import { ScrollContext } from 'react-router-scroll-4';
|
||||
|
||||
import { loadInstance } from 'soapbox/actions/instance';
|
||||
import { fetchMe } from 'soapbox/actions/me';
|
||||
@ -115,6 +117,11 @@ const SoapboxMount = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
// @ts-ignore: I don't actually know what these should be, lol
|
||||
const shouldUpdateScroll = (prevRouterProps, { location }) => {
|
||||
return !(location.state?.soapboxModalKey && location.state?.soapboxModalKey !== prevRouterProps?.location?.state?.soapboxModalKey);
|
||||
};
|
||||
|
||||
/** Whether to display a loading indicator. */
|
||||
const showLoading = [
|
||||
me === null,
|
||||
@ -223,17 +230,19 @@ const SoapboxMount = () => {
|
||||
{helmet}
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter basename={BuildConfig.FE_SUBDIRECTORY}>
|
||||
<>
|
||||
{renderBody()}
|
||||
<ScrollContext shouldUpdateScroll={shouldUpdateScroll}>
|
||||
<>
|
||||
{renderBody()}
|
||||
|
||||
<BundleContainer fetchComponent={NotificationsContainer}>
|
||||
{(Component) => <Component />}
|
||||
</BundleContainer>
|
||||
<BundleContainer fetchComponent={NotificationsContainer}>
|
||||
{(Component) => <Component />}
|
||||
</BundleContainer>
|
||||
|
||||
<BundleContainer fetchComponent={ModalContainer}>
|
||||
{Component => <Component />}
|
||||
</BundleContainer>
|
||||
</>
|
||||
<BundleContainer fetchComponent={ModalContainer}>
|
||||
{Component => <Component />}
|
||||
</BundleContainer>
|
||||
</>
|
||||
</ScrollContext>
|
||||
</BrowserRouter>
|
||||
</ErrorBoundary>
|
||||
</IntlProvider>
|
||||
|
||||
Reference in New Issue
Block a user