Skip to content

Commit 5ec115b

Browse files
authored
Merge branch 'main' into update-landing-909
2 parents 0fb6377 + 6ad2cc5 commit 5ec115b

File tree

7 files changed

+289
-46
lines changed

7 files changed

+289
-46
lines changed
Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
1-
const faker = require('faker')
1+
const faker = require('faker');
22

33
describe('Footer', () => {
4-
const BAD_FORMAT_EMAIL = 'test@'
5-
const DUPLICATE_EMAIL = 'test@test.test'
4+
const BAD_FORMAT_EMAIL = 'test@';
5+
const DUPLICATE_EMAIL = 'test@test.test';
66
const RANDOM_EMAIL = `test_${faker.internet.email()}`;
77

88
before(() => {
99
cy.visit('/')
10-
})
10+
});
1111

1212
it('footer loads', () => {
1313
cy.get('[class*=containerFooter]').within(() => {
14-
cy.contains('The Civic Tech Index is an open-source project, read more on our')
15-
})
16-
})
14+
cy.contains(
15+
'The Civic Tech Index is an open-source project, read more on our'
16+
);
17+
});
18+
});
1719

1820
it('navigates to donate', () => {
1921
cy.get('[class*=containerFooter]').within(() => {
20-
cy.contains('Collaborate with Us').click()
21-
cy.get('[href*=donate]').click()
22-
})
23-
cy.get('[class*=makeStyles-infoThank]')
24-
.contains('We appreciate your contribution.')
25-
})
22+
cy.contains('Collaborate with Us').click();
23+
cy.get('[href*=donate]').click();
24+
});
25+
cy.get('[class*=makeStyles-infoThank]').contains(
26+
'We appreciate your contribution.'
27+
);
28+
});
2629

2730
it('does not capture a poorly formatted email address', () => {
2831
cy.get('[class*=containerFooter]').within(() => {
29-
cy.get('input').clear().type(BAD_FORMAT_EMAIL)
30-
cy.get('button').click()
31-
cy.contains('The email address you have submitted was invalid.')
32-
})
33-
})
32+
cy.get('input').clear().type(BAD_FORMAT_EMAIL);
33+
cy.get('button').click({ force: true });
34+
cy.contains('The email address you have submitted was invalid.');
35+
});
36+
});
3437

3538
it('does not capture a registered email address', () => {
3639
cy.get('[class*=containerFooter]').within(() => {
37-
cy.get('input').clear().type(DUPLICATE_EMAIL)
38-
cy.get('button').click()
39-
cy.contains('That email address has already been registered with us.')
40-
})
41-
})
40+
cy.get('input').clear().type(DUPLICATE_EMAIL);
41+
cy.get('button').click();
42+
cy.contains('That email address has already been registered with us.');
43+
});
44+
});
4245

4346
it('captures a new email address', () => {
4447
cy.get('[class*=containerFooter]').within(() => {
45-
cy.get('input').clear().type(RANDOM_EMAIL)
46-
cy.get('button').click()
47-
cy.contains('Thanks for subscribing!')
48-
})
49-
})
50-
})
48+
cy.get('input').clear().type(RANDOM_EMAIL);
49+
cy.get('button').click();
50+
cy.contains('Thanks for subscribing!');
51+
});
52+
});
53+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
describe('Privacy Popup', () => {
2+
before(() => {
3+
cy.visit('/home')
4+
});
5+
6+
it('verifies cookie notice is visible', () => {
7+
cy.get('[id*=cookieNotice]')
8+
.should(
9+
'contain',
10+
'Cookies and Privacy Policy'
11+
)
12+
.should(
13+
'contain',
14+
'We use cookies and other tracking technologies'
15+
).within(() => {
16+
cy.get('[data-cy=accept-cookie]').should('be.visible');
17+
cy.get('[data-cy=privacy-link]').should('be.visible');
18+
});
19+
});
20+
21+
it('navigates to privacy page', () => {
22+
cy.get('[data-cy=privacy-link]').click();
23+
cy.contains('Privacy Policy');
24+
});
25+
26+
it('loads home page and shows hover box', () => {
27+
cy.visit('/home');
28+
cy.get('[id*=cookieNotice]').should('be.visible');
29+
});
30+
31+
it('closes cookie notice', () => {
32+
cy.get('[data-cy=accept-cookie]').click();
33+
cy.get('[id*=cookieNotice]').should('not.be.visible');
34+
});
35+
});

