@@ -216,12 +216,37 @@ A combination for testing HTML structure and content.
216
216
217
217
## Implementation Steps
218
218
219
- 1 . Set up testing environment:
219
+ 1 . Add testing dependencies to requirements file ` requirements/local.txt ` :
220
+ ``` text
221
+ # Testing Dependencies
222
+ selenium>=4.15.2
223
+ pytest-xdist>=3.3.1
224
+ pytest-cov>=4.1.0
225
+ ```
226
+
227
+ 2 . Update Dockerfile ` compose/local/django/Dockerfile ` to install Chrome and ChromeDriver:
228
+ ``` dockerfile
229
+ # Install Chrome and ChromeDriver for Selenium tests
230
+ RUN apt-get update && apt-get install -y \
231
+ chromium \
232
+ chromium-driver \
233
+ && rm -rf /var/lib/apt/lists/*
234
+ ```
235
+
236
+ 3 . Rebuild Docker container to apply changes:
220
237
``` bash
221
- pip install selenium pytest pytest- django
238
+ docker-compose -f local.yml build django
222
239
```
223
240
224
- 2 . Create base test classes:
241
+ 4 . Create test directory structure:
242
+ ``` bash
243
+ mkdir -p tests/frontend
244
+ touch tests/frontend/__init__.py
245
+ touch tests/frontend/base.py
246
+ touch tests/frontend/test_setup.py
247
+ ```
248
+
249
+ 5 . Create base test classes:
225
250
``` python
226
251
import pytest
227
252
from selenium import webdriver
@@ -238,7 +263,7 @@ class BaseUITest:
238
263
pass
239
264
```
240
265
241
- 3 . Organize tests by feature:
266
+ 6 . Organize tests by feature:
242
267
``` python
243
268
class TestCollectionManagement (BaseUITest ):
244
269
def test_create_collection (self ):
@@ -250,4 +275,9 @@ class TestCollectionManagement(BaseUITest):
250
275
class TestURLPatterns (BaseUITest ):
251
276
def test_add_include_pattern (self ):
252
277
pass
253
- ```
278
+ ```
279
+
280
+ 7 . Run tests:
281
+ ``` bash
282
+ docker-compose -f local.yml run --rm django pytest tests/frontend/test_setup.py -v
283
+ ```
0 commit comments