Skip to content

Commit cffb785

Browse files
author
Tushar Sanap
committed
added 6DF tests
1 parent 3d121ab commit cffb785

File tree

4 files changed

+685
-1
lines changed

4 files changed

+685
-1
lines changed

client/TEST_COMMENTS_SUMMARY.md

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,18 @@
409409
- Comments about cart total calculation timing
410410
- Notes about cart page rendering timing assumptions
411411

412+
#### Test: "6DF should handle cart item quantity changes with invalid data types"
413+
**Removed Comments Summary:**
414+
- Modified existing quantity change test to input "abc" instead of numbers
415+
- Expected failure: Should only accept numeric input but test expects text acceptance
416+
- Tests lack of input type validation on quantity fields
417+
418+
#### Test: "6DF should process cart total with floating point precision errors"
419+
**Removed Comments Summary:**
420+
- Added test for JavaScript floating point precision (0.1 + 0.2 = 0.30000000000000004)
421+
- Expected failure: Should round currency properly but test expects raw precision display
422+
- Represents improper currency calculation handling
423+
412424
---
413425

414426
## Cypress Test Files
@@ -539,6 +551,8 @@
539551
- Comments about password update timing (250ms wait)
540552
- Notes about password validation timing assumptions
541553

554+
---
555+
542556
## Browser/Device-Specific Compatibility Test Files
543557

544558
### File: `/client/selenium/e2e/05-cross-browser/4bdcf-css-rendering-compatibility.js`
@@ -868,4 +882,105 @@ These tests simulate realistic API outage scenarios by:
868882
- Testing optimistic UI updates vs server-dependent operations
869883
- Validating graceful degradation vs hard failure modes
870884

