Skip to content

Commit 87f5ae3

Browse files
committed
chore: moved out E2E details from README into their own doc
1 parent c2a4968 commit 87f5ae3

File tree

2 files changed

+76
-105
lines changed

2 files changed

+76
-105
lines changed

E2E Overview.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# End-to-End Testing with Playwright
2+
3+
To run the end-to-end tests using Playwright, you need to configure your environment and follow these steps:
4+
5+
### Environment Variables
6+
7+
Ensure you have the following variables set in your `.env` file:
8+
9+
- `E2E_USER_ID`: The ID of the E2E user for testing.
10+
- `E2E_USER_EMAIL`: The email of the E2E user for testing.
11+
- `E2E_USER_ONE_SESSION_ID`: The session ID that the user will use to authenticate.
12+
13+
Note: The sample `.env` file is fine to use.
14+
15+
### Session and User Setup
16+
17+
First, you need to add your E2E test user to your locally running database. Do this by running the following script if you haven't already:
18+
19+
```bash
20+
npm run db:seed
21+
```
22+
23+
This will create a user and session for your E2E tests. Details of the E2E user created can be seen in `drizzle/seedE2E.ts`.
24+
25+
### Running the Tests
26+
27+
You can run the end-to-end tests using one of the following commands:
28+
29+
For headless mode:
30+
31+
```bash
32+
npx playwright test
33+
```
34+
35+
For UI mode:
36+
37+
```bash
38+
npx playwright test --ui
39+
```
40+
41+
### Additional E2E Environment Variables
42+
43+
- **E2E_USER_ONE_SESSION_ID**: This is the session token UUID for one E2E user.
44+
- **E2E_USER_TWO_SESSION_ID**: This is the session token UUID for another E2E user.
45+
- **E2E_USER_ONE_ID**: The user ID of one of the E2E users.
46+
- **E2E_USER_TWO_ID**: The user ID of another E2E user.
47+
48+
These values are currently hardcoded and should be unique for each user.

README.md

