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

merge develop into release branch #232

Merged
merged 58 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bc6a64f
added recaptcha key and env
okumujustine Aug 1, 2021
3e3c195
Merge branch 'develop' into login-recaptcha
NickCallaghan Aug 8, 2021
40f95a5
Merge branch 'develop' into login-recaptcha
NickCallaghan Aug 10, 2021
c8622ef
Merge branch 'develop' into login-recaptcha
NickCallaghan Aug 13, 2021
31f308e
Fall back to cypress test key
NickCallaghan Aug 13, 2021
285b7c0
Test clicking Recaptcha
SabineU Aug 15, 2021
6d19ee5
Test clicking Recaptcha
SabineU Aug 15, 2021
82d8d53
added recapchat clicking to login page
okumujustine Aug 15, 2021
b9f666f
remove env.dev
NickCallaghan Aug 15, 2021
4decd16
test passing locally
NickCallaghan Aug 15, 2021
268265e
tests passing locally
NickCallaghan Aug 15, 2021
645d02f
changed recaptcha.specs extension from js to ts, added custom types f…
okumujustine Aug 15, 2021
58392fe
Remove duplicate test cases
SabineU Aug 16, 2021
36a0e59
Merge pull request #218 from ClimateMind/login-recaptcha
NickCallaghan Aug 16, 2021
2e07343
fix
rodriguesk Aug 16, 2021
c15a70b
Merge pull request #224 from ClimateMind/cm-822-docker-build-fix
rodriguesk Aug 16, 2021
f2fc57c
Dockerfile.production no longer needs .env.development
rodriguesk Aug 16, 2021
f878636
remove .env.development dependency
rodriguesk Aug 16, 2021
152bace
remove .env.development dependency
rodriguesk Aug 16, 2021
d082d26
remove .env.development dependency
rodriguesk Aug 16, 2021
a39faf6
only use test key
NickCallaghan Aug 16, 2021
21ef350
removed xs restricion from grid
JamesAKing Aug 17, 2021
ec4b0a0
card icon now changes width based on screen size
JamesAKing Aug 17, 2021
906312f
Merge branch 'develop' into CM-799-JK
JamesAKing Aug 17, 2021
4fa6f0e
revert and add REACT_APP_RECAPTCHA_SITEKEY
rodriguesk Aug 17, 2021
c912580
Environment variables added
rodriguesk Aug 17, 2021
fe9d8c9
Revert back login typescript
rodriguesk Aug 17, 2021
1ecf2eb
migrate app setting to setting json
NickCallaghan Aug 17, 2021
6757b79
Add something to the .env file so it's not deleted
NickCallaghan Aug 17, 2021
df02218
Merge pull request #225 from ClimateMind/CM-799-JK
JamesAKing Aug 18, 2021
65bbdcf
Merge branch 'develop' into cm-823-revert-back-env-file
rodriguesk Aug 19, 2021
b2eb9fe
Merge pull request #226 from ClimateMind/cm-823-revert-back-env-file
rodriguesk Aug 19, 2021
216dd14
Hot fix for docker builds
rodriguesk Aug 19, 2021
cf7e1fc
redeploy test
rodriguesk Aug 19, 2021
8700404
added excamation mark after take
NickCallaghan Aug 19, 2021
f57ea42
Keep .env.development contents
rodriguesk Aug 19, 2021
4464613
print env variables to console
NickCallaghan Aug 19, 2021
420e99a
add google.com to ngix.config
NickCallaghan Aug 19, 2021
19ac766
gstatic.com to nginx.conf
NickCallaghan Aug 19, 2021
f9bb1ae
remove console.log in app
NickCallaghan Aug 19, 2021
49c5695
add google to default src nginx
NickCallaghan Aug 19, 2021
646a1db
add fram src
NickCallaghan Aug 19, 2021
6be3bb2
update self src
NickCallaghan Aug 19, 2021
ad8fb48
add fram src
NickCallaghan Aug 19, 2021
fc8fb76
update regex and tests
NickCallaghan Aug 20, 2021
a00261e
Update error messages
NickCallaghan Aug 20, 2021
3dc498f
add back som commented out tests
NickCallaghan Aug 20, 2021
efd8088
use quizId not sessionId
NickCallaghan Aug 20, 2021
0e2e600
improve cypress tests
NickCallaghan Aug 20, 2021
33d41bc
added recaptcha verification
okumujustine Aug 21, 2021
93582fe
Merge pull request #227 from ClimateMind/CM-806_Loosen_PQ_reqs
NickCallaghan Aug 22, 2021
1402fde
Merge branch 'develop' into CM-831_PV_Menu_option_should_only_show_af…
NickCallaghan Aug 22, 2021
97ee545
Merge pull request #228 from ClimateMind/CM-831_PV_Menu_option_should…
NickCallaghan Aug 23, 2021
2fddc3b
moved recaptcha to login function
okumujustine Aug 25, 2021
f8279f7
passes the token through the body to the backend
okumujustine Aug 26, 2021
2833fd9
Merge branch 'develop' into CM-825-finish-captcha
rodriguesk Aug 28, 2021
cd3ba83
Merge pull request #229 from ClimateMind/CM-825-finish-captcha
rodriguesk Aug 28, 2021
f7ca68d
Merge branch 'CM-791_FE_Accounts_Release_Branch' into develop
rodriguesk Aug 29, 2021
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
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
REACT_APP_API_URL=http://localhost:5000
REACT_APP_SHOW_RQ_TOOLS=true
REACT_APP_RECAPTCHA_SITEKEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
REACT_APP_SHOW_RQ_TOOLS=true
3 changes: 2 additions & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`u
chmod +x envsubst && \
mv envsubst /usr/local/bin

#set environment variable
#set environment variables
ENV REACT_APP_API_URL=http://localhost:5000
ENV REACT_APP_RECAPTCHA_SITEKEY=6Lc0JOAbAAAAAIv3CYhhU6lHzHovl0yfMhI7mDl8

#copy config file over to the template
COPY ./nginx.config /etc/nginx/nginx.template
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`u
chmod +x envsubst && \
mv envsubst /usr/local/bin

