Skip to content

Commit c8bc3f1

Browse files
committed
Merge 2.22.11
2 parents 529f22d + 42aad4e commit c8bc3f1

21 files changed

Lines changed: 309 additions & 59 deletions

File tree

‎.env.example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ GOOGLE_ID=<your-google-client-id> (use google+ api)
1616
GOOGLE_SECRET=<your-google-client-secret> (use google+ api)
1717
MAILGUN_DOMAIN=<your-mailgun-domain>
1818
MAILGUN_KEY=<your-mailgun-api-key>
19+
# For local mail testing
20+
EMAIL_TRANSPORT=smtp
21+
MAILPIT_SMTP_PORT=1025
1922
ML5_LIBRARY_USERNAME=ml5
2023
ML5_LIBRARY_EMAIL=examples@ml5js.org
2124
ML5_LIBRARY_PASS=helloml5

‎.github/workflows/deploy-staging.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- develop
77
types:
88
- completed
9+
# Run staging deploys one at a time
10+
concurrency:
11+
group: deploy-staging-${{ github.event.workflow_run.conclusion }}
12+
cancel-in-progress: false
913
env:
1014
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
1115
GKE_CLUSTER: p5-gke-cluster

‎.github/workflows/deploy.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- release
77
types:
88
- completed
9+
# Run production deploys one at a time
10+
concurrency:
11+
group: deploy-production-${{ github.event.workflow_run.conclusion }}
12+
cancel-in-progress: false
913
env:
1014
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
1115
GKE_CLUSTER: p5-gke-cluster
@@ -14,6 +18,7 @@ env:
1418
IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor
1519
jobs:
1620
push_to_registry:
21+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1722
environment: production
1823
name: Push Docker image to Docker Hub
1924
runs-on: ubuntu-latest
@@ -47,7 +52,7 @@ jobs:
4752
with:
4853
service_account_key: ${{ secrets.GKE_SA_KEY }}
4954
project_id: ${{ secrets.GKE_PROJECT }}
50-
55+
5156
# Configure docker to use the gcloud command-line tool as a credential helper
5257
- run: |-
5358
gcloud --quiet auth configure-docker

‎.github/workflows/e2e.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on:
33
workflow_dispatch:
44
pull_request:
55
branches: [develop]
6+
7+
# Cancel superseded PR runs
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
10+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
11+
612
jobs:
713
test-e2e:
814
environment: e2e-tests

‎.github/workflows/test.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ on:
77
- develop
88
- release
99

