You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+36-22Lines changed: 36 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,12 +34,7 @@ For tests that rely on being logged in to user accounts (drive, sharing, collabo
34
34
35
35
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.
36
36
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:
43
38
44
39
* test-user
45
40
* testuser
@@ -55,8 +50,29 @@ TESTUSER2PASSWORD = ""
55
50
TESTUSER3PASSWORD = ""
56
51
```
57
52
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.
59
74
75
+
0. Make sure you have set the passwords for each of the test users with the use of environment variables (see above)
60
76
61
77
1. Set up the test environment:
62
78
@@ -68,35 +84,36 @@ npx playwright test dbseeding --workers=1 --project='chrome'
68
84
69
85
You can specify another OS name or run the file using BrowserStack as desired (see [Running tests](## Running Tests)).
70
86
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
71
95
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.
73
97
74
-
* create the auth folder:
98
+
1. Create the auth folder:
75
99
76
100
```bash
77
101
mkdir auth
78
102
```
79
103
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:
* 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:
88
112
89
113
```bash
90
114
cd ..
91
115
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
+
```
100
117
101
118
102
119
### Browserstack authentication and integration
@@ -133,9 +150,6 @@ To run the tests using BrowserStack, add the desired OS and `@BrowserStack` (for
133
150
> :exclamation:
134
151
> 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.
135
152
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
-
139
153
0. If running tests for the first time on your chosen browser/OS combination, run:
0 commit comments