Test Share Feature - Step by Step
Prerequisites
1. MongoDB Must Be Running
# Check if MongoDB is running
docker ps | grep mongodb
# If not running, start it:
cd /Users/sraradhy/cisco/eti/sre/cnoe/ai-platform-engineering
docker-compose --profile caipe-ui-dev up -d mongodb mongo-express
# Verify it's running
docker ps | grep mongodb
# Should see: mongodb and mongo-express containers
2. UI Dev Server Must Be Running
cd ui
npm run dev
# Should be running on http://localhost:3000
Testing Steps
Step 1: Clear Old Conversations (IMPORTANT!)
Open Browser Console (F12) and run:
// This removes ALL old localStorage conversations
localStorage.removeItem('caipe-chat-history');
console.log("✅ Cleared old conversations");
window.location.reload();
Why? Old conversations only exist in localStorage and CANNOT be shared. We need to start fresh.
Step 2: Create a NEW Conversation
- After page reloads, you should see an empty chat history
- Click "New Chat" button in the sidebar
- Wait for redirect - URL should change to:
http://localhost:3000/chat/[some-uuid] - Check the UUID format - It should look like:
550e8400-e29b-41d4-a716-446655440000
Expected behavior:
- Loading spinner appears: "Creating new conversation..."
- Redirects to
/chat/[mongodb-generated-uuid] - Chat interface loads
If this fails:
- Check browser console for errors
- Check MongoDB is running (Step 1)
- Check API endpoint:
curl http://localhost:3000/api/chat/conversations
Step 3: Send a Message
- Type "test message" in the chat input
- Send the message
- Wait for response from CAIPE
This ensures the conversation is active and has content
Step 4: Test Share Button
- Hover over the conversation in the left sidebar
- You should see two icons appear: Share (🔗) and Delete (🗑️)
- Click the Share icon (🔗)
Expected behavior:
- Modal dialog appears centered on screen (not in sidebar)
- Dark backdrop covers entire viewport
- Dialog shows:
- "Share Conversation"
- Conversation title
- "Share Link" with URL
- "Copy" button
- "Add People" search box
If you see error "Conversation not found":
- This means you're still using an old conversation
- Go back to Step 1 and clear localStorage
- Create a completely new conversation
Step 5: Test Copy Link
- Click the "Copy" button next to the share link
- Button should change to show checkmark: "Copied"
- Open a new incognito browser window
- Paste the URL and press Enter
Expected behavior:
- New user should see the conversation
- Messages should load from MongoDB
Step 6: Test User Search
- In the "Add People" field, type an email:
sraradhy@cisco.com - Wait 300ms for search to trigger
- If user exists in MongoDB, they should appear in dropdown
- Click the user to share
Note: Users must have logged into CAIPE at least once to appear in search.
Debugging
Check if Conversation Exists in MongoDB
Browser Console:
// Get current conversation ID from URL
const conversationId = window.location.pathname.split('/').pop();
console.log("Current conversation ID:", conversationId);
// Check if it exists in MongoDB
fetch(`/api/chat/conversations/${conversationId}`)
.then(res => res.json())
.then(data => console.log("✅ Conversation exists in MongoDB:", data))
.catch(err => console.error("❌ Conversation NOT in MongoDB:", err));
Check MongoDB Direct Connection
Terminal:
# Connect to MongoDB
docker exec -it ai-platform-engineering-mongodb-1 mongosh -u admin -p changeme
# In MongoDB shell:
use caipe
# List all conversations
db.conversations.find({}).pretty()
# Count conversations
db.conversations.countDocuments()
# Exit
exit
Check MongoDB via mongo-express
- Open: http://localhost:8081
- Login: admin / changeme
- Click "caipe" database
- Click "conversations" collection
- You should see your conversations listed
Common Issues
Issue: "MongoDB connection refused"
Solution:
docker-compose --profile caipe-ui-dev up -d mongodb
docker-compose logs mongodb
Issue: "Conversation not found" even with new conversation
Check:
- MongoDB is running:
docker ps | grep mongodb - Conversation was created via API: Check browser network tab for
POST /api/chat/conversations - Response includes
_idfield - URL contains the MongoDB UUID
Debug API Call:
// In browser console after clicking "New Chat"
fetch('/api/chat/conversations', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: 'Test Conversation' })
})
.then(res => res.json())
.then(data => console.log("✅ Created:", data))
.catch(err => console.error("❌ Failed:", err));
Issue: Share dialog doesn't appear centered
Check:
- Clear browser cache: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)
- Check for z-index conflicts in browser DevTools
- Verify
document.bodyis not styled withposition: relative
Issue: User search returns no results
Check:
- User has logged in at least once:
db.users.find({email: "sraradhy@cisco.com"}) - API endpoint works:
curl http://localhost:3000/api/users/search?q=sraradhy - Authentication is working
Success Criteria
✅ MongoDB is running
✅ New conversation created via "New Chat" button
✅ URL shows MongoDB UUID format
✅ Share button appears on hover
✅ Share dialog opens centered on screen
✅ Can copy link successfully
✅ Can search for users
✅ Shared link works in incognito mode
Still Having Issues?
Collect Debug Info
# 1. Check Docker services
docker ps
# 2. Check MongoDB logs
docker-compose logs mongodb | tail -50
# 3. Check UI dev server logs
# (should be in terminal where `npm run dev` is running)
# 4. Export MongoDB data
docker exec -it ai-platform-engineering-mongodb-1 mongosh -u admin -p changeme --eval "use caipe; db.conversations.find().pretty()" > conversations.json
cat conversations.json
Share Debug Info
Include:
- Browser console errors
- Network tab for failed API calls
- MongoDB logs
- Conversation IDs you're trying to share
- Steps you followed
Last Updated: January 29, 2026 Author: Sri Aradhyula