const request = require('supertest'); const { expect } = require('chai'); const { app, mongoDB } = require('../index'); // Adjust the path to your app describe('Auth API', function () { this.timeout(10000); // Set timeout to 10000ms (10 seconds) let server; let userToken; // Start the server before running the tests before(async function () { this.timeout(10000); // Set timeout to 10000ms (10 seconds) await mongoDB.getDB; // Ensure the database is connected server = app.listen(3005); // Start the server on a different port to avoid conflicts }); // Close the server after running the tests after(async function () { this.timeout(10000); // Set timeout to 10000ms (10 seconds) server.close(); }); it('should create a new user', async function () { const res = await request(app) .post('/signup') .send({ username: 'test@example.com', email: 'test@example.com', password: 'password123', profile: { firstName: 'Test', lastName: 'User', description: 'This is a test user from the backend test', } }); expect(res.status).to.equal(200); expect(res.body).to.have.property('status'); expect(res.body.status).to.equal('This user is already registered'); //userToken = res.body.token; }); it('should login the user', async function () { const res = await request(app) .post('/login') .send({ username: 'test@example.com', password: 'password123' }); expect(res.status).to.equal(200); expect(res.body).to.have.property('user_sid'); expect(res.body).to.have.property('session_id'); userToken = res.body.user_sid; }); //it('should logout the user', async function () { // const res = await request(app) // .post('/logout') // .set('Authorization', `Bearer ${userToken}`); // expect(res.status).to.equal(200); // expect(res.body).to.have.property('status', 'ok'); //}); });