Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAS-1166] feat: add tos and privacy pages #607

Merged
merged 13 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ import StationsPage from './pages/stations/list/StationsPage';
import StationAssociateECPage from './pages/stations/stationAssociateEC/StationAssociateECPage';
import StationECListPage from './pages/stations/stationECList/StationECPage';
import PaymentNoticesPage from './pages/notices/PaymentNoticesPage';
import { TOS } from './pages/tos/TOS';
import { TOS_AND_PRIVACY } from './pages/tos_and_privacy/TOS_AND_PRIVACY';
import routes from './routes';
import CommissionBundleDetailActivationPage from './pages/commisionalBundles/detail/CommissionBundleDetailActivationPage';
import { getMaintenanceMessage } from './services/maintenanceService';
import { MaintenanceMessage } from './api/generated/portal/MaintenanceMessage';
import CommissionBundleDetailOffersAddRecipientsPage from './pages/commisionalBundles/detail/CommissionBundleDetailOffersAddRecipientsPage';
import PaymentNoticesAddEditPage from './pages/notices/addEdit/PaymentNoticesAddEditPage';
import { rewriteLinks } from './utils/onetrust-utils';
import tosJson from './data/tos.json';
import privacyJson from './data/privacy.json';


const SecuredRoutes = withLogin(
withFeatureFlags(
Expand Down Expand Up @@ -87,10 +91,10 @@ const SecuredRoutes = withLogin(
);
}

if (!isTOSAccepted && location.pathname !== routes.TOS) {
if (!isTOSAccepted && location.pathname !== routes.TOS && location.pathname !== routes.PRIVACY) {
return (
<Layout>
<TOSWall acceptTOS={acceptTOS} detailRoute={routes.TOS} />
<TOSWall acceptTOS={acceptTOS} tosRoute={routes.TOS} privacyRoute={routes.PRIVACY} />
</Layout>
);
}
Expand Down Expand Up @@ -315,8 +319,21 @@ const SecuredRoutes = withLogin(
</Route>

<Route path={routes.TOS} exact={true}>
<TOS />
<TOS_AND_PRIVACY html={tosJson.html}
waitForElementCondition={'.otnotice-content'}
waitForElementFunction={() => {
rewriteLinks(routes.TOS, '.otnotice-content a');}}
/>
</Route>

<Route path={routes.PRIVACY} exact={true}>
<TOS_AND_PRIVACY html={privacyJson.html}
waitForElementCondition={'.otnotice-content'}
waitForElementFunction={() => {
rewriteLinks(routes.TOS, '.otnotice-content a');}}
/>
</Route>

<Route path="*">
<Redirect to={routes.HOME} />
</Route>
Expand Down
84 changes: 77 additions & 7 deletions src/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {ThemeProvider} from '@mui/system';
import {theme} from '@pagopa/mui-italia';
import {createMemoryHistory} from 'history';
import {Provider} from 'react-redux';
import {BrowserRouter} from 'react-router-dom';
import {BrowserRouter, MemoryRouter, Route} from 'react-router-dom';
import {createStore} from '../redux/store';
import App from '../App';
import {verifyMockExecution as verifyLoginMockExecution} from '../decorators/__mocks__/withLogin';
Expand All @@ -19,12 +19,6 @@ import {mockedPartyProducts} from '../services/__mocks__/productService';

const mockSignOutFn = jest.fn();

jest.mock('../hooks/useTOSAgreementLocalStorage', () => () => ({
isTOSAccepted: true,
acceptTOS: mockSignOutFn,
acceptedTOS: '',
}));

jest.mock('../decorators/withLogin');
jest.mock('../decorators/withParties');
jest.mock('../decorators/withSelectedParty');
Expand Down Expand Up @@ -61,9 +55,85 @@ const renderApp = (
};

test('Test rendering', () => {

jest.mock('../hooks/useTOSAgreementLocalStorage', () => () => ({
isTOSAccepted: true,
acceptTOS: mockSignOutFn,
acceptedTOS: '',
}));

const {store} = renderApp();

verifyLoginMockExecution(store.getState());
verifyPartiesMockExecution(store.getState());
verifySelectedPartyProductsMockExecution(store.getState());
});

test('Test rendering tosNotAccepted', () => {

jest.mock('../hooks/useTOSAgreementLocalStorage', () => () => ({
isTOSAccepted: false
}));

const store = createStore();
const history = createMemoryHistory();

render(
<Provider store={store}>
<MemoryRouter initialEntries={[`/payments-notices`]}>
<Route path="/payments-notices">
<ThemeProvider theme={theme}>
<Component/>
</ThemeProvider>
</Route>
</MemoryRouter>
</Provider>
);

});

test('Test rendering tos', () => {

jest.mock('../hooks/useTOSAgreementLocalStorage', () => () => ({
isTOSAccepted: false
}));

const store = createStore();
const history = createMemoryHistory();

render(
<Provider store={store}>
<MemoryRouter initialEntries={[`/termini-di-servizio`]}>
<Route path="/termini-di-servizio">
<ThemeProvider theme={theme}>
<Component/>
</ThemeProvider>
</Route>
</MemoryRouter>
</Provider>
);

});

test('Test rendering privacy', () => {

jest.mock('../hooks/useTOSAgreementLocalStorage', () => () => ({
isTOSAccepted: false
}));

const store = createStore();
const history = createMemoryHistory();

render(
<Provider store={store}>
<MemoryRouter initialEntries={[`/informativa-privacy`]}>
<Route path="/informativa-privacy">
<ThemeProvider theme={theme}>
<Component/>
</ThemeProvider>
</Route>
</MemoryRouter>
</Provider>
);

});
Loading
Loading