Test Cases
Comprehensive test cases for the Next.js Authentication Template. Use this document to verify all features and functionality.
Authentication Flows
Login
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-AUTH-001 | Login with valid credentials | 1. Navigate to /login 2. Enter valid email and password 3. Click Sign In | User is redirected to /dashboard, session is created | |
| TC-AUTH-002 | Login with invalid email format | 1. Navigate to /login 2. Enter invalid email format 3. Click Sign In | Validation error message displayed, form not submitted | |
| TC-AUTH-003 | Login with invalid password | 1. Navigate to /login 2. Enter valid email, invalid password 3. Click Sign In | Error message: "Invalid email or password" | |
| TC-AUTH-004 | Login with empty fields | 1. Navigate to /login 2. Leave fields empty 3. Click Sign In | Validation errors for required fields displayed | |
| TC-AUTH-005 | Loading state during login | 1. Navigate to /login 2. Enter credentials 3. Click Sign In | Button shows "Signing in..." and is disabled during request |
Register
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-REG-001 | Register with valid data | 1. Navigate to /register 2. Enter name, email, password, confirm password 3. Click Create Account | Account created, success message shown, redirect to dashboard | |
| TC-REG-002 | Register with existing email | 1. Navigate to /register 2. Enter email that already exists 3. Submit form | Error message: "This email is already registered" | |
| TC-REG-003 | Password mismatch | 1. Navigate to /register 2. Enter different passwords in password and confirm fields 3. Submit form | Validation error: "Passwords do not match" | |
| TC-REG-004 | Weak password validation | 1. Navigate to /register 2. Enter password without uppercase/number 3. Submit form | Validation error: "Password must contain at least one uppercase letter and one number" | |
| TC-REG-005 | Required field validation | 1. Navigate to /register 2. Leave one or more fields empty 3. Submit form | Validation errors for empty required fields displayed |
Forgot Password
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-FP-001 | Request password reset with valid email | 1. Navigate to /forgot-password 2. Enter registered email 3. Click Send Reset Link | Success message displayed, email sent (if account exists) | |
| TC-FP-002 | Request with invalid email format | 1. Navigate to /forgot-password 2. Enter invalid email format 3. Submit form | Validation error: "Please enter a valid email address" | |
| TC-FP-003 | Request with non-existent email | 1. Navigate to /forgot-password 2. Enter email that doesn't exist 3. Submit form | Same success message (security: don't reveal if email exists) |
Reset Password
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-RP-001 | Reset password with valid token | 1. Click reset link from email 2. Enter new password and confirm 3. Submit form | Password reset successfully, redirect to login | |
| TC-RP-002 | Reset with expired token | 1. Use expired reset token 2. Try to reset password | Error message: "Invalid or expired reset link" | |
| TC-RP-003 | Password mismatch in reset | 1. Click reset link 2. Enter different passwords 3. Submit form | Validation error: "Passwords do not match" |
OTP Verification
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-OTP-001 | Verify with correct OTP | 1. Navigate to /otp 2. Enter 6-digit code from email 3. Click Verify | Verification successful, redirect to dashboard | |
| TC-OTP-002 | Verify with incorrect OTP | 1. Navigate to /otp 2. Enter wrong 6-digit code 3. Click Verify | Error message displayed, verification fails | |
| TC-OTP-003 | OTP countdown timer | 1. Navigate to /otp 2. Observe resend button | Resend button disabled, shows countdown (60s), then enables | |
| TC-OTP-004 | Resend OTP code | 1. Navigate to /otp 2. Wait for countdown 3. Click Resend code | New OTP sent, countdown resets to 60s | |
| TC-OTP-005 | Invalid OTP length | 1. Navigate to /otp 2. Enter less than 6 digits 3. Try to submit | Validation error: "Code must be 6 digits" |
Social Login
Google Login
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-SOC-001 | Login with Google (new user) | 1. Navigate to /login 2. Click "Continue with Google" 3. Complete Google OAuth flow | Account created, user logged in, redirected to dashboard | |
| TC-SOC-002 | Login with Google (existing user) | 1. Navigate to /login 2. Click "Continue with Google" 3. Use existing Google account | User logged in, redirected to dashboard | |
| TC-SOC-003 | Cancel Google OAuth | 1. Navigate to /login 2. Click "Continue with Google" 3. Cancel OAuth flow | User remains on login page, no error |
Facebook Login
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-SOC-004 | Login with Facebook | 1. Navigate to /login 2. Click "Continue with Facebook" 3. Complete Facebook OAuth flow | User logged in, redirected to dashboard |
Instagram Login
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-SOC-005 | Login with Instagram | 1. Navigate to /login 2. Click "Continue with Instagram" 3. Complete Instagram OAuth flow | User logged in, redirected to dashboard |
LINE Login
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-SOC-006 | Login with LINE | 1. Navigate to /login 2. Click "Continue with LINE" 3. Complete LINE OAuth flow | User logged in, redirected to dashboard |
Protected Routes
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-PROT-001 | Access dashboard when authenticated | 1. Login successfully 2. Navigate to /dashboard | Dashboard page loads, user info displayed | |
| TC-PROT-002 | Access dashboard when not authenticated | 1. Logout or clear session 2. Navigate to /dashboard | Redirected to /login page | |
| TC-PROT-003 | Access auth pages when authenticated | 1. Login successfully 2. Navigate to /login or /register | Redirected to /dashboard |
Logout
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-LOGOUT-001 | Logout successfully | 1. Login to account 2. Click Logout button 3. Confirm logout | Session cleared, redirected to login page | |
| TC-LOGOUT-002 | Logout loading state | 1. Login to account 2. Click Logout button | Button shows "Signing out..." and is disabled during logout |
Internationalization (i18n)
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-I18N-001 | Switch to English | 1. Navigate to any page 2. Switch language to English | All text displays in English, URL updates to /en | |
| TC-I18N-002 | Switch to Japanese | 1. Navigate to any page 2. Switch language to Japanese | All text displays in Japanese, URL updates to /ja | |
| TC-I18N-003 | Language persistence | 1. Switch language 2. Navigate to different pages 3. Refresh page | Selected language persists across navigation and page refresh |
UI/UX
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-UI-001 | Responsive design - Mobile | 1. Open app on mobile device 2. Navigate through pages | All pages display correctly, forms are usable, buttons accessible | |
| TC-UI-002 | Responsive design - Tablet | 1. Open app on tablet device 2. Navigate through pages | All pages display correctly, layout adapts to tablet size | |
| TC-UI-003 | Dark mode toggle | 1. Navigate to any page 2. Toggle dark mode | Theme switches between light and dark, preference persists | |
| TC-UI-004 | Form validation messages | 1. Navigate to any form 2. Submit with invalid data | Clear, helpful error messages displayed below each field | |
| TC-UI-005 | Loading states | 1. Perform any action (login, register, etc.) 2. Observe loading state | Buttons show loading text, disabled during request, no double submission |
Form Validation & Regex
Email Validation
| Test ID | Test Case | Regex | Expected Result | Status |
|---|---|---|---|---|
| TC-VAL-001 | Valid email format | /^[^\s@]+@[^\s@]+\.[^\s@]+$/ | Email accepted, no validation error | |
| TC-VAL-002 | Email without @ symbol | /^[^\s@]+@[^\s@]+\.[^\s@]+$/userexample.com | Validation error: "Email không hợp lệ" | |
| TC-VAL-003 | Email without domain | /^[^\s@]+@[^\s@]+\.[^\s@]+$/user@ | Validation error: "Email không hợp lệ" | |
| TC-VAL-004 | Email without TLD | /^[^\s@]+@[^\s@]+\.[^\s@]+$/user@example | Validation error: "Email không hợp lệ" | |
| TC-VAL-005 | Empty email field | Required field | Validation error displayed for required field |
Password Validation (Regex)
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-VAL-006 | Valid password (all requirements) | 1. Navigate to /register or /reset-password 2. Enter password: Password123 3. Submit form | Password accepted, no validation error | |
| TC-VAL-007 | Password without uppercase (regex: /[A-Z]/) | 1. Navigate to /register 2. Enter password: password123 3. Submit form | Validation error: "Cần ít nhất 1 chữ hoa" | |
| TC-VAL-008 | Password without lowercase (regex: /[a-z]/) | 1. Navigate to /register 2. Enter password: PASSWORD123 3. Submit form | Validation error: "Cần ít nhất 1 chữ thường" | |
| TC-VAL-009 | Password without number (regex: /[0-9]/) | 1. Navigate to /register 2. Enter password: Password 3. Submit form | Validation error: "Cần ít nhất 1 số" | |
| TC-VAL-010 | Password less than 8 characters | 1. Navigate to /register 2. Enter password: Pass123 3. Submit form | Validation error: "Mật khẩu tối thiểu 8 ký tự" | |
| TC-VAL-011 | Password with only uppercase | 1. Navigate to /register 2. Enter password: PASSWORD123 3. Submit form | Validation error: "Cần ít nhất 1 chữ thường" | |
| TC-VAL-012 | Password with only lowercase | 1. Navigate to /register 2. Enter password: password123 3. Submit form | Validation error: "Cần ít nhất 1 chữ hoa" | |
| TC-VAL-013 | Password with only numbers | 1. Navigate to /register 2. Enter password: 12345678 3. Submit form | Validation error: "Cần ít nhất 1 chữ hoa" and "Cần ít nhất 1 chữ thường" | |
| TC-VAL-014 | Empty password field | 1. Navigate to /register 2. Leave password field empty 3. Submit form | Validation error: "Mật khẩu tối thiểu 8 ký tự" |
Name Validation
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-VAL-015 | Valid name (2+ characters) | 1. Navigate to /register 2. Enter name: John Doe 3. Submit form | Name accepted, no validation error | |
| TC-VAL-016 | Name less than 2 characters | 1. Navigate to /register 2. Enter name: J 3. Submit form | Validation error: "Tên tối thiểu 2 ký tự" | |
| TC-VAL-017 | Empty name field | 1. Navigate to /register 2. Leave name field empty 3. Submit form | Validation error: "Tên tối thiểu 2 ký tự" |
Error Handling
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-ERR-001 | Network error handling | 1. Disable network 2. Try to login or register | Error message: "Network error. Please try again." | |
| TC-ERR-002 | Server error handling | 1. Simulate server error (500) 2. Try to perform action | Error message: "An error occurred. Please try again." | |
| TC-ERR-003 | Timeout handling | 1. Simulate slow network 2. Wait for timeout | Appropriate timeout error message displayed |
Search
| Test ID | Test Case | Steps | Expected Result | Status |
|---|---|---|---|---|
| TC-SEARCH-001 | Open search with button | 1. Navigate to any docs page 2. Click search icon in header | Search input opens, auto-focused, placeholder shows "Search documentation..." | |
| TC-SEARCH-002 | Open search with keyboard shortcut | 1. Navigate to any docs page 2. Press Cmd+K (Mac) or Ctrl+K (Windows/Linux) | Search input opens, auto-focused | |
| TC-SEARCH-003 | Search with valid query | 1. Open search 2. Type "login" (2+ characters) 3. Observe results | Dropdown shows matching results with title and section, results are clickable | |
| TC-SEARCH-004 | Search with no results | 1. Open search 2. Type "xyz123nonexistent" 3. Observe results | Shows "No results found for..." message | |
| TC-SEARCH-005 | Search with less than 2 characters | 1. Open search 2. Type "l" (1 character) | No results dropdown shown (minMatchCharLength: 2) | |
| TC-SEARCH-006 | Keyboard navigation - Arrow Down | 1. Open search 2. Type query with results 3. Press Arrow Down key | Selected result moves down, highlighted, scrolls into view if needed | |
| TC-SEARCH-007 | Keyboard navigation - Arrow Up | 1. Open search 2. Type query with results 3. Press Arrow Up key | Selected result moves up, highlighted, scrolls into view if needed | |
| TC-SEARCH-008 | Keyboard navigation - Enter | 1. Open search 2. Type query with results 3. Navigate to a result 4. Press Enter | Navigates to selected result page, search closes | |
| TC-SEARCH-009 | Close search with Escape | 1. Open search 2. Press Escape key | Search closes, query cleared | |
| TC-SEARCH-010 | Close search with X button | 1. Open search 2. Click X button | Search closes, query cleared | |
| TC-SEARCH-011 | Click result navigates | 1. Open search 2. Type query 3. Click on a result | Navigates to selected page, search closes | |
| TC-SEARCH-012 | Fuzzy search matching | 1. Open search 2. Type "instal" (typo of "installation") | Still shows "Installation" result (fuzzy matching with threshold 0.3) | |
| TC-SEARCH-013 | Search results show section | 1. Open search 2. Type query 3. Observe results | Each result shows title (bold) and section name (smaller, muted) | |
| TC-SEARCH-014 | Search results scrollable | 1. Open search 2. Type query with many results 3. Scroll dropdown | Results dropdown is scrollable (max-height: 96), all results accessible |
Notes
All test cases are marked as checked by default. The checkboxes are disabled and cannot be modified. Use this document as a reference for test case coverage.