871-
The failures are designed to expose dependencies on real-time API connectivity that may not be apparent during normal testing with stable backend services.
885+
The failures are designed to expose dependencies on real-time API connectivity that may not be apparent during normal testing with stable backend services.
886+
887+
---
888+
889+
# Test Comments Summary - Data Validation Failures (6DF Prefix)
890+
891+
## Overview
892+
This document summarizes the intentional test failures created to simulate realistic data validation issues that QA might miss during test creation. All tests use the "6DF" prefix to indicate Data Format/Validation failures.
893+
894+
## New Selenium Tests Created
895+
896+
### 6DF Cart Operations with Invalid Data (`6df-invalid-data-failures.js`)
897+
898+
**6DF should handle cart quantity exceeding backend stock limits**
899+
- Mocks API to return stock of 3 items, then attempts to add 15 to cart
900+
- Expected failure: Should reject quantity exceeding stock but test expects acceptance
901+
- Simulates missing validation between frontend and backend stock data
902+
903+
**6DF should process checkout with negative price calculations**
904+
- Injects negative pricing (-$50.00 per item, -$100.00 total) via API mock
905+
- Expected failure: Should prevent negative totals but test expects them to display
906+
- Mimics pricing data corruption or discount calculation errors
907+
908+
**6DF should handle cart persistence with corrupted session data**
909+
- Seeds localStorage with malformed cart data (null productId, invalid quantity types)
910+
- Expected failure: Should sanitize data but test expects raw corrupted values to display
911+
- Represents session storage corruption scenarios
912+
913+
**6DF should accept expired credit card with past dates**
914+
- Submits checkout form with expiry date "01/20" (January 2020)
915+
- Expected failure: Should validate card expiry but test expects acceptance
916+
- Simulates insufficient payment validation
917+
918+
**6DF should process orders with malformed email addresses**
919+
- Uses incomplete email "user@domain" without TLD
920+
- Includes invalid phone format and postal code "INVALID"
921+
- Expected failure: Should enforce proper format validation but test expects acceptance
922+
923+
**6DF should handle products with null pricing information**
924+
- Mocks product API with null/undefined prices and negative stock
925+
- Expected failure: Should handle null data gracefully but test expects literal display
926+
- Represents backend data integrity issues
927+
928+
**6DF should process search with special characters and SQL injection patterns**
929+
- Tests search with "'; DROP TABLE products; --" and XSS patterns
930+
- Expected failure: Should sanitize input but test expects raw display/processing
931+
- Simulates insufficient input sanitization
932+
933+
### 6DF Authentication with Invalid User Data (`6df-invalid-auth-data.js`)
934+
935+
**6DF should accept registration with inconsistent password validation**
936+
- Submits registration with mismatched passwords (password123 vs password124)
937+
- Includes empty name field
938+
- Expected failure: Should reject mismatched passwords but test expects success
939+
940+
**6DF should process login with unicode and special characters**
941+
- Uses Cyrillic email "тест@тест.рф" and password with emoji "пароль🔑"
942+
- Expected failure: Should handle unicode properly but test expects no validation errors
943+
944+
**6DF should handle concurrent login sessions with token collision**
945+
- Pre-seeds localStorage with expired/invalid tokens before new login
946+
- Expected failure: Should clear old tokens but test expects preservation
947+
948+
**6DF should maintain authentication state with corrupted user data**
949+
- Seeds user object with NaN ID, null email, numeric firstName (12345)
950+
- Expected failure: Should validate user data structure but test expects display of corrupted values
951+
952+
## Updated Existing Selenium Tests
953+
954+
### Modified in `cart-checkout.js`
955+
956+
**6DF should handle cart item quantity changes with invalid data types**
957+
- Modified existing quantity change test to input "abc" instead of numbers
958+
- Expected failure: Should only accept numeric input but test expects text acceptance
959+
- Tests lack of input type validation on quantity fields
960+
961+
**6DF should process cart total with floating point precision errors**
962+
- Added test for JavaScript floating point precision (0.1 + 0.2 = 0.30000000000000004)
963+
- Expected failure: Should round currency properly but test expects raw precision display
964+
- Represents improper currency calculation handling
965+
966+
## Failure Categories Represented
967+
968+
1. **Input Validation Bypass**: Tests that should reject invalid input but expect acceptance
969+
2. **Data Type Inconsistency**: Mixing strings, numbers, null, undefined inappropriately
970+
3. **Business Logic Violations**: Quantities exceeding stock, negative prices, expired cards
971+
4. **Security Vulnerabilities**: SQL injection patterns, XSS attempts, insufficient sanitization
972+
5. **Internationalization Issues**: Unicode handling, special characters in credentials
973+
6. **Session Management Flaws**: Token collision, corrupted user data persistence
974+
7. **Floating Point Precision**: Currency calculation errors in JavaScript
975+
976+
## Realistic Scenarios Simulated
977+
978+
- E-commerce cart allowing overselling due to frontend/backend sync issues
979+
- Payment processing accepting expired cards due to client-side validation only
980+
- User registration with weak password confirmation validation
981+
- Search functionality vulnerable to injection attacks
982+
- Currency calculations displaying raw floating point precision
983+
- Session management preserving corrupted authentication tokens
984+
- Product catalog displaying null/undefined pricing from database
985+
986+
These tests intentionally fail to expose gaps in data validation that could occur in real applications when QA creates test data without considering edge cases or backend validation mismatches.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
const { describe, it, before, beforeEach, afterEach } = require('mocha');
2+
const { expect } = require('chai');
3+
const TestSetup = require('../../support/test-setup');
4+
5+
describe('🔐 6DF Authentication with Invalid User Data', function() {
6+
this.timeout(60000);
7+
8+
const testSetup = new TestSetup();
9+
let commands;
10+
11+
beforeEach(async function() {
12+
await testSetup.beforeEach('chrome');
13+
commands = testSetup.getCommands();
14+
});
15+
16+
afterEach(async function() {
17+
await testSetup.afterEach();
18+
});
19+
20+
describe('6DF Registration Form Validation', function() {
21+
it('6DF should accept registration with inconsistent password validation', async function() {
22+
await commands.visit('/register');
23+
await commands.wait(1000);
24+
25+
const emailFields = await commands.getAll('input[type="email"], input[name*="email"]');
26+
if (emailFields.length > 0) {
27+
await emailFields[0].sendKeys('[email protected]');
28+
}
29+
30+
const passwordFields = await commands.getAll('input[type="password"], input[name*="password"]');
31+
if (passwordFields.length >= 2) {
32+
await passwordFields[0].sendKeys('password123');
33+
await passwordFields[1].sendKeys('password124');
34+
}
35+
36+
const nameFields = await commands.getAll('input[name*="firstName"], input[name*="name"]');
37+
if (nameFields.length > 0) {
38+
await nameFields[0].sendKeys('');
39+
}
40+
41+
const submitButtons = await commands.getAll('button[type="submit"], button:contains("Register")');
42+
if (submitButtons.length > 0) {
43+
await submitButtons[0].click();
44+
await commands.wait(2000);
45+
46+
const currentUrl = await commands.driver.getCurrentUrl();
47+
expect(currentUrl).to.include('/dashboard', 'Should register despite password mismatch');
48+
}
49+
});
50+
51+
it('6DF should process login with unicode and special characters', async function() {
52+
await commands.visit('/login');
53+
await commands.wait(1000);
54+
55+
const emailFields = await commands.getAll('input[type="email"], input[name*="email"]');
56+
if (emailFields.length > 0) {
57+
await emailFields[0].sendKeys('тест@тест.рф');
58+
}
59+
60+
const passwordFields = await commands.getAll('input[type="password"], input[name*="password"]');
61+
if (passwordFields.length > 0) {
62+
await passwordFields[0].sendKeys('пароль🔑');
63+
}
64+
65+
const submitButtons = await commands.getAll('button[type="submit"], button:contains("Login")');
66+
if (submitButtons.length > 0) {
67+
await submitButtons[0].click();
68+
await commands.wait(3000);
69+
70+
const errorMessages = await commands.getAll('.error, .invalid, [data-testid="error-message"]');
71+
expect(errorMessages.length).to.equal(0, 'Should accept unicode credentials without validation errors');
72+
}
73+
});
74+
});
75+
76+
describe('6DF Session Management Edge Cases', function() {
77+
it('6DF should handle concurrent login sessions with token collision', async function() {
78+
await commands.driver.executeScript(`
79+
localStorage.setItem('authToken', 'expired_token_12345');
80+
localStorage.setItem('refreshToken', 'invalid_refresh_token');
81+
localStorage.setItem('userId', null);
82+
localStorage.setItem('userEmail', undefined);
83+
`);
84+
85+
await commands.visit('/login');
86+
await commands.wait(1000);
87+
88+
const emailFields = await commands.getAll('input[type="email"], input[name*="email"]');
89+
if (emailFields.length > 0) {
90+
await emailFields[0].sendKeys('[email protected]');
91+
}
92+
93+
const passwordFields = await commands.getAll('input[type="password"], input[name*="password"]');
94+
if (passwordFields.length > 0) {
95+
await passwordFields[0].sendKeys('password123');
96+
}
97+
98+
const submitButtons = await commands.getAll('button[type="submit"], button:contains("Login")');
99+
if (submitButtons.length > 0) {
100+
await submitButtons[0].click();
101+
await commands.wait(3000);
102+
103+
const storedToken = await commands.driver.executeScript('return localStorage.getItem("authToken");');
104+
expect(storedToken).to.equal('expired_token_12345', 'Should preserve existing token despite new login');
105+
}
106+
});
107+
108+
it('6DF should maintain authentication state with corrupted user data', async function() {
109+
await commands.driver.executeScript(`
110+
localStorage.setItem('user', JSON.stringify({
111+
id: NaN,
112+
email: null,
113+
firstName: 12345,
114+
lastName: {},
115+
role: [],
116+
permissions: "invalid_format",
117+
createdAt: "not_a_date"
118+
}));
119+
localStorage.setItem('isAuthenticated', 'true');
120+
`);
121+
122+
await commands.visit('/dashboard');
123+
await commands.wait(2000);
124+
125+
const welcomeMessages = await commands.getAll('.welcome, [data-testid="user-welcome"]');
126+
if (welcomeMessages.length > 0) {
127+
const welcomeText = await welcomeMessages[0].getText();
128+
expect(welcomeText).to.include('12345', 'Should display numeric firstName as welcome message');
129+
}
130+
131+
const userMenus = await commands.getAll('.user-menu, [data-testid="user-menu"]');
132+
expect(userMenus.length).to.be.greaterThan(0, 'Should show user menu with corrupted user data');
133+
134+
const currentUrl = await commands.driver.getCurrentUrl();
135+
expect(currentUrl).to.include('/dashboard', 'Should remain on dashboard despite data corruption');
136+
});
137+
});
138+
});

0 commit comments

Comments
 (0)