Medicare Final Data Setup, Integration & Application Testing

Business Scenario

In this lab, you will prepare the Medicare application for final verification by setting up test doctor accounts and profiles, then testing the complete application through the React frontend.

Pre-Lab Preparation

Module:

1) React Basics & Backend Integration (Spring Boot)​

Phase 15 — Final Data Setup + API & Frontend Testing

  • There are only 3 things to do:
1. Add enough test data
2. Test the complete application from the frontend
3. Run a small final API/security test

Add test data first

1

  • Do not manually insert:
Appointments 
Payments 
Prescriptions 
Patients 
  • We want the frontend to create those because those are exactly the flows we need to test.
  • The only thing we really need to pre-populate is:
Doctors
  • Because the patient needs doctors available to search and book.
  • I recommend having at least 7 doctors, because your frontend pagination size is: 6
  • So 7 doctors lets us test:
Page 1 → 6 doctors
Page 2 → remaining doctor

Doctor test accounts

2

DoctorEmailSpecializationExperienceFee
Dr. Ananya Sharmaananya.doctor@example.comCardiologist121800
Dr. Rohit Mehtarohit.doctor@example.comOrthopedic81200
Dr. Neha Patilneha.doctor@example.comDentist6800
Dr. Arjun Raoarjun.doctor@example.comGeneral Physician10700
Dr. Kavya Iyerkavya.doctor@example.comCardiologist51400
Dr. Sameer Khansameer.doctor@example.comOrthopedic152000
Dr. Priya Nairpriya.doctor@example.comDentist91000
  • Use this password for all test doctors:
Doctor@123

Easiest way to insert them

3

  • Because your public registration intentionally creates: PATIENT and not DOCTOR, don't modify your registration API just for testing.
  • Use MySQL once to seed the doctor accounts.
  • Run:
USE medicare_db;
INSERT IGNORE INTO users
(name, email, phone, role, password)
VALUES

(
    'Dr. Ananya Sharma',
    'ananya.doctor@example.com',
    '9000000001',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
),

(
    'Dr. Rohit Mehta',
    'rohit.doctor@example.com',
    '9000000002',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
),

(
    'Dr. Neha Patil',
    'neha.doctor@example.com',
    '9000000003',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
),
(
    'Dr. Arjun Rao',
    'arjun.doctor@example.com',
    '9000000004',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
),
(
    'Dr. Kavya Iyer',
    'kavya.doctor@example.com',
    '9000000005',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
),
(
    'Dr. Sameer Khan',
    'sameer.doctor@example.com',
    '9000000006',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
),
(
    'Dr. Priya Nair',
    'priya.doctor@example.com',
    '9000000007',
    'DOCTOR',
    '$2y$10$9vkfZH2psSI9/RAWTZ8bCOAt7J40JPHyhJEPg82RhsR4AvFZza71S'
);
  • That BCrypt hash represents: Doctor@123

Insert doctor profiles

4

  • Then run:
INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'Cardiologist', 12, 1800.00, NULL
FROM users WHERE email = 'ananya.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);


INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'Orthopedic', 8, 1200.00, NULL
FROM users WHERE email = 'rohit.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);


INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'Dentist', 6, 800.00, NULL
FROM users WHERE email = 'neha.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);


INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'General Physician', 10, 700.00, NULL
FROM users WHERE email = 'arjun.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);


INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'Cardiologist', 5, 1400.00, NULL
FROM users WHERE email = 'kavya.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);


INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'Orthopedic', 15, 2000.00, NULL
FROM users WHERE email = 'sameer.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);


INSERT INTO doctor_profiles 
(user_id, specialization, experience_years, consultation_fee, photo_url)
SELECT id, 'Dentist', 9, 1000.00, NULL
FROM users WHERE email = 'priya.doctor@example.com'
AND NOT EXISTS (
    SELECT 1
    FROM doctor_profiles
    WHERE user_id = users.id
);
  • That's enough test data. Don't insert appointments manually.

Verify doctor data once

5

  • Before frontend testing, open:
GET http://localhost:8080/api/doctors?page=0&size=6
  • with a valid JWT.
  • You should see:
totalElements = 7
totalPages = 2
  • Once that works, stop using Postman for normal functionality
  • From this point, test through React.

Start frontend testing

6

  • Frontend:
http://localhost:5173
  • Backend:
http://localhost:8080
  • Now test in exactly this order.

Test 1 — Patient registration

Name: Rahul Patil
Email: rahul.patient@example.com
Phone: 9876543210
Password: Patient@123
  • Go to: http://localhost:5173/register
  • Create a brand-new patient:
  • Expected:
Registration successful 
Role = PATIENT 

Test 2 — Patient login

  • Go to : http://localhost:5173/login
  • Use:
rahul.patient@example.com
Patient@123
  • Expected: Patient Dashboard
  • Also refresh the browser once. You should remain logged in.

Test 3 — My Profile

  • Open :
Patient Dashboard
→ My Profile
  • Verify:
Rahul Patil
rahul.patient@example.com
9876543210
PATIENT

Test 4 — Doctor listing

  • Go to:
Patient Dashboard
→ Find Doctor
  • You should see the doctors we inserted.
  • Now test:
Search by name
Specialization
Maximum fee
Sort by fee
Sort by name
Sort by experience
Ascending
Descending
Reset Filters
  • Also verify:
