Add basic tests to containers/soapbox

revert-5af0e40a
Alex Gleason 2022-04-21 14:29:25 -05:00
rodzic b6c7e3717b
commit 6b19adbb26
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
5 zmienionych plików z 50 dodań i 5 usunięć

Wyświetl plik

@ -0,0 +1,45 @@
import React from 'react';
import { __stub as stub } from 'soapbox/api';
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
import Soapbox from '../soapbox';
describe('<Soapbox />', () => {
describe('without a user or instance', () => {
beforeEach(() => {
stub(mock => {
mock.onGet('/api/v1/instance').reply(404, '');
});
});
it('renders external login', async() => {
render(<Soapbox />);
await waitFor(() => {
expect(location.href.endsWith('/login/external')).toBeTruthy();
expect(screen.getByTestId('external-login')).toBeInTheDocument();
});
});
});
describe('without a user', () => {
beforeEach(() => {
stub(mock => {
mock.onGet('/api/v1/instance')
.reply(200, require('soapbox/__fixtures__/pleroma-instance.json'));
});
});
it('renders the homepage', async() => {
render(<Soapbox />);
waitFor(() => {
expect(screen.getByTestId('homepage')).toBeInTheDocument();
expect(screen.getByText('Gleasonator')).toBeInTheDocument();
expect(screen.getByText('Speak freely.')).toBeInTheDocument();
});
});
});
});

Wyświetl plik

@ -123,7 +123,7 @@ const SoapboxMount = () => {
return (
<IntlProvider locale={locale} messages={messages}>
<Helmet>
<html lang='en' className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
<html lang={locale} className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
<body className={bodyClass} />
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
<meta name='theme-color' content={soapboxConfig.brandColor} />
@ -142,7 +142,7 @@ const SoapboxMount = () => {
return (
<IntlProvider locale={locale} messages={messages}>
<Helmet>
<html lang='en' className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
<html lang={locale} className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
<body className={bodyClass} />
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
<meta name='theme-color' content={soapboxConfig.brandColor} />

Wyświetl plik

@ -43,7 +43,7 @@ const ExternalLoginForm: React.FC = () => {
}
return (
<Form onSubmit={handleSubmit}>
<Form onSubmit={handleSubmit} data-testid='external-login'>
<FormGroup labelText={intl.formatMessage(messages.instanceLabel)}>
<Input
aria-label={intl.formatMessage(messages.instancePlaceholder)}

Wyświetl plik

@ -66,7 +66,7 @@ const LandingPage = () => {
};
return (
<main className='mt-16 sm:mt-24'>
<main className='mt-16 sm:mt-24' data-testid='homepage'>
<div className='mx-auto max-w-7xl'>
<div className='lg:grid lg:grid-cols-12 lg:gap-8 py-12'>
<div className='px-4 sm:px-6 sm:text-center md:max-w-2xl md:mx-auto lg:col-span-6 lg:text-left lg:flex'>

Wyświetl plik

@ -67,7 +67,7 @@ const OnboardingWizard = () => {
}, []);
return (
<div>
<div data-testid='onboarding-wizard'>
<div className='fixed h-screen w-full bg-gradient-to-tr from-primary-50 via-white to-cyan-50' />
<main className='h-screen flex flex-col'>