kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Add basic tests to containers/soapbox
rodzic
b6c7e3717b
commit
6b19adbb26
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -123,7 +123,7 @@ const SoapboxMount = () => {
|
||||||
return (
|
return (
|
||||||
<IntlProvider locale={locale} messages={messages}>
|
<IntlProvider locale={locale} messages={messages}>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<html lang='en' className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
|
<html lang={locale} className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
|
||||||
<body className={bodyClass} />
|
<body className={bodyClass} />
|
||||||
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
|
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
|
||||||
<meta name='theme-color' content={soapboxConfig.brandColor} />
|
<meta name='theme-color' content={soapboxConfig.brandColor} />
|
||||||
|
@ -142,7 +142,7 @@ const SoapboxMount = () => {
|
||||||
return (
|
return (
|
||||||
<IntlProvider locale={locale} messages={messages}>
|
<IntlProvider locale={locale} messages={messages}>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<html lang='en' className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
|
<html lang={locale} className={classNames({ dark: settings.get('themeMode') === 'dark' })} />
|
||||||
<body className={bodyClass} />
|
<body className={bodyClass} />
|
||||||
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
|
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
|
||||||
<meta name='theme-color' content={soapboxConfig.brandColor} />
|
<meta name='theme-color' content={soapboxConfig.brandColor} />
|
||||||
|
|
|
@ -43,7 +43,7 @@ const ExternalLoginForm: React.FC = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form onSubmit={handleSubmit} data-testid='external-login'>
|
||||||
<FormGroup labelText={intl.formatMessage(messages.instanceLabel)}>
|
<FormGroup labelText={intl.formatMessage(messages.instanceLabel)}>
|
||||||
<Input
|
<Input
|
||||||
aria-label={intl.formatMessage(messages.instancePlaceholder)}
|
aria-label={intl.formatMessage(messages.instancePlaceholder)}
|
||||||
|
|
|
@ -66,7 +66,7 @@ const LandingPage = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
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='mx-auto max-w-7xl'>
|
||||||
<div className='lg:grid lg:grid-cols-12 lg:gap-8 py-12'>
|
<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'>
|
<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'>
|
||||||
|
|
|
@ -67,7 +67,7 @@ const OnboardingWizard = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
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' />
|
<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'>
|
<main className='h-screen flex flex-col'>
|
||||||
|
|
Ładowanie…
Reference in New Issue