cypress/integration/pages/privacy.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('About Page', () => {
1+
describe('Privacy Policy Page', () => {
22
before(() => {
33
cy.visit('/privacy')
44
})

public/images/cookie.png

901 Bytes
Loading

src/App.js

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useEffect } from 'react';
1+
/* eslint-disable max-lines-per-function */
2+
import React, { useEffect, useState } from 'react';
23
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom';
34
import { QueryParamProvider } from 'use-query-params';
45
import Layout from './components/common/Layout';
@@ -16,44 +17,96 @@ import SearchProjects from './pages/SearchProjects';
1617
import TagGenerator from './pages/TagGenerator';
1718
import Error404 from './pages/Error404';
1819
import ShareTheCti from './pages/Share';
19-
import Privacy from './pages/Privacy'
20+
import Privacy from './pages/Privacy';
21+
import PopUp from './pages/Privacy/PopUp';
2022
import Guides from './guides/';
2123
import useStyles from './styles';
2224

2325
const RouteTitled = ({ title, ...rest }) => {
2426
useEffect(() => {
2527
if (title) {
26-
document.title = `Civic Tech Index — ${title}`
28+
document.title = `Civic Tech Index — ${title}`;
2729
}
2830
});
2931

3032
return <Route {...rest} />;
3133
};
3234

3335
const App = () => {
36+
const [showModal, setShowModal] = useState(false);
3437
useStyles();
3538
return (
3639
<BrowserRouter>
3740
<ScrollToTop />
41+
<PopUp showModal={showModal} setShowModal={setShowModal} />
3842
<QueryParamProvider ReactRouterRoute={Route}>
3943
<Layout>
4044
<Switch>
4145
<RouteTitled exact path='/' component={Home} title='Home' />
4246
<RouteTitled exact path='/about' component={About} title='About' />
43-
<RouteTitled exact path='/about/contact' component={Contact} title='Contact Us' />
47+
<RouteTitled
48+
exact
49+
path='/about/contact'
50+
component={Contact}
51+
title='Contact Us'
52+
/>
4453
<RouteTitled exact path='/about/faq' component={Faq} title='FAQ' />
45-
<RouteTitled exact path={'/organizations'} component={Contributors} title='Organizations' />
54+
<RouteTitled
55+
exact
56+
path={'/organizations'}
57+
component={Contributors}
58+
title='Organizations'
59+
/>
4660
<RouteTitled exact path='/home' component={Home} title='Home' />
47-
<RouteTitled exact path='/projects' component={SearchProjects} title='Search Projects' />
48-
<RouteTitled exact path='/join-index' component={TagGenerator} title='Join the Index' />
49-
<RouteTitled exact path='/join-index/how-to-add' component={HowToAdd} title='How to Add Your Project' />
50-
<RouteTitled exact path='/support/collaborate' component={Collaborate} title='Collaborate with Us' />
51-
<RouteTitled exact path='/support/donate' component={Donate} title='Donate' />
52-
<RouteTitled exact path='/support/share' component={ShareTheCti} title='Share the CTI' />
53-
<RouteTitled exact path='/privacy' component={Privacy} title='Privacy' />
61+
<RouteTitled
62+
exact
63+
path='/projects'
64+
component={SearchProjects}
65+
title='Search Projects'
66+
/>
67+
<RouteTitled
68+
exact
69+
path='/join-index'
70+
component={TagGenerator}
71+
title='Join the Index'
72+
/>
73+
<RouteTitled
74+
exact
75+
path='/join-index/how-to-add'
76+
component={HowToAdd}
77+
title='How to Add Your Project'
78+
/>
79+
<RouteTitled
80+
exact
81+
path='/support/collaborate'
82+
component={Collaborate}
83+
title='Collaborate with Us'
84+
/>
85+
<RouteTitled
86+
exact
87+
path='/support/donate'
88+
component={Donate}
89+
title='Donate'
90+
/>
91+
<RouteTitled
92+
exact
93+
path='/support/share'
94+
component={ShareTheCti}
95+
title='Share the CTI'
96+
/>
97+
<RouteTitled
98+
exact
99+
path='/privacy'
100+
component={Privacy}
101+
title='Privacy'
102+
/>
54103
<Route exact path='/organization/:name' component={IndvOrgPage} />
55104
{/* test and error page routes begin */}
56-
<RouteTitled path='/guides/:guide' component={Guides} title='Guides' />
105+
<RouteTitled
106+
path='/guides/:guide'
107+
component={Guides}
108+
title='Guides'
109+
/>
57110
<RouteTitled path='/404' component={Error404} title='404' />
58111
{/* test and error page routes end */}
59112
<Redirect from='/add' to='/join-index/how-to-add' />

src/components/Header/NavLink.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@ import {
1111
import { navigation } from '../../navigation';
1212

1313
const useStyles = makeStyles({
14-
active: {
14+
link: {
15+
fontWeight: 500,
16+
'&:after': {
17+
display: 'block',
18+
content: 'attr(title)',
19+
fontWeight: 700,
20+
height: '1px',
21+
visibility: 'hidden',
22+
},
23+
},
24+
activeLink: {
1525
fontWeight: 700,
26+
'&:hover': {
27+
fontWeight: 700,
28+
},
29+
'&:active': {
30+
fontWeight: 700,
31+
},
1632
},
1733
menu: {
1834
padding: '0',
@@ -25,7 +41,7 @@ const useStyles = makeStyles({
2541
},
2642
});
2743

28-
const NavLink = ({ label, id, children, header, route, title }) => {
44+
const NavLink = ({ id, children, header, route }) => {
2945
const classes = useStyles();
3046
const location = useLocation();
3147
const popupState = usePopupState({ variant: 'popper', popupId: 'navlink' });
@@ -46,10 +62,11 @@ const NavLink = ({ label, id, children, header, route, title }) => {
4662
return (
4763
<>
4864
<Link
49-
className={active || popupState.isOpen ? classes.active : null}
65+
className={active || popupState.isOpen ? classes.activeLink : classes.link}
5066
component={NaviLink}
5167
exact
5268
to={route}
69+
title={header}
5370
underline='none'
5471
{...bindHover(popupState)}
5572
>
@@ -63,6 +80,7 @@ const NavLink = ({ label, id, children, header, route, title }) => {
6380
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
6481
transformOrigin={{ horizontal: 'left', vertical: 'top' }}
6582
PopoverClasses={{ paper: classes.popover }}
83+
disableScrollLock={true}
6684
{...bindMenu(popupState)}
6785
>
6886
<div>{children}</div>

0 commit comments

Comments
 (0)