#set environment variable
#set environment variables
ENV REACT_APP_API_URL=https://app-backend-prod-001.azurewebsites.net
ENV REACT_APP_RECAPTCHA_SITEKEY=6Lfgw9YbAAAAAJT8vn0SNIRhRTmsrQtfV8Z4fEWl

#copy config file over to the template
COPY ./nginx.config /etc/nginx/nginx.template
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.1.0/envsubst-`u
chmod +x envsubst && \
mv envsubst /usr/local/bin

#set environment variable
#set environment variables
ENV REACT_APP_API_URL=https://app-backend-test-001.azurewebsites.net
ENV REACT_APP_RECAPTCHA_SITEKEY=6Lc0JOAbAAAAAIv3CYhhU6lHzHovl0yfMhI7mDl8

#copy config file over to the template
COPY ./nginx.config /etc/nginx/nginx.template
Expand Down
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"retries": {
"runMode": 2,
"openMode": 0
}
},
"chromeWebSecurity": false
}
11 changes: 6 additions & 5 deletions cypress/fixtures/register.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNjIxMDc2NDA1LCJqdGkiOiJiMDMzNzFlNC1jODgzLTQ2MTAtOTA1Zi05NTA1YTBiOTVjYjAiLCJuYmYiOjE2MjEwNzY0MDUsInR5cGUiOiJhY2Nlc3MiLCJzdWIiOiI4RjEyMTIwMS0wNEZGLTRENTUtOERCNy1CQkNBQjE1QzRDQzIiLCJleHAiOjE2MjExNjI4MDV9.co-anCPDpuGK-A0_iu5nzAY52L6MxL7zTESOfW-UbyA",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNjI3MjIwNjU1LCJqdGkiOiJhYzdlOGFmNi00YjQ1LTQ2ZTYtOTAyYi1lYzcxMGZjNmFjNWQiLCJuYmYiOjE2MjcyMjA2NTUsInR5cGUiOiJhY2Nlc3MiLCJzdWIiOiI5Q0RDNkRCRi1BRUY3LTQ2NzktQTk1RC1EMzMwMjcxNzEwNzYiLCJleHAiOjE2MjcyMjE1NTV9.4DoqxC616-EucHs8XzWYGD8HjGaDQrpkPBoVJ0XfoaQ",
"message": "Successfully created user",
"user": {
"email": "test233e3@example.com",
"full_name": "Test User",
"session_id": "58627AD1-4252-4EAB-9892-7529291C7AC7",
"user_uuid": "8F121201-04FF-4D55-8DB7-BBCAB15C4CC2"
"email": "testds1c1@example.com",
"first_name": "test",
"last_name": "bunny",
"quiz_id": "9E833B3C-1CD5-41AC-B120-ED1005E79F92",
"user_uuid": "9CDC6DBF-AEF7-4679-A95D-D33027171076"
}
}
1 change: 0 additions & 1 deletion cypress/integration/actionsfeed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe('Actions feed loads and looks correct', () => {
// Set session id and accept cookies as if a returning user
cy.acceptCookies();
cy.mockServer();

cy.login();
cy.wait(1).contains('Actions').click();
});
Expand Down
3 changes: 2 additions & 1 deletion cypress/integration/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ describe('Login', () => {

it('allows a user to login with valid account details', () => {
cy.visit('/login');

cy.get('input#email').type(testUser.email);
cy.get('input#password').type(testUser.password);
cy.switchToIframe('iframe[title="reCAPTCHA"]').click();
cy.contains(/log in/i).click();
cy.get('.MuiAlert-root').contains('Welcome, Test');
cy.url().should('include', '/climate-feed');
Expand Down Expand Up @@ -100,6 +100,7 @@ describe('Login', () => {
cy.visit('/login');
cy.get('input#email').type(testUser.email);
cy.get('input#password').type(testUser.password);
cy.switchToIframe('iframe[title="reCAPTCHA"]').click();
cy.contains(/log in/i).click();
cy.url().should('include', '/login');
cy.get('.MuiAlert-root').contains(/Wrong email or password\. Try again\./i);
Expand Down
23 changes: 22 additions & 1 deletion cypress/integration/menubar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,33 @@
import { terminalLog } from '../support/helpers.ts';

describe('Menu bar opens and looks correct', () => {
it('can open menubar', () => {
beforeEach(() => {
cy.acceptCookies();
cy.mockServer();
});

it('can open menubar', () => {
cy.visit('/start');
cy.get('[aria-label="menu"]').should('be.visible').click();
cy.contains('About ClimateMind').should('be.visible');
cy.checkAccessibility(terminalLog);
cy.percySnapshot('MenuBar');
});

it('should have the right menu items', () => {
cy.login();
cy.get('[aria-label="menu"]').should('be.visible').click();
cy.contains(/About ClimateMind/i);
cy.contains(/Scientists Speak Up/i);
cy.contains(/Privacy Policy/i);
cy.contains(/LOG OUT/i);
cy.contains(/EMAIL US/i);
});

it('personal values and retake quiz should not be in the menu until user has take the quiz', () => {
cy.visit('/');
cy.get('[aria-label="menu"]').should('be.visible').click();
cy.contains(/Personal Values/i).should('not.exist');
cy.contains(/Re-take the Quiz/i).should('not.exist');
});
});
21 changes: 12 additions & 9 deletions cypress/integration/register.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ describe('User can register', () => {
cy.get('input#email').type('test.user@example.com');
cy.get('input#password').type('Password123!');
cy.get('input#confirmPassword').type('Password123!');
cy.contains(/create account and go to feed/i).should('be.enabled');
cy.contains(/create account and go to feed/i)
.should('be.enabled')
.click();
// TODO: Imporve this test
// cy.url().should('include', 'climate-feed');
// cy.contains('Your Personal Climate Feed');
cy.url().should('include', 'climate-feed');
cy.contains('Your Personal Climate Feed');
});

it('User can skip registration', () => {
cy.visit('/sign-up');
cy.contains(/Create a Climate Mind account/i).should('be.visible');
cy.contains(/skip making an account and see feed/i).should('be.enabled');
cy.contains(/skip making an account and see feed/i)
.should('be.enabled')
.click();
// TODO: Improve this test
// .click();
// cy.url().should('include', 'climate-feed');
// cy.contains('Your Personal Climate Feed');
cy.url().should('include', 'climate-feed');
cy.contains('Your Personal Climate Feed');
});

it('Passwords must match to register', () => {
Expand Down Expand Up @@ -85,10 +88,10 @@ describe('User can register', () => {

it('Password must be valid', () => {
cy.visit('/sign-up');
cy.get('input#password').type('Password123');
cy.get('input#password').type('Password');
cy.get('input#firstname').click();
cy.contains(
/Password must be between 8-20 characters and containt at least one uppercase letter, one lowercase letter, one number and one special character/i
/Invalid Password\. Password must be at least 8 characters and containt one number or one special character/i
);
cy.contains(/create account and go to feed/i).should('be.disabled');
});
Expand Down
11 changes: 11 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Cypress.Commands.add('login', () => {
cy.visit('/login');
cy.get('input#email').type('test.user@example.com');
cy.get('input#password').type('Password123!');
cy.switchToIframe('iframe[title="reCAPTCHA"]').click();
cy.contains(/log in/i).click();
cy.get('.MuiAlert-root').contains('Welcome, Test');
});
Expand Down Expand Up @@ -170,3 +171,13 @@ Cypress.Commands.add('mockServer', (quizId = '1234') => {
response: 'fixture:solutions.json',
});
});

//Switch to iFrame
Cypress.Commands.add('switchToIframe', (iframe) => {
return cy
.get(iframe, { force: true })
.its('0.contentDocument.body')
.should('be.visible')
.then(cy.wrap);
});

16 changes: 16 additions & 0 deletions cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,21 @@ declare namespace Cypress {
* A command to go mock the api responses
*/
mockServer(sessionId?: string): void;

/**
* A command to switch to click recaptcha iframe
*/
switchToIframe(iframeName: any): any;


/**
* A command to login with the recaptcha clicked
*/
loginWithRecaptcha(email: string, password: string): void;

/**
* A command to click the login button
*/
clickLoginButton(): void;
}
}
2 changes: 1 addition & 1 deletion nginx.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ server {
try_files $$uri /index.html;
}

add_header Content-Security-Policy "default-src 'self'; script-src 'self' http://www.googletagmanager.com/ https://www.google-analytics.com/ 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://*.typekit.net https://fonts.googleapis.com; img-src * www.googletagmanager.com 'self' data:; font-src 'self' *.typekit.net fonts.googleapis.com fonts.gstatic.com; connect-src 'self' https://*.okta.com https://app-backend-test-001.azurewebsites.net https://app-backend-prod-001.azurewebsites.net https://www.google-analytics.com ;";
add_header Content-Security-Policy "default-src 'self'; frame-src https://www.google.com/; script-src 'self' http://www.googletagmanager.com/ https://www.google-analytics.com/ https://www.google.com/ https://www.gstatic.com/ 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://*.typekit.net https://fonts.googleapis.com; img-src * www.googletagmanager.com 'self' data:; font-src 'self' *.typekit.net fonts.googleapis.com fonts.gstatic.com; connect-src 'self' https://*.okta.com https://app-backend-test-001.azurewebsites.net https://app-backend-prod-001.azurewebsites.net https://www.google-analytics.com ;";
add_header Referrer-Policy "no-referrer, strict-origin-when-cross-origin";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
add_header X-Content-Type-Options nosniff;
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react-chartjs-3": "^2.7.7",
"react-div-100vh": "^0.5.6",
"react-dom": "^16.13.1",
"react-google-recaptcha": "^2.1.0",
"react-gtm-module": "^2.0.11",
"react-helmet": "^6.1.0",
"react-markdown": "^5.0.3",
Expand Down Expand Up @@ -93,6 +94,7 @@
"@types/node": "^12.12.50",
"@types/react": "^16.9.43",
"@types/react-dom": "^16.9.8",
"@types/react-google-recaptcha": "^2.1.2",
"@types/react-helmet": "^6.1.1",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^3.6.1",
Expand Down
40 changes: 40 additions & 0 deletions src/__tests__/src/__utilities__/password.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { passwordRegex } from '../../../helpers/validationSchemas';

describe('Password requirements', () => {
const isPasswordValid = (password: string) => passwordRegex.test(password);

it('Must be min length', () => {
expect(isPasswordValid('Passwor')).toBe(false);
});
it('Must not exceed max length', () => {
const longPassword: any = 'p' * 129;
expect(isPasswordValid(longPassword)).toBe(false);
});
it('Must Need a number or special char', () => {
expect(isPasswordValid('Password')).toBe(false);
expect(isPasswordValid('password')).toBe(false);
});
it('Accepts valid passwords', () => {
const testPasses = [
'Password123',
'Password!',
'password!',
'Passworddddddddd!',
'dddddddddddddddddds!',
'1234567890123456789D',
];
testPasses.forEach((pass) => expect(isPasswordValid(pass)).toBe(true));
});

it('All special chars make a valid password', () => {
// Make a password for every valid special character
const chars: string = '!"#$£%&\'()*+,-.:;<=>?@[]^_`{|}~';
const testPasses = [];
for (let char of chars) {
testPasses.push('Password' + char);
}

