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

Update production #676

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
8d6f9c8
pushing changes to logic
epixieme Aug 3, 2024
7941304
clean up
epixieme Aug 3, 2024
43ed5e4
update login and sign up screens
Svenstar74 Aug 4, 2024
f372a2b
added fetch request
epixieme Aug 4, 2024
6785ca6
refactored code to use the useApi hook
epixieme Aug 4, 2024
69ff7db
refactored google login to use useLogin hook
epixieme Aug 5, 2024
f9f48a9
feat: Add cursor pointer to CmButton2 component
Svenstar74 Aug 6, 2024
2129771
close modals for changing password and email when successful
Svenstar74 Aug 6, 2024
21905bb
finished clean up for google login
epixieme Aug 6, 2024
0a5c405
made google login optional so it doesn't affect userb journey
epixieme Aug 6, 2024
d17230b
added devmode
epixieme Aug 6, 2024
56e6f70
clean up
epixieme Aug 6, 2024
9f65cc4
Merge branch 'develop' into 630-refactor-google-client-logic
epixieme Aug 6, 2024
7695289
cleaned up
epixieme Aug 6, 2024
1004c7c
pushing changes to button
epixieme Aug 6, 2024
686e73b
Bump @tanstack/react-query from 5.51.15 to 5.51.21 (#634)
dependabot[bot] Aug 7, 2024
6f2f5c0
Bump axios from 1.7.2 to 1.7.3 (#633)
dependabot[bot] Aug 7, 2024
ec346b1
Bump @mui/icons-material from 5.16.5 to 5.16.6 (#626)
dependabot[bot] Aug 7, 2024
f516f04
Bump uuid and @types/uuid (#608)
dependabot[bot] Aug 7, 2024
d7ea408
630 refactor google client logic (#636)
epixieme Aug 9, 2024
e774266
pushing changes
epixieme Aug 13, 2024
d8c5fe4
Merge branch 'develop' into 631-implement-new-google-logic-for-backend
epixieme Aug 13, 2024
3965a7f
clean up
epixieme Aug 13, 2024
957cba4
cleanup
Svenstar74 Aug 16, 2024
53b2d4f
Merge pull request #644 from ClimateMind/631-implement-new-google-log…
epixieme Aug 16, 2024
913bc4f
google login code in place
epixieme Aug 22, 2024
e8bb583
pushing working code ready for refactoring
epixieme Aug 23, 2024
a285828
clean up credentials
epixieme Aug 23, 2024
ed94941
pushing code so we can test backend
epixieme Aug 23, 2024
77fcf76
upgraded to @react-oauth/google so CI works
epixieme Aug 23, 2024
3d8be82
cleaned up code
epixieme Aug 23, 2024
76efdcb
clean up
epixieme Aug 23, 2024
7ea8418
clean up
epixieme Aug 23, 2024
3d8672e
clean up
epixieme Aug 24, 2024
c08c41b
changed style of button on login page to demonstrate it can be done
epixieme Aug 24, 2024
284160a
pushing sign up button chnages
epixieme Aug 24, 2024
7204e0a
clean up
epixieme Aug 25, 2024
0cbe445
small cleanup
Svenstar74 Aug 25, 2024
69f5d86
Merge pull request #652 from ClimateMind/650-adjust-frontend-code-to-…
epixieme Aug 26, 2024
5f761a1
chore: Clean up nginx.config file (#654)
epixieme Aug 27, 2024
0b070a7
chore: Add Content-Security-Policy header to nginx.config (#655)
epixieme Aug 27, 2024
352034f
chore: Update Content-Security-Policy header in nginx.config
Svenstar74 Aug 27, 2024
1b3dfc3
chore: Update Content-Security-Policy header in nginx.config
Svenstar74 Aug 27, 2024
22d289c
chore: Update environment variables for Google OAuth
Svenstar74 Aug 27, 2024
708290d
chore: Update serverdata.sh to include additional environment variabl…
Svenstar74 Aug 27, 2024
3765791
Remove log statement
Svenstar74 Aug 27, 2024
f5f9c84
chore: Update Content-Security-Policy header in nginx.config
Svenstar74 Aug 27, 2024
96256f5
Update Content-Security-Policy header in nginx.config
epixieme Aug 27, 2024
3fedd9b
clean up
epixieme Aug 27, 2024
8e8f057
Merge pull request #657 from ClimateMind/update-nginx-config-to-inclu…
epixieme Aug 27, 2024
01b8381
Closes [661] - Customize the google login button (#662)
epixieme Sep 3, 2024
e8d07e6
chore: Update Content-Security-Policy header in nginx.config (#664)
epixieme Sep 3, 2024
0fb53c6
Closes [665] - Create userb google login and sign in (#667)
epixieme Sep 5, 2024
122398b
Bump @mui/material from 5.16.5 to 5.16.7 (#642)
dependabot[bot] Sep 8, 2024
8a17b95
Bump react-router-dom from 6.25.1 to 6.26.1 (#647)
dependabot[bot] Sep 8, 2024
894b798
Bump @sentry/react from 7.118.0 to 8.28.0 (#666)
dependabot[bot] Sep 8, 2024
0959687
Bump @sentry/cli from 2.33.0 to 2.35.0 (#669)
dependabot[bot] Sep 8, 2024
573e342
Bump @tanstack/react-query from 5.51.21 to 5.55.0 (#670)
dependabot[bot] Sep 8, 2024
b17e17a
fix: Dockerfile to reduce vulnerabilities (#674)
TrishaChetani Sep 8, 2024
d28dd06
fix: Dockerfile.local to reduce vulnerabilities (#673)
TrishaChetani Sep 8, 2024
e4fc3b9
fix: Dockerfile.production to reduce vulnerabilities (#672)
TrishaChetani Sep 8, 2024
4cabc65
fix: Dockerfile.test to reduce vulnerabilities (#671)
TrishaChetani Sep 8, 2024
97d6ac8
small adjustments to quiz and login page
Svenstar74 Sep 8, 2024
aa83176
Merge branch 'master' into develop
Svenstar74 Sep 8, 2024
a24c2ed
[686] - create code for refreshing google auth token (#690)
epixieme Sep 25, 2024
19a6bbf
Refactor useApiClient to set secure cookies for access and refresh to…
Svenstar74 Oct 4, 2024
5f69cf8
696 - Minor Fix on cypress to amend the wait times and failures (#706)
epixieme Oct 10, 2024
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY . ./
RUN npm run build

##stage 2. build the production (server) environment
FROM nginx:1.17-alpine
FROM nginx:1.23.2-alpine

#install curl and envsubst
RUN apk --no-cache add curl
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY . ./
RUN npm run build

##stage 2. build the production (server) environment
FROM nginx:1.17-alpine
FROM nginx:1.23.2-alpine

#install curl and envsubst
RUN apk --no-cache add curl
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY . ./
RUN npm run build

##stage 2. build the production (server) environment
FROM nginx:1.17-alpine
FROM nginx:1.23.2-alpine

# Install curl and envsubst
RUN apk --no-cache add curl
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ COPY .env.development .env.production
RUN npm run build

## Stage 2. build the production (server) environment
FROM nginx:1.17-alpine
FROM nginx:1.23.2-alpine

# Install curl and envsubst
RUN apk --no-cache add curl
Expand Down
98 changes: 68 additions & 30 deletions cypress/e2e/new-user-a.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ describe('New UserA', () => {
it('allows new userA to go through 10 questions, see his results (personal values) and sign up', () => {
// Load the HomePage and accept cookies
cy.visit('/');
cy.get('button').contains(/accept/i).click();
cy.get('button')
.contains(/accept/i)
.click();

// Transition to the PreQuizPage through button click
cy.get('button').contains(/get started/i).click({ force: true });
cy.get('button')
.contains(/get started/i)
.click({ force: true });
cy.location('pathname').should('equal', '/start');

// Transition to the QuizPage through button click
cy.get('button').contains(/take the quiz/i).click({ force: true });
cy.get('button')
.contains(/take the quiz/i)
.click({ force: true });
cy.location('pathname').should('equal', '/questionnaire');

// Complete the quiz.
for (let i = 0; i < 10; i++) {
cy.contains('Q' + (i+1));
cy.contains('/10')
cy.contains('Q' + (i + 1));
cy.contains('/10');
cy.contains(/not like me at all/i).click({ force: true });
cy.tick(300); // Skip the animation between questions
cy.wait(100); // Wait for the next question to appear
Expand All @@ -37,21 +43,32 @@ describe('New UserA', () => {
// Submit the feedback and finish the quiz
cy.contains(/bonus/i);
cy.get('input').type('Some custom feedback');
cy.get('button').contains(/finish quiz/i).click();
cy.get('button')
.contains(/finish quiz/i)
.click();

// Find out the results (personal values)
cy.location('pathname').should('equal', '/submit');
cy.get('button').contains(/find out my climate personality/i).click();
cy.get('button')
.contains(/find out my climate personality/i)
.click();
cy.location('pathname').should('equal', '/personal-values');

cy.contains(/power/i).should('be.visible');
cy.contains(/security/i).should('be.visible');
cy.contains(/tradition/i).should('be.visible');

cy.get('canvas[typeof="radar"]').should('be.visible');
cy.tick(300);
cy.wait(100);
cy.contains(/power/i).scrollIntoView().should('be.visible');
cy.contains(/security/i)
.scrollIntoView()
.should('be.visible');
cy.contains(/tradition/i)
.scrollIntoView()
.should('be.visible');

cy.get('canvas[typeof="radar"]').scrollIntoView().should('be.visible');

// Complete by going to the sign up page
cy.get('button').contains(/dive in/i).click();
cy.get('button')
.contains(/dive in/i)
.click();
cy.location('pathname').should('equal', '/sign-up');

// At first the sign up button should be disabled
Expand All @@ -64,26 +81,34 @@ describe('New UserA', () => {
cy.get('input[id="confirmPassword"]').type('asdf1234');

// Now the sign up button should be enabled and login the user as well
cy.get('button').contains(/create account/i).click();
cy.get('button')
.contains(/create account/i)
.click();
cy.location('pathname').should('equal', '/climate-feed');
});

it('allows new userA to go through 20 questions, see his results (personal values) and sign up', () => {
// Load the HomePage and accept cookies
cy.visit('/');
cy.get('button').contains(/accept/i).click();
cy.get('button')
.contains(/accept/i)
.click();

// Transition to the PreQuizPage through button click
cy.get('button').contains(/get started/i).click({ force: true });
cy.get('button')
.contains(/get started/i)
.click({ force: true });
cy.location('pathname').should('equal', '/start');

// Transition to the QuizPage through button click
cy.get('button').contains(/take the quiz/i).click({ force: true });
cy.get('button')
.contains(/take the quiz/i)
.click({ force: true });
cy.location('pathname').should('equal', '/questionnaire');

// Complete the quiz.
for (let i = 0; i < 10; i++) {
cy.contains('Q' + (i+1));
cy.contains('Q' + (i + 1));
cy.contains('/10');
cy.contains(/not like me at all/i).click({ force: true });
cy.tick(300); // Skip the animation between questions
Expand All @@ -93,16 +118,20 @@ describe('New UserA', () => {
// Submit the feedback and finish the quiz
cy.contains(/bonus/i);
cy.get('input').type('Some custom feedback');
cy.get('button').contains(/finish quiz/i).click();
cy.get('button')
.contains(/finish quiz/i)
.click();

// Continue with the next 10 questions
cy.location('pathname').should('equal', '/submit');
cy.get('button').contains(/continue/i).click();
cy.get('button')
.contains(/continue/i)
.click();
cy.location('pathname').should('equal', '/questionnaire');

// Complete the quiz.
for (let i = 10; i < 20; i++) {
cy.contains('Q' + (i+1));
cy.contains('Q' + (i + 1));
cy.contains('/20');
cy.contains(/not like me at all/i).click({ force: true });
cy.tick(300); // Skip the animation between questions
Expand All @@ -111,17 +140,26 @@ describe('New UserA', () => {

// Find out the results (personal values)
cy.location('pathname').should('equal', '/submit-set-two');
cy.get('button').contains(/find out my climate personality/i).click();
cy.get('button')
.contains(/find out my climate personality/i)
.click();
cy.location('pathname').should('equal', '/personal-values');

cy.contains(/power/i).should('be.visible');
cy.contains(/security/i).should('be.visible');
cy.contains(/tradition/i).should('be.visible');

cy.get('canvas[typeof="radar"]').should('be.visible');
cy.tick(300);
cy.wait(100);
cy.contains(/power/i).scrollIntoView().should('be.visible');
cy.contains(/security/i)
.scrollIntoView()
.should('be.visible');
cy.contains(/tradition/i)
.scrollIntoView()
.should('be.visible');

cy.get('canvas[typeof="radar"]').scrollIntoView().should('be.visible');

// Complete by going to the sign up page
cy.get('button').contains(/dive in/i).click();
cy.get('button')
.contains(/dive in/i)
.click();
cy.location('pathname').should('equal', '/sign-up');
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "cypress run",
"test": "cypress run --headed",
"docker:build": "docker build -t react-docker .",
"docker:run": "docker run -p 3000:80 -e http://localhost:5000 --rm react-docker",
"docker:dev:build": "docker build -f Dockerfile.dev -t react-docker-dev .",
Expand Down
1 change: 1 addition & 0 deletions src/api/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type Login = {
export type googleLogin = {
message: string;
access_token: string;
refresh_token: string;
user: {
email: string;
first_name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/features/auth/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function LoginForm({ isLoading, onLogin, onForgotPasswordClick }: Props) {

<div style={styles.passwordResetContainer}>
<CmTypography variant="body">Forgot your password?</CmTypography>

<CmButton variant="text" text="Send reset link" onClick={onForgotPasswordClick} style={{ textTransform: 'none' }} />
</div>

Expand All @@ -42,7 +41,8 @@ const styles: { [key: string]: React.CSSProperties } = {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
width: '100%',
width: '80vw',
maxWidth: 320,
},
textInput: {
marginTop: 20,
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/hooks/useLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function useLogin() {
const dispatch = useAppDispatch();
const quizIdB = useAppSelector((state) => state.auth.userB.quizId);
const quizIdA = useAppSelector((state) => state.auth.userA.quizId);

const apiClient = useApiClient();
const { showSuccessToast, showErrorToast } = useToastMessage();

Expand Down
5 changes: 1 addition & 4 deletions src/features/quiz/components/QuizProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMediaQuery } from '@mui/material';
import { CmBackButton, CmTypography } from 'shared/components';

interface Props {
Expand All @@ -9,11 +8,9 @@ interface Props {
}

function QuizProgress({ onBack, currentQuestionIndex, maxQuestionIndex, alternativeText }: Props) {
const isSmall = useMediaQuery('(max-width: 960px)');

// We only show the back button on the top for small screens. For larger screens it is beneath the question.
// And of course we don't show it on the first question, because there's no question to go back to.
const showBackButtonTop = isSmall && (maxQuestionIndex - currentQuestionIndex) !== 9;
const showBackButtonTop = (maxQuestionIndex - currentQuestionIndex) !== 9;

// Calculate the current value of the progress bar.
let progress = currentQuestionIndex / 10 - 0.1;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/UserAUnauthorizedPages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { LoginForm, RequestPasswordResetModal, useLogin, useResetPassword } from
import { useMobileView } from 'shared/hooks';

function LoginPage() {
const devMode = localStorage.getItem('devMode') === 'true';
const navigate = useNavigate();
const location = useLocation();
const isMobile = useMobileView();
Expand Down Expand Up @@ -51,7 +50,7 @@ function LoginPage() {
<div style={{ display: 'flex', flexDirection: 'column', gap: 19, justifyContent: 'center', alignItems: 'center' }}>
<LoginForm isLoading={isLoading} onLogin={handleSubmit} onForgotPasswordClick={() => setShowPasswordResetModal(true)} />
<div style={{ borderBottom: '1px solid #0000001A', height: 1, width: 205 }}></div>
{devMode && <GoogleLogin navigateAfterLogin={navigateAfterLogin} text="Log In With Google" />}
<GoogleLogin navigateAfterLogin={navigateAfterLogin} text="Log In With Google" />
</div>

<RequestPasswordResetModal isOpen={showPasswordResetModal} onClose={() => setShowPasswordResetModal(false)} onSubmit={handlePasswordReset} />
Expand Down
4 changes: 1 addition & 3 deletions src/pages/UserAUnauthorizedPages/SignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { SignUpForm, useSignUp } from 'features/auth';
import GoogleLogin from 'features/auth/components/GoogleLogin';

function SignUpPage() {
const devMode = localStorage.getItem('devMode') === 'true';

const signUpId = uuidv4();
const navigate = useNavigate();

Expand Down Expand Up @@ -51,7 +49,7 @@ function SignUpPage() {
<div style={{ display: 'flex', flexDirection: 'column', gap: 19, justifyContent: 'center', alignItems: 'center' }}>
<SignUpForm isLoading={isLoading} onSignUp={signUpHandler} />
<div style={{ borderBottom: '1px solid #0000001A', height: 1, width: 205 }}></div>
{devMode && <GoogleLogin navigateAfterLogin={navigateAfterLogin} text="Continue With Google" />}
<GoogleLogin navigateAfterLogin={navigateAfterLogin} text="Continue With Google" />
</div>
</PageContent>
</Page>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/UserBPages/UserBSignUpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function UserBSignUpPage() {
<CmTypography variant="h1">Welcome to Climate Mind</CmTypography>

<div style={{ display: 'flex' }}>
<CmTypography variant="body" style={{ textAlign: 'center' }}>Already have an account?</CmTypography>
<CmTypography variant="body" style={{ textAlign: 'center' }}>
Already have an account?
</CmTypography>
<CmButton variant="text" text="Login" onClick={() => navigate(ROUTES.LOGIN_PAGE)} style={styles.loginButton} />
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 19, justifyContent: 'center', alignItems: 'center' }}>
Expand Down
Loading
Loading