Lines changed: 28 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,35 @@ GITHUB_SECRET=YOUR_GITHUB_APP_SECRET
4141
NEXTAUTH_URL=http://localhost:3000/api/auth
4242
```
4343

44-
For a more detailed how to guide on setting them up [go to the Environment Variables section](#environment-variables).
44+
For a more detailed guide on setting them up [go to the Environment Variables section](#environment-variables).
4545

4646
**NOTE:** Before proceeding, [make sure your database is running](#database_url).
4747

48-
6. Setup the tables in the database with Drizzle by running:
48+
6. Setup the tables in the database with Drizzle by running:
4949

5050
```bash
5151
npm run db:migrate
5252
```
5353

54-
The full command can be seen in our [package.json](/package.json#16) file
54+
The full command can be seen in our [package.json](/package.json#16) file.
5555

5656
7. Seed the database with some mock data by running:
5757

5858
```bash
5959
npm run db:seed
6060
```
6161

62-
The full command can be seen in our [package.json](/package.json#19) file
62+
The full command can be seen in our [package.json](/package.json#19) file.
6363

6464
8. Finally, run the development server:
6565

6666
```bash
6767
npm run dev
6868
```
6969

70-
After completion of above commands, now -
70+
After completion of the above commands, navigate to [http://localhost:3000](http://localhost:3000) in your browser to see the result.
7171

72-
Navigate to [http://localhost:3000](http://localhost:3000) in your browser to see the result.
73-
74-
You can start your journey by modifying `pages/index.tsx`. With Auto-update feature, pages updates as you edit the file.
72+
You can start your journey by modifying `pages/index.tsx`. With the auto-update feature, pages update as you edit the file.
7573

7674
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
7775

@@ -89,49 +87,39 @@ To run this file, make sure you have [Docker installed](https://docs.docker.com/
8987

9088
Run the command `docker compose up`.
9189

92-
Alternatively, if you have PostgreSQL running locally then you can use your local connection string or grab one from a free service like [Supabase](https://supabase.com/docs/guides/database/connecting-to-postgres#finding-your-connection-string).
90+
Alternatively, if you have PostgreSQL running locally, you can use your local connection string or grab one from a free service like [Supabase](https://supabase.com/docs/guides/database/connecting-to-postgres#finding-your-connection-string).
9391

9492
### GITHUB_ID and GITHUB_SECRET
9593

96-
Currently, we only allow authentication via GitHub. To enable this you need to have a `GITHUB_ID` and `GITHUB_SECRET` value.
94+
Currently, we only allow authentication via GitHub. To enable this, you need to have a `GITHUB_ID` and `GITHUB_SECRET` value.
9795

98-
Setup your GitHub ID & Secret on GitHub:
96+
Set up your GitHub ID & Secret on GitHub:
9997

100-
- [Click here](https://github.com/settings/applications/new) to setup New OAuth App and fill in the details as shown below.
98+
- [Click here](https://github.com/settings/applications/new) to set up a New OAuth App and fill in the details as shown below.
10199

102-
For development, make sure you setup this with a **Homepage URL** of
100+
For development, make sure you set this up with a **Homepage URL** of
103101

104102
```
105103
http://localhost:3000/
106104
```
107105

108-
and **Authorization callback URL** of
106+
and an **Authorization callback URL** of
109107

110108
```
111109
http://localhost:3000/api/auth
112110
```
113111

114-
as shown in the image below:
115-
116-
![Screenshot 2022-10-25 at 08 22 03](https://user-images.githubusercontent.com/12615742/197709325-50766dc2-2245-438c-8f71-09064fc3b123.png)
117-
118-
After you click the "Register application" button you should see the `GITHUB_ID` and be able to generate a new client secret. You can see this in the screenshot below. 👇
119-
![Screenshot 2022-10-25 at 08 23 22](https://user-images.githubusercontent.com/12615742/197710695-d3ef9cb7-fe66-4a53-8b3e-d66064434068.png)
120-
After generating the secret, make sure you copy this value to your `.env` file as this value can not be seen again once you refresh the page. 👇
121-
![Screenshot 2022-10-25 at 08 26 04](https://user-images.githubusercontent.com/12615742/197710697-ef791d9e-b205-4667-a97c-477148917897.png)
112+
After you click the "Register application" button, you should see the `GITHUB_ID` and be able to generate a new client secret. After generating the secret, make sure you copy this value to your `.env` file as this value cannot be seen again once you refresh the page.
122113

123-
More info on Authorizing OAuth in the GitHub documentation
124-
[here](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps).
114+
More info on Authorizing OAuth in the GitHub documentation [here](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps).
125115

126-
### Setting up Passwordless auth locally
116+
### Setting up Passwordless Auth Locally
127117

128-
In order to use Passwordless login locally you need to have a `ACCESS_KEY` and `SECRET_KEY` value.
118+
In order to use Passwordless login locally, you need to have an `ACCESS_KEY` and `SECRET_KEY` value.
129119

130-
Niall has written a [tutorial](https://www.codu.co/articles/sending-emails-with-aws-ses-and-nodemailer-in-node-js-xfuucrri) on how to send emails with AWS SES and shows how to get these values.
120+
Check out the example `.env` file [here](./sample.env) to see how to populate these values.
131121

132-
Check out the example .env file [here](./sample.env) to see how to populate these values
133-
134-
**Note: Currenly the AWS region of the SNS service is hardcoded to "eu-west-1" it may be necessary to change this if your SNS service is in a different region**
122+
**Note:** Currently, the AWS region of the SNS service is hardcoded to "eu-west-1"; it may be necessary to change this if your SNS service is in a different region.
135123

136124
### NEXTAUTH_URL
137125

@@ -141,85 +129,16 @@ You shouldn't need to change the default value here. This is a variable used by
141129
NEXTAUTH_URL=http://localhost:3000/api/auth
142130
```
143131

