Skip to content

Commit 28edbea

Browse files
Add comprehensive test scripts for registration features
1 parent 5e11a56 commit 28edbea

17 files changed

Lines changed: 1383 additions & 90 deletions

.gitignore

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.*
7-
.yarn/*
8-
!.yarn/patches
9-
!.yarn/plugins
10-
!.yarn/releases
11-
!.yarn/versions
12-
13-
# testing
14-
/coverage
15-
16-
# next.js
17-
/.next/
18-
/out/
19-
20-
# production
21-
/build
22-
23-
# misc
24-
.DS_Store
25-
*.pem
26-
27-
# debug
28-
npm-debug.log*
29-
yarn-debug.log*
30-
yarn-error.log*
31-
.pnpm-debug.log*
32-
33-
# env files (can opt-in for committing if needed)
34-
.env*
35-
36-
# vercel
37-
.vercel
38-
39-
# typescript
40-
*.tsbuildinfo
41-
next-env.d.ts
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
35+
# vercel
36+
.vercel
37+
38+
# typescript
39+
*.tsbuildinfo
40+
next-env.d.ts
41+
config.bat

scripts/test-batch-extraction.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
* Test script to verify batch selection extraction
3+
* Tests that conversational inputs like "my batch is 23" extract "23"
4+
*/
5+
6+
console.log('🧪 Testing Batch Selection Extraction\n');
7+
console.log('━'.repeat(80));
8+
9+
// Batch extraction phrases
10+
const BATCH_PHRASES = [
11+
'my batch is', 'our batch is', 'batch is', 'the batch is',
12+
'we are batch', 'we are from batch', 'i am from batch', 'i am in batch',
13+
'our batch', 'my batch', 'batch', 'we are in batch', 'from batch'
14+
];
15+
16+
// Extraction function
17+
function extractFromConversational(input: string, phrases: string[]): string {
18+
let result = input.trim();
19+
const lowerInput = result.toLowerCase();
20+
21+
for (const phrase of phrases) {
22+
if (lowerInput.includes(phrase)) {
23+
const phraseIndex = lowerInput.indexOf(phrase);
24+
const afterPhrase = result.substring(phraseIndex + phrase.length).trim();
25+
26+
if (afterPhrase.length >= 1) {
27+
result = afterPhrase;
28+
console.log(` 🔍 Detected phrase "${phrase}" → Extracting...`);
29+
break;
30+
}
31+
}
32+
}
33+
34+
return result;
35+
}
36+
37+
// Batch validator (must be "23" or "24")
38+
function validateBatch(batch: string): boolean {
39+
return /^(23|24)$/.test(batch);
40+
}
41+
42+
// Test cases for batch extraction
43+
const testCases = [
44+
// Conversational inputs with "is"
45+
{ input: 'my batch is 23', expected: '23', description: 'Conversational: "my batch is 23"' },
46+
{ input: 'our batch is 24', expected: '24', description: 'Conversational: "our batch is 24"' },
47+
{ input: 'batch is 23', expected: '23', description: 'Conversational: "batch is 23"' },
48+
{ input: 'the batch is 24', expected: '24', description: 'Conversational: "the batch is 24"' },
49+
50+
// Conversational inputs without "is"
51+
{ input: 'our batch 23', expected: '23', description: 'Short: "our batch 23"' },
52+
{ input: 'my batch 24', expected: '24', description: 'Short: "my batch 24"' },
53+
54+
// "We are" patterns
55+
{ input: 'we are batch 23', expected: '23', description: 'We are: "we are batch 23"' },
56+
{ input: 'we are from batch 24', expected: '24', description: 'We are from: "we are from batch 24"' },
57+
{ input: 'we are in batch 23', expected: '23', description: 'We are in: "we are in batch 23"' },
58+
59+
// "I am" patterns
60+
{ input: 'i am from batch 24', expected: '24', description: 'I am from: "i am from batch 24"' },
61+
{ input: 'i am in batch 23', expected: '23', description: 'I am in: "i am in batch 23"' },
62+
63+
// "from batch" pattern
64+
{ input: 'from batch 24', expected: '24', description: 'From batch: "from batch 24"' },
65+
66+
// Direct input (no extraction needed)
67+
{ input: '23', expected: '23', description: 'Direct: "23"' },
68+
{ input: '24', expected: '24', description: 'Direct: "24"' },
69+
70+
// Edge cases with capitalization
71+
{ input: 'My Batch Is 23', expected: '23', description: 'Capitalized: "My Batch Is 23"' },
72+
{ input: 'OUR BATCH IS 24', expected: '24', description: 'Uppercase: "OUR BATCH IS 24"' },
73+
];
74+
75+
console.log('\n📝 Running Test Cases:\n');
76+
77+
let passed = 0;
78+
let failed = 0;
79+
80+
testCases.forEach((testCase, index) => {
81+
const extracted = extractFromConversational(testCase.input, BATCH_PHRASES);
82+
const result = extracted.trim();
83+
const isValid = validateBatch(result);
84+
const testPassed = result === testCase.expected && isValid;
85+
86+
if (testPassed) {
87+
console.log(`✅ Test ${index + 1}: PASS`);
88+
console.log(` Description: ${testCase.description}`);
89+
console.log(` Input: "${testCase.input}"`);
90+
console.log(` Expected: "${testCase.expected}" | Got: "${result}" | Valid: ${isValid}\n`);
91+
passed++;
92+
} else {
93+
console.log(`❌ Test ${index + 1}: FAIL`);
94+
console.log(` Description: ${testCase.description}`);
95+
console.log(` Input: "${testCase.input}"`);
96+
console.log(` Expected: "${testCase.expected}" | Got: "${result}" | Valid: ${isValid}\n`);
97+
failed++;
98+
}
99+
});
100+
101+
console.log('━'.repeat(80));
102+
console.log(`\n📊 Results: ${passed}/${testCases.length} passed`);
103+
console.log(` ✅ Passed: ${passed}`);
104+
console.log(` ❌ Failed: ${failed}`);
105+
console.log(` Success Rate: ${Math.round((passed / testCases.length) * 100)}%\n`);
106+
107+
if (failed === 0) {
108+
console.log('🎉 All tests passed! Batch extraction working perfectly!\n');
109+
process.exit(0);
110+
} else {
111+
console.log('⚠️ Some tests failed. Please review the implementation.\n');
112+
process.exit(1);
113+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Test script to verify conversational phrase detection
3+
* Tests that phrases like "my name is aditha" are rejected as team names
4+
*/
5+
6+
console.log('🧪 Testing Conversational Phrase Detection\n');
7+
console.log('━'.repeat(70));
8+
9+
// Test cases
10+
const testCases = [
11+
// Conversational phrases (should be rejected)
12+
{ input: 'my name is aditha', expected: 'REJECT', reason: 'Contains "my name is"' },
13+
{ input: 'i am john', expected: 'REJECT', reason: 'Contains "i am"' },
14+
{ input: 'this is our team', expected: 'REJECT', reason: 'Contains "this is"' },
15+
{ input: 'my team is phoenix', expected: 'REJECT', reason: 'Contains "my team is"' },
16+
{ input: 'we are the warriors', expected: 'REJECT', reason: 'Contains "we are"' },
17+
{ input: 'our name is team alpha', expected: 'REJECT', reason: 'Contains "our name is"' },
18+
{ input: 'our team name is bulk', expected: 'REJECT', reason: 'Contains "our team name is"' },
19+
{ input: 'my team name is phoenix', expected: 'REJECT', reason: 'Contains "my team name is"' },
20+
{ input: 'the team name is warriors', expected: 'REJECT', reason: 'Contains "the team name is"' },
21+
{ input: 'team name is alpha', expected: 'REJECT', reason: 'Contains "team name is"' },
22+
{ input: 'hello i am sarah', expected: 'REJECT', reason: 'Contains "hello i am"' },
23+
{ input: 'hi i am david', expected: 'REJECT', reason: 'Contains "hi i am"' },
24+
{ input: "i'm michael", expected: 'REJECT', reason: 'Contains "i\'m"' },
25+
26+
// Valid team names (should be accepted)
27+
{ input: 'Phoenix', expected: 'ACCEPT', reason: 'Valid short name' },
28+
{ input: 'Team Alpha', expected: 'ACCEPT', reason: 'Valid team name' },
29+
{ input: 'Code Warriors', expected: 'ACCEPT', reason: 'Valid team name' },
30+
{ input: 'Rush2025', expected: 'ACCEPT', reason: 'Valid name with numbers' },
31+
{ input: 'The_Innovators', expected: 'ACCEPT', reason: 'Valid with underscore' },
32+
{ input: 'Team-42', expected: 'ACCEPT', reason: 'Valid with hyphen' },
33+
{ input: 'CodeRush Champions', expected: 'ACCEPT', reason: 'Valid longer name' },
34+
{ input: 'Binary Beasts', expected: 'ACCEPT', reason: 'Valid team name' },
35+
];
36+
37+
console.log('\n📝 Test Cases:\n');
38+
39+
let passed = 0;
40+
let failed = 0;
41+
42+
testCases.forEach((testCase, index) => {
43+
const lowerInput = testCase.input.toLowerCase();
44+
45+
// Check for conversational phrases
46+
const conversationalPhrases = [
47+
'my name is', 'i am', 'this is', 'my team is', 'we are',
48+
'our name is', 'our team is', 'our team name is', 'my team name is',
49+
'the team name is', 'team name is', 'hello i am', 'hi i am', "i'm"
50+
];
51+
52+
const containsConversationalPhrase = conversationalPhrases.some(phrase =>
53+
lowerInput.includes(phrase)
54+
);
55+
56+
const actualResult = containsConversationalPhrase ? 'REJECT' : 'ACCEPT';
57+
const testPassed = actualResult === testCase.expected;
58+
59+
if (testPassed) {
60+
console.log(`✅ Test ${index + 1}: PASS`);
61+
console.log(` Input: "${testCase.input}"`);
62+
console.log(` Expected: ${testCase.expected} | Actual: ${actualResult}`);
63+
console.log(` Reason: ${testCase.reason}\n`);
64+
passed++;
65+
} else {
66+
console.log(`❌ Test ${index + 1}: FAIL`);
67+
console.log(` Input: "${testCase.input}"`);
68+
console.log(` Expected: ${testCase.expected} | Actual: ${actualResult}`);
69+
console.log(` Reason: ${testCase.reason}\n`);
70+
failed++;
71+
}
72+
});
73+
74+
console.log('━'.repeat(70));
75+
console.log(`\n📊 Results: ${passed}/${testCases.length} passed`);
76+
console.log(` ✅ Passed: ${passed}`);
77+
console.log(` ❌ Failed: ${failed}`);
78+
console.log(` Success Rate: ${Math.round((passed / testCases.length) * 100)}%\n`);
79+
80+
if (failed === 0) {
81+
console.log('🎉 All tests passed! Conversational phrase detection is working correctly.\n');
82+
process.exit(0);
83+
} else {
84+
console.log('⚠️ Some tests failed. Please review the implementation.\n');
85+
process.exit(1);
86+
}

0 commit comments

Comments
 (0)