2022-11-25 09:04:11 -08:00
|
|
|
import React from 'react';
|
2022-04-05 12:38:49 -07:00
|
|
|
|
|
|
|
import LandingPage from '..';
|
2022-04-25 12:27:09 -07:00
|
|
|
import { rememberInstance } from '../../../actions/instance';
|
2022-05-10 17:11:26 -07:00
|
|
|
import { SOAPBOX_CONFIG_REMEMBER_SUCCESS } from '../../../actions/soapbox';
|
2022-04-05 12:38:49 -07:00
|
|
|
import { PEPE_FETCH_INSTANCE_SUCCESS } from '../../../actions/verification';
|
|
|
|
import { render, screen, rootReducer, applyActions } from '../../../jest/test-helpers';
|
|
|
|
|
|
|
|
describe('<LandingPage />', () => {
|
|
|
|
it('renders a RegistrationForm for an open Pleroma instance', () => {
|
|
|
|
|
|
|
|
const state = rootReducer(undefined, {
|
2022-04-25 13:47:47 -07:00
|
|
|
type: rememberInstance.fulfilled.type,
|
2022-04-25 12:27:09 -07:00
|
|
|
payload: {
|
2022-04-05 12:38:49 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
|
|
|
registrations: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-06 10:31:11 -07:00
|
|
|
render(<LandingPage />, undefined, state);
|
2022-04-05 12:38:49 -07:00
|
|
|
|
|
|
|
expect(screen.queryByTestId('registrations-open')).toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-closed')).not.toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-pepe')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders "closed" message for a closed Pleroma instance', () => {
|
|
|
|
|
|
|
|
const state = rootReducer(undefined, {
|
2022-04-25 13:47:47 -07:00
|
|
|
type: rememberInstance.fulfilled.type,
|
2022-04-25 12:27:09 -07:00
|
|
|
payload: {
|
2022-04-05 12:38:49 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
|
|
|
registrations: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-06 10:31:11 -07:00
|
|
|
render(<LandingPage />, undefined, state);
|
2022-04-05 12:38:49 -07:00
|
|
|
|
|
|
|
expect(screen.queryByTestId('registrations-closed')).toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-open')).not.toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-pepe')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
2022-05-10 17:11:26 -07:00
|
|
|
it('renders Pepe flow if Pepe extension is enabled', () => {
|
2022-04-05 12:38:49 -07:00
|
|
|
|
|
|
|
const state = applyActions(undefined, [{
|
2022-05-10 17:11:26 -07:00
|
|
|
type: SOAPBOX_CONFIG_REMEMBER_SUCCESS,
|
|
|
|
soapboxConfig: {
|
|
|
|
extensions: {
|
|
|
|
pepe: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
2022-04-05 12:38:49 -07:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: PEPE_FETCH_INSTANCE_SUCCESS,
|
|
|
|
instance: {
|
|
|
|
registrations: true,
|
|
|
|
},
|
|
|
|
}], rootReducer);
|
|
|
|
|
2022-07-06 10:31:11 -07:00
|
|
|
render(<LandingPage />, undefined, state);
|
2022-04-05 12:38:49 -07:00
|
|
|
|
|
|
|
expect(screen.queryByTestId('registrations-pepe')).toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-open')).not.toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-closed')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders "closed" message for a Truth Social instance with Pepe closed', () => {
|
|
|
|
|
|
|
|
const state = applyActions(undefined, [{
|
2022-04-25 13:47:47 -07:00
|
|
|
type: rememberInstance.fulfilled.type,
|
2022-04-25 12:27:09 -07:00
|
|
|
payload: {
|
2022-04-05 12:38:49 -07:00
|
|
|
version: '3.4.1 (compatible; TruthSocial 1.0.0)',
|
|
|
|
registrations: false,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: PEPE_FETCH_INSTANCE_SUCCESS,
|
|
|
|
instance: {
|
|
|
|
registrations: false,
|
|
|
|
},
|
|
|
|
}], rootReducer);
|
|
|
|
|
2022-07-06 10:31:11 -07:00
|
|
|
render(<LandingPage />, undefined, state);
|
2022-04-05 12:38:49 -07:00
|
|
|
|
|
|
|
expect(screen.queryByTestId('registrations-closed')).toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-pepe')).not.toBeInTheDocument();
|
|
|
|
expect(screen.queryByTestId('registrations-open')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
});
|