// All special chars passwords
testPasses.forEach((pass) => expect(isPasswordValid(pass)).toBe(true));
});
});
5 changes: 4 additions & 1 deletion src/api/postLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { climateApi } from '../api/apiHelper';
export type loginPayload = {
email: string;
password: string;
recaptchaToken:string;
};

export type loginResponse = {
Expand All @@ -15,13 +16,15 @@ export type loginResponse = {
export const postLogin = async ({
email,
password,
recaptchaToken,
}: loginPayload): Promise<loginResponse> => {
const url = '/login';
const url = "/login";
try {
// Make request for token
const request = await climateApi.post(
url,
{
recaptchaToken,
email,
password,
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppBar/MenuDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const menuLinks = [
const MenuDrawer: React.FC<MenuDrawerProps> = ({ isShowing, setIsShowing }) => {
const classes = useStyles();
const { push } = useHistory();
const { sessionId, clearSession } = useSession();
const { quizId, clearSession } = useSession();
const { setCurrentSet } = useQuestions();
const { dispatch } = useResponses();
const { clearPersonality } = useClimatePersonality();
Expand Down Expand Up @@ -113,7 +113,7 @@ const MenuDrawer: React.FC<MenuDrawerProps> = ({ isShowing, setIsShowing }) => {
<Grid item>
<List>
{/* Personal Values option should only show if there is a session id */}
{sessionId && (
{quizId && (
<>
<ListItem
component="li"
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppBar/MenuPaper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const menuLinks = [
const TopMenu: React.FC<MenuPaperProps> = ({ isShowing, setIsShowing }) => {
const classes = useStyles();
const { push } = useHistory();
const { sessionId, clearSession } = useSession();
const { quizId, clearSession } = useSession();
const { dispatch } = useResponses();
const { clearPersonality } = useClimatePersonality();
const { setCurrentSet } = useQuestions();
Expand Down Expand Up @@ -111,7 +111,7 @@ const TopMenu: React.FC<MenuPaperProps> = ({ isShowing, setIsShowing }) => {
<Grid item>
<List>
{/* Personal Values option should only show if there is a session id */}
{sessionId && (
{quizId && (
<>
<ListItem
component="li"
Expand Down
1 change: 0 additions & 1 deletion src/components/CardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const CardHeader: React.FC<CardHeaderProps> = ({
{cardIcon && (
<Grid
item
xs={2}
data-testid="CardIcon"
>
<CardIcon actionType={cardIcon} />
Expand Down
Loading