|
|
|
@ -5,6 +5,7 @@ import { Route, Switch } from 'react-router-dom';
|
|
|
|
|
import { render, screen, waitFor } from '../../../jest/test-helpers';
|
|
|
|
|
import { normalizeAccount } from '../../../normalizers';
|
|
|
|
|
import UI from '../index';
|
|
|
|
|
import { WrappedRoute } from '../util/react_router_helpers';
|
|
|
|
|
|
|
|
|
|
const TestableComponent = () => (
|
|
|
|
|
<Switch>
|
|
|
|
@ -12,6 +13,9 @@ const TestableComponent = () => (
|
|
|
|
|
<Route path='/@:username/media' exact><UI /></Route>
|
|
|
|
|
<Route path='/@:username' exact><UI /></Route>
|
|
|
|
|
<Route path='/login' exact><span data-testid='sign-in'>Sign in</span></Route>
|
|
|
|
|
|
|
|
|
|
{/* WrappedRount will redirect to /login for logged out users... which will resolve to the route above! */}
|
|
|
|
|
<WrappedRoute path='/notifications' />
|
|
|
|
|
</Switch>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -33,53 +37,47 @@ describe('<UI />', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('when logged out', () => {
|
|
|
|
|
describe('with guest experience disabled', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
store = { ...store, soapbox: ImmutableMap({ guestExperience: false }) };
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('when viewing a Profile Page', () => {
|
|
|
|
|
it('should render the Profile page', async() => {
|
|
|
|
|
render(
|
|
|
|
|
<TestableComponent />,
|
|
|
|
|
{},
|
|
|
|
|
store,
|
|
|
|
|
{ initialEntries: ['/@username'] },
|
|
|
|
|
);
|
|
|
|
|
describe('when viewing a Profile Page', () => {
|
|
|
|
|
it('should render the Profile page', async() => {
|
|
|
|
|
render(
|
|
|
|
|
<TestableComponent />,
|
|
|
|
|
{},
|
|
|
|
|
store,
|
|
|
|
|
{ initialEntries: ['/@username'] },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(screen.getByTestId('cta-banner')).toHaveTextContent('Sign up now to discuss');
|
|
|
|
|
});
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(screen.getByTestId('cta-banner')).toHaveTextContent('Sign up now to discuss');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('when viewing a Status Page', () => {
|
|
|
|
|
it('should render the Status page', async() => {
|
|
|
|
|
render(
|
|
|
|
|
<TestableComponent />,
|
|
|
|
|
{},
|
|
|
|
|
store,
|
|
|
|
|
{ initialEntries: ['/@username/posts/12'] },
|
|
|
|
|
);
|
|
|
|
|
describe('when viewing a Status Page', () => {
|
|
|
|
|
it('should render the Status page', async() => {
|
|
|
|
|
render(
|
|
|
|
|
<TestableComponent />,
|
|
|
|
|
{},
|
|
|
|
|
store,
|
|
|
|
|
{ initialEntries: ['/@username/posts/12'] },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(screen.getByTestId('cta-banner')).toHaveTextContent('Sign up now to discuss');
|
|
|
|
|
});
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(screen.getByTestId('cta-banner')).toHaveTextContent('Sign up now to discuss');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('when viewing any other page', () => {
|
|
|
|
|
it('should redirect to the login page', async() => {
|
|
|
|
|
render(
|
|
|
|
|
<TestableComponent />,
|
|
|
|
|
{},
|
|
|
|
|
store,
|
|
|
|
|
{ initialEntries: ['/@username/media'] },
|
|
|
|
|
);
|
|
|
|
|
describe('when viewing Notifications', () => {
|
|
|
|
|
it('should redirect to the login page', async() => {
|
|
|
|
|
render(
|
|
|
|
|
<TestableComponent />,
|
|
|
|
|
{},
|
|
|
|
|
store,
|
|
|
|
|
{ initialEntries: ['/notifications'] },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(screen.getByTestId('sign-in')).toHaveTextContent('Sign in');
|
|
|
|
|
});
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(screen.getByTestId('sign-in')).toHaveTextContent('Sign in');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|