10+
# Cancel superseded PR runs; let develop/release runs finish since they trigger deploys
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
1015
jobs:
1116
test:
1217
name: Test and lint code base
1318
runs-on: ubuntu-latest
1419
steps:
15-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
1621
- name: Use Node.js
17-
uses: actions/setup-node@v1
22+
uses: actions/setup-node@v4
1823
with:
1924
node-version: '18.20.x'
20-
- run: npm install
25+
cache: 'npm'
26+
- run: npm ci
2127
- run: npm run test
2228
- run: npm run typecheck
2329
- run: npm run lint
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import React from 'react';
2+
import thunk from 'redux-thunk';
3+
import configureStore from 'redux-mock-store';
4+
import { screen, fireEvent, act } from '@testing-library/react';
5+
6+
import { LoginView } from './LoginView';
7+
import { reduxRender, history } from '../../../test-utils';
8+
import { initialTestState } from '../../../testData/testReduxStore';
9+
import * as actions from '../actions';
10+
11+
const mockStore = configureStore([thunk]);
12+
13+
jest.mock('../actions', () => ({
14+
...jest.requireActual('../actions'),
15+
validateAndLoginUser: jest.fn().mockReturnValue(
16+
(dispatch) =>
17+
new Promise((resolve) => {
18+
dispatch({ type: 'AUTH_USER', payload: {} });
19+
dispatch({ type: 'SET_PREFERENCES', payload: {} });
20+
resolve();
21+
})
22+
)
23+
}));
24+
25+
jest.mock('../../../common/useSyncFormTranslations', () => ({
26+
useSyncFormTranslations: jest.fn()
27+
}));
28+
29+
describe('<LoginView />', () => {
30+
let store;
31+
32+
beforeEach(() => {
33+
store = mockStore(initialTestState);
34+
jest.clearAllMocks();
35+
});
36+
37+
const renderComponent = () => reduxRender(<LoginView />, { store });
38+
39+
it('renders page heading, login form, social auth buttons, and navigation links', () => {
40+
renderComponent();
41+
42+
// Verify main page title and divider
43+
expect(
44+
screen.getByRole('heading', { name: /log in/i, level: 2 })
45+
).toBeInTheDocument();
46+
expect(
47+
screen.getByRole('heading', { name: /^or$/i, level: 2 })
48+
).toBeInTheDocument();
49+
50+
// Verify embedded LoginForm fields
51+
expect(
52+
screen.getByRole('textbox', { name: /email or username/i })
53+
).toBeInTheDocument();
54+
expect(screen.getByLabelText(/^password$/i)).toBeInTheDocument();
55+
expect(screen.getByRole('button', { name: /log in/i })).toBeInTheDocument();
56+
57+
// Verify social authentication buttons
58+
const githubButton = screen.getByRole('link', { name: /github/i });
59+
expect(githubButton).toBeInTheDocument();
60+
expect(githubButton).toHaveAttribute('href', '/auth/github');
61+
62+
const googleButton = screen.getByRole('link', { name: /google/i });
63+
expect(googleButton).toBeInTheDocument();
64+
expect(googleButton).toHaveAttribute('href', '/auth/google');
65+
66+
// Verify navigation links for signup and reset-password
67+
const signupLink = screen.getByRole('link', { name: /sign up/i });
68+
expect(signupLink).toBeInTheDocument();
69+
expect(signupLink).toHaveAttribute('href', '/signup');
70+
71+
const resetPasswordLink = screen.getByRole('link', {
72+
name: /reset your password/i
73+
});
74+
expect(resetPasswordLink).toBeInTheDocument();
75+
expect(resetPasswordLink).toHaveAttribute('href', '/reset-password');
76+
});
77+
78+
it('navigates to the signup page when the sign up link is clicked', () => {
79+
renderComponent();
80+
81+
const signupLink = screen.getByRole('link', { name: /sign up/i });
82+
fireEvent.click(signupLink);
83+
84+
expect(history.location.pathname).toBe('/signup');
85+
});
86+
87+
it('navigates to the reset password page when the reset password link is clicked', () => {
88+
renderComponent();
89+
90+
const resetPasswordLink = screen.getByRole('link', {
91+
name: /reset your password/i
92+
});
93+
fireEvent.click(resetPasswordLink);
94+
95+
expect(history.location.pathname).toBe('/reset-password');
96+
});
97+
98+
it('integrates with LoginForm and submits user credentials', async () => {
99+
renderComponent();
100+
101+
const emailInput = screen.getByRole('textbox', {
102+
name: /email or username/i
103+
});
104+
fireEvent.change(emailInput, {
105+
target: { value: 'testuser@example.com' }
106+
});
107+
108+
const passwordInput = screen.getByLabelText(/^password$/i);
109+
fireEvent.change(passwordInput, {
110+
target: { value: 'password123' }
111+
});
112+
113+
const submitButton = screen.getByRole('button', { name: /log in/i });
114+
await act(async () => {
115+
fireEvent.click(submitButton);
116+
});
117+
118+
expect(actions.validateAndLoginUser).toHaveBeenCalledWith({
119+
email: 'testuser@example.com',
120+
password: 'password123'
121+
});
122+
});
123+
});

‎client/styles/components/_console.scss‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
flex: 1;
4242
flex-direction: column;
4343
overflow-y: auto;
44+
a.linkified {
45+
@include themify() {
46+
color: getThemifyVariable('link-text-color');
47+
}
48+
49+
&:hover {
50+
text-decoration: underline;
51+
text-decoration-thickness: 0.1em;
52+
}
53+
}
4454
& div div div:first-child {
4555
height: unset;
4656
line-height: unset;

‎client/styles/components/_nav.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
}
225225

