Skip to content

Commit ac5230f

Browse files
committed
Updated readme
1 parent 7d2e09d commit ac5230f

1 file changed

Lines changed: 36 additions & 22 deletions

File tree

Readme.md

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ For tests that rely on being logged in to user accounts (drive, sharing, collabo
3434

3535
This environment is kept constant and replicable between tests, i.e. if as part of a test a document is created and added to the user's drive, it must be deleted before the test is run again. To ensure this in case of code malfunction or test failure, there are several cleanup scripts in `cleanup.js` integrated into the test files, which run in order to return the test environment to its base state. However, there may be situations in which these do not work as expected, and one may be required to manually intervene in the test environment.
3636

37-
#### Seeding the database
38-
39-
> :exclamation:
40-
> The setup, authentication and teardown scripts **must** be run on Chromium as we have found it to be the most stable browser for this process and least likely to result in failures or errors. It can also be run on either OSX or Windows, but **not** on a mobile device.
41-
42-
1. Set passwords for the following test accounts:
37+
The tests for logged-in users require passwords to use with test accounts. You will need to set passwords for the following test accounts:
4338

4439
* test-user
4540
* testuser
@@ -55,8 +50,29 @@ TESTUSER2PASSWORD = ""
5550
TESTUSER3PASSWORD = ""
5651
```
5752

58-
They will be used by the script that creates accounts in the next step.
53+
If you seed the database using the 'Extracting data' method (recommended) (see below), you will need to set them to the passwords already contained in the data seed (i.e. "password" for each of the test users). If you choose to seed the database by running the seeding script, you can set the passwords to a string of your choosing.
54+
55+
#### Seeding the database
56+
57+
> :information_source:
58+
> It is recommended that you run tests against a repository specifically dedicated for this purpose to enable easily wiping and seeding test data.
59+
60+
There are two ways to seed the database. One is running a Playwright file which creates the user accounts, files etc. required for the tests through UI interactions with CryptPad. This is time-consuming and prone to error, and thus seeding the database through expanding a .zip file, containing "ready-made" user data, is recommended instead. Instructions for both are provided below.
61+
62+
0. Run `npm run clear` in your dedicated test CryptPad repo to erase existing user and file data.
63+
64+
##### Extract data from database seed file
65+
66+
1. In your CryptPad repo, check out branch `2025.6_seed`
67+
2. Extract the user data using `unzip database_seed_2025.6.zip`
68+
3. Checkout the branch you wish to run tests against
69+
70+
71+
##### Running the seeding script
72+
> :exclamation:
73+
> The setup, authentication and teardown scripts **must** be run on Chromium as we have found it to be the most stable browser for this process and least likely to result in failures or errors. It can also be run on either OSX or Windows, but **not** on a mobile device.
5974
75+
0. Make sure you have set the passwords for each of the test users with the use of environment variables (see above)
6076

6177
1. Set up the test environment:
6278

@@ -68,35 +84,36 @@ npx playwright test dbseeding --workers=1 --project='chrome'
6884

6985
You can specify another OS name or run the file using BrowserStack as desired (see [Running tests](## Running Tests)).
7086

87+
A database teardown script is not included because CryptPad does not allow the re-creation of accounts (i.e. deleting an account and creating a new one with the same username and password). If running on a local instance, stop and run:
88+
89+
```bash
90+
npm run clear
91+
```
92+
in the same tab to unseed the database.
93+
94+
##### Authenticating users
7195

72-
3. To save the authentication information for test accounts:
96+
Once the database is seeded, you will need to store the authentication information for test accounts.
7397

74-
* create the auth folder:
98+
1. Create the auth folder:
7599

76100
```bash
77101
mkdir auth
78102
```
79103

80-
* change directory to auth folder and create files to store authentication information for each test account using:
104+
2. Change directory to auth folder and create files to store authentication information for each test account using:
81105

82106
```bash
83107
cd auth
84108
touch mainuser.json testuser.json testuser2.json testuser3.json
85109
```
86110

87-
* then change back to project root directory and run the auth script using:
111+
3. Change back to project root directory and run the auth script using:
88112

89113
```bash
90114
cd ..
91115
npx playwright test auth --workers=1 --project='chrome'
92-
```
93-
94-
A database teardown script is not included because CryptPad does not allow the re-creation of accounts (i.e. deleting an account and creating a new one with the same username and password). If running on a local instance, stop and run:
95-
96-
```bash
97-
npm run clear
98-
```
99-
in the same tab to unseed the database.
116+
```
100117

101118

102119
### Browserstack authentication and integration
@@ -133,9 +150,6 @@ To run the tests using BrowserStack, add the desired OS and `@BrowserStack` (for
133150
> :exclamation:
134151
> It is strongly recommended that the tests be run over a strong and stable internet connection, **especially** when using BrowserStack. Tests run over slow connections will often time out and fail or hang indefinitely.
135152
136-
> :information_source:
137-
> If running tests against a local instance, it is recommended that you run it from a repository specifically dedicated for tests to enable wiping test data using `npm run clear` in the CryptPad repo.
138-
139153
0. If running tests for the first time on your chosen browser/OS combination, run:
140154

141155
```bash

0 commit comments

Comments
 (0)