Skip to content

Commit

Permalink
[VAS-1166] feat: add tos and privacy pages (#607)
Browse files Browse the repository at this point in the history
* [VAS-1116] feat: add privacy and tos pages

* [VAS-1116] feat: Updated footer config, and management for the snippet pages

* [VAS-1116] feat: Updated tests

* [VAS-1116] feat: Updated Snippet.tsx

* [VAS-1116] feat: Updated Snippet.tsx and tests

* [VAS-1116] feat: Updated App.test.tsx

* [VAS-1116] feat: Updated App.test.tsx

* Bump to version 1.26.4-4-VAS-1166-feat-add-tos-and-privacy-pages [skip ci]

* [VAS-1116] feat: Updated App.test

* Bump to version 1.26.4-5-VAS-1166-feat-add-tos-and-privacy-pages [skip ci]

---------

Co-authored-by: pagopa-github-bot <github-bot@pagopa.it>
Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent 038b7d3 commit a8bef9a
Show file tree
Hide file tree
Showing 16 changed files with 614 additions and 64 deletions.
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.PRIVACY, '.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

0 comments on commit a8bef9a

Please sign in to comment.