226226
.nav__items-right {
227+
min-width: 11rem;
227228
padding-right: #{math.div(20, $base-font-size)}rem;
228229

229230
& .nav__dropdown {

‎contributor_docs/installation.md‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,20 @@ _Note_: The installation steps assume you are using a Unix-like shell. If you ar
4545
- Choose **Node.js** as the driver for your connection method. You will see a connection string, with or without the password filled in.
4646
- Copy the string and use it as your `MONGO_URL` in the `.env` file.
4747
8. `$ cp .env.example .env`
48-
9. (Optional) Update `.env` with necessary keys to enable certain app behaviors, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
48+
9. (Optional) To test emails locally, install and run [Mailpit](https://github.com/axllent/mailpit) and read mail at [http://localhost:8025](http://localhost:8025).
49+
* MacOS with homebrew: `brew install mailpit`, then run `mailpit`.
50+
* Windows: `winget install axllent.mailpit`, then run `mailpit`.
51+
* Docker: `docker run -p 1025:1025 -p 8025:8025 axllent/mailpit` (skip this if you're using the Docker installation below, which bundles Mailpit).
52+
* Note: if Mailpit isn't running, sending email (e.g. signup verification) will fail.
53+
10. (Optional) Update `.env` with necessary keys to enable certain app behaviors, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
4954
* See the [GitHub API Configuration](#github-api-configuration) section for information on how to authenticate with Github.
5055
* See the [S3 Bucket Configuration](#s3-bucket-configuration) section for information on how to set up an S3 bucket
51-
10. (Optional) Run `$ npm run fetch-examples` to download the example sketches into a user called 'p5'. Note that you need to configure your GitHub Credentials, which you can do by following the [Github API Configuration](#github-api-configuration) section.
52-
11. Enable Prettier in your text editor by following [this guide](https://prettier.io/docs/en/editors.html).
53-
12. `$ npm start`
54-
13. Navigate to [http://localhost:8000](http://localhost:8000) in your browser
55-
14. Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
56-
15. Open and close the Redux DevTools using `ctrl+h`, and move them with `ctrl+w`
56+
11. (Optional) Run `$ npm run fetch-examples` to download the example sketches into a user called 'p5'. Note that you need to configure your GitHub Credentials, which you can do by following the [Github API Configuration](#github-api-configuration) section.
57+
12. Enable Prettier in your text editor by following [this guide](https://prettier.io/docs/en/editors.html).
58+
13. `$ npm start`
59+
14. Navigate to [http://localhost:8000](http://localhost:8000) in your browser
60+
15. Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
61+
16. Open and close the Redux DevTools using `ctrl+h`, and move them with `ctrl+w`
5762

5863
## Docker Installation
5964

@@ -81,14 +86,15 @@ Now, anytime you wish to start the server with its dependencies, you can run:
8186

8287
9. `$ docker-compose -f docker-compose-development.yml up`
8388
10. Navigate to [http://localhost:8000](http://localhost:8000) in your browser
89+
11. Mail sent by the app is caught by the bundled Mailpit service, read it at [http://localhost:8025](http://localhost:8025).
8490

8591
To open a terminal/shell in the running Docker server (i.e. after `docker-compose up` has been run):
8692

87-
11. `$ docker-compose -f docker-compose-development.yml exec app bash -l`
93+
12. `$ docker-compose -f docker-compose-development.yml exec app bash -l`
8894

8995
If you don't have the full server environment running, you can launch a one-off container instance (and have it automatically deleted after you're done using it):
9096

91-
12. `$ docker-compose -f docker-compose-development.yml run app --rm bash -l`
97+
13. `$ docker-compose -f docker-compose-development.yml run app --rm bash -l`
9298

9399
## Environment Files
94100

‎docker-compose-development.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
target: development
1111
environment:
1212
- MONGO_URL=mongodb://mongo:27017/p5js-web-editor
13+
- MAILPIT_SMTP_HOST=mailpit
1314
volumes:
1415
- .:/usr/src/app
1516
- /usr/src/app/node_modules
@@ -18,5 +19,10 @@ services:
1819
- '8002:8002'
1920
depends_on:
2021
- mongo
22+
- mailpit
23+
mailpit:
24+
image: axllent/mailpit
25+
ports:
26+
- '8025:8025'
2127
volumes:
2228
dbdata:

0 commit comments

Comments
 (0)