Page 1
Page 2

Test 5 — Book appointment

  • For the main test, choose:
Dr. Ananya Sharma
Cardiologist
  • Select:
​Future date 10:00 AM
  • Book.
  • Expected:
Appointment Created

PENDING
UNPAID
  • This proves appointment creation works.

Test 6 — Razorpay payment

  • Click: Pay Now
  • Razorpay Checkout should open.
  • Use Razorpay Test Mode only.
  • For current Razorpay sandbox testing, their published test guidance includes:
success@razorpay
  • for a simulated successful UPI payment, and:
failure@razorpay
  • for a simulated failure.
  • Expected after backend verification
Appointment Status: CONFIRMED
Payment Status: PAID

Test 7 — Email

  • After successful payment, check the email registered for the patient.
  • Expected confirmation details:
Patient name
Doctor
Specialization
Date
Slot
Fee
CONFIRMED
PAID

Test 8 — My Appointments

  • Go to:
Patient Dashboard
→ My Appointments
  • The appointment should show:
Dr. Ananya Sharma
CONFIRMED
PAID
  • And: Cancel Appointment should not be available for the paid appointment.

Test 9 — Doctor login

  • Logout.
ananya.doctor@example.com
Doctor@123
  • Login with:
  • Expected redirect: Doctor Dashboard

Test 10 — Doctor profile

  • Open :
Doctor Dashboard
→ My Profile
  • You should see:
Cardiologist
12 years
₹1800
  • Change something temporarily, for example:
Experience:
12 → 13
  • Save
  • Verify the updated value appears.
  • Then you can return it to 12.
  • That is enough to test profile update.
  • No need to delete a working doctor profile.

Test 11 — Doctor schedule

  • Go to:
Doctor Dashboard
→ My Schedule
  • The appointment booked by Rahul should appear.
CONFIRMED + PAID
  • Because it is:
  • you should see:
Mark Completed
  • Click it.
  • Expected:
COMPLETED + PAID

Test 12 — Prescription

  • After completing the appointment:
Add Prescription
  • Use:
Diagnosis: Seasonal viral fever
Doctor Notes: Drink plenty of fluids and take adequate rest.
  • Medicine 1:
Medicine Name: Paracetamol
Dosage: 500 mg
Frequency: Twice daily
Duration: 3 days
Medicine Name: Vitamin C
Dosage: 500 mg
Frequency: Once daily
Duration: 5 days
  • Medicine 2:
  • Save.
  • Expected: Prescription created successfully

Test 13 — Patient views prescription

  • Logout doctor.
rahul.patient@example.com
Patient@123
  • Login again:
  • Go to My Appoinments
  • The appointment should be:
COMPLETED
PAID
  • Click:
View Prescription
  • Verify:
Doctor name
Diagnosis
Paracetamol
Vitamin C
Dosage
Frequency
Duration
Doctor Notes
  • If this works, your main end-to-end project flow is complete.

Test 14 — Cancellation flow

  • We need one more appointment because cancellation is also a feature.
  • Book another appointment with, for example:
Dr. Rohit Mehta
  • Choose another future date/slot.
  • Do not pay.
  • It should be:
  • Pay Now should no longer be available.
PENDING
UNPAID
  • Open: My Appointments
  • Click: Cancel Appointment
  • Expected:
CANCELLED
UNPAID

Test 15 — Failed/closed payment

  • Book another unpaid appointment.
PENDING
UNPAID
  • Click: Pay Now
  • Then either close Razorpay Checkout or use a Razorpay sandbox failure scenario such as failure@razorpay.
  • Expected:
  • The appointment must not become paid.
  • Then you can retry or cancel it.

Final API testing

7

  • After all frontend tests work, do just a few important API checks.
  • We do not need to retest every successful endpoint in Postman because the frontend already exercised them.
GET http://localhost:8080/api/health
  • API Test 1 — Health
  • Expected:
200 OK
  • API Test 2 — Wrong password
{
    "email": "rahul.patient@example.com",
    "password": "WrongPassword123"
}
  • Expected:
401 Unauthorized
GET http://localhost:8080/api/users/me
  • API Test 3 — Invalid JWT
  • Header:
Authorization:
Bearer invalid-token
  • Expected:
401 Unauthorized
  • API Test 4 — Patient cannot use doctor API
  • Login as Rahul and copy his JWT.
  • Try:
POST
http://localhost:8080/api/doctors/profile
  • Expected:
403 FORBIDDEN
  • API Test 5 — Doctor cannot create patient appointment
  • Login as:
ananya.doctor@example.com , Doctor@123
  • Use doctor JWT.
  • Try:
POST
http://localhost:8080/api/appointments
  • Expected:
403 FORBIDDEN
  • API Test 6 — Patient ownership
  • For this one create a second patient through your frontend:
Name: Amit Kumar

Email: amit.patient@example.com

Phone: 9876501234

Password: Patient@123
  • Login as Amit and get his JWT.
  • Take Rahul's appointment ID, for example: 12
  • Call:
GET
http://localhost:8080/api/appointments/12
  • using Amit's token.
  • Expected:
403 FORBIDDEN
  • That's enough to prove patient ownership is working.

HURRAY!! WE DID IT!

Congratulations on completing all the labs and building Medicare from the ground up!

One project, countless concepts, and a lot of learning. What an achievement!

   Git Push

git push origin branchName