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
-`test_clone_backend_validation_error`: Error message validation when cloning form is invalid
9
10
10
11
### Critical Insights
11
12
**Clone Ordering**: `_clone_ordering` = ordering value to insert *before*. After save, existing content gets renormalized but cloned content keeps its target ordering value. This is correct behavior.
@@ -14,6 +15,59 @@
14
15
15
16
**Region Targeting**: Use `[data-region="sidebar"] .order-machine-insert-target` for region-specific insert targets.
16
17
18
+
## Test Writing Guidelines
19
+
20
+
### Be Strict - No Fallbacks
21
+
-**Always test the exact expected behavior** - don't use fallback logic that would mask failing code
22
+
-**Verify specific error messages** - check for exact text, field names, and validation details
23
+
-**Assert on precise conditions** - avoid "if this doesn't work, try that" patterns
24
+
-**Let tests fail when code is broken** - fallbacks hide bugs and prevent proper debugging
25
+
-**Test database state directly** - verify exact counts, field values, and relationships
26
+
-**Use specific selectors** - don't fall back to generic ones that might match wrong elements
27
+
-**Validate full user experience** - error messages must be visible to actual users
28
+
29
+
### Common Anti-Patterns to Avoid
30
+
-`assert True` after conditional checks (masks real failures)
31
+
-`try/except` blocks that suppress assertion errors
32
+
- Generic error message checks instead of specific validation
33
+
- Counting "at least N" instead of "exactly N" when exact is expected
34
+
- Checking "something worked" instead of "the right thing worked correctly"
35
+
36
+
Example of **BAD** test pattern:
37
+
```python
38
+
# DON'T DO THIS - fallbacks hide real issues
39
+
if"expected error"in messages:
40
+
assertTrue# Found expected error
41
+
else:
42
+
# Fallback that masks the real problem
43
+
if any_error_messages:
44
+
assertTrue# "At least some error occurred"
45
+
46
+
# DON'T DO THIS - vague assertions
47
+
assertlen(items) >=2# Could be wrong number
48
+
try:
49
+
some_assertion()
50
+
exceptAssertionError:
51
+
pass# Ignoring failures
52
+
```
53
+
54
+
Example of **GOOD** test pattern:
55
+
```python
56
+
# DO THIS - strict assertions reveal real issues
57
+
assert"Cloning plugins failed"in error_message, f"Expected error not found: {error_message}"
58
+
assert"This field is required"in error_message, f"Field validation missing: {error_message}"
0 commit comments