144-
### E2E_USER_ONE_SESSION_ID
145-
146-
This is the sessionToken uuid that is used to identify a users current active session.
147-
This is currently hardcoded and their is no reason to change this value.
148-
**Note: This value must be different to E2E_USER_TWO_SESSION_ID**
149-
150-
151-
### E2E_USER_TWO_SESSION_ID
152-
153-
This is the sessionToken uuid that is used to identify a users current active session.
154-
This is currently hardcoded and their is no reason to change this value.
155-
**Note: This value must be different to E2E_USER_ONE_SESSION_ID**
156-
157-
158-
### E2E_USER_ONE_ID
159-
160-
This is the userId of one of our E2E users and is used for testing.
161-
This is currently hardcoded and there is no reason to change this value.
162-
**Note: This value must be different from E2E_USER_TWO_ID**
163-
164-
165-
### E2E_USER_TWO_ID
166-
167-
This is the userId of one of our E2E users and is used for testing.
168-
This is currently hardcoded and there is no reason to change this value.
169-
**Note: This value must be different from E2E_USER_ONE_ID**
170-
171-
For more information, you can read the documentation [here](https://next-auth.js.org/configuration/options).
172-
**Example .env file can be found [here](./sample.env). You can rename this to .env to get started**
132+
**Example .env file can be found [here](./sample.env). You can rename this to `.env` to get started.**
173133

174134
## 👨‍💻 Contribution Guidelines
175135

176136
- Contributions are **greatly appreciated**. Contributions make the open-source community an amazing place to learn, inspire, and create.
177-
- Check out our [contribution guidelines](/CONTRIBUTING.md) for contributiong to our repo. It includes
137+
- Check out our [contribution guidelines](/CONTRIBUTING.md) for contributing to our repo. It includes
178138
- How to Contribute
179139
- How to create a Pull Request
180140
- Run Tests
181-
- Also, Style Guide for Commit Messages
182-
183-
## End-to-End Testing with Playwright
184-
185-
To run the end-to-end tests using Playwright, you need to configure your environment and follow these steps:
186-
187-
### Environment Variables
188-
189-
Please ensure you have the following variables set in your `.env` file:
190-
191-
- `E2E_USER_ID`: The id of the E2E user for testing.
192-
- `E2E_USER_EMAIL`: The email of the E2E user for testing.
193-
- `E2E_USER_ONE_SESSION_ID`: The session id that the user will use to authenticate.
194-
195-
196-
Note the sample .env [here](./sample.env) is fine to use.
197-
198-
### Session and User setup
199-
200-
First you need to add your E2E test user to your locally running database. Do this by running the following script if you havent already
201-
202-
```
203-
npm run db:seed
204-
```
205-
206-
This will create a user and session for your E2E tests. Details of the E2E user created can be seen [here](./drizzle/seedE2E.ts)
207-
208-
### Running the Tests
209-
210-
You can run the end-to-end tests using one of the following commands:
211-
212-
For headless mode:
213-
214-
```zsh
215-
npx playwright test
216-
```
217-
218-
For UI mode:
219-
220-
```zsh
221-
npx playwright test --ui
222-
```
141+
- Style Guide for Commit Messages
223142

224143
## 📙 Prerequisite Skills to Contribute
225144

@@ -246,10 +165,14 @@ To learn more about Next.js, take a look at the following resources:
246165

247166
### Editor Doc
248167

249-
To learn about the editor shortcuts and hotkeys you can check out this document
168+
To learn about the editor shortcuts and hotkeys, you can check out this document:
169+
170+
- [Markdoc Editor Hotkeys and Shortcuts](/EDITOR_SHORTCUTS.MD)
171+
172+
## 🧪 E2E Testing
250173

251-
- [Markdoc Editor Hotkeys and Shortcus](/EDITOR_SHORTCUTS.MD)
174+
For information on E2E testing, please refer to our dedicated documentation [here](./E2E%20Overview.md).
252175

253176
## 💥 Issues
254177

255-
You are welcome to [open issues](https://github.com/codu-code/codu/issues/new/choose) to discuss ideas about improving our Codú. Enhancements are encouraged and appreciated.
178+
You are welcome to [open issues](https://github.com/codu-code/codu/issues/new/choose) to discuss ideas about improving Codú. Enhancements are encouraged and appreciated.

0 commit comments

Comments
 (0)