Add user and employee management enhancements with database schema updates
- Introduced new columns `status`, `created_by`, and `updated_by` in the `users` table to track user status and ownership. - Updated the `employees` table to include a foreign key reference to the `users` table via `user_id`. - Created migration script `0012_users_primary.sql` to apply these changes to the database schema. - Enhanced the `EmployeesService` and `EmployeesRepository` to support user assignments and related data retrieval. - Updated DTOs and service methods to reflect the new user and employee relationships. - Added unit tests to validate the new functionality and ensure data integrity. - Modified existing controllers to accommodate the new fields and relationships in user and employee management.
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
privileges,
|
||||
users,
|
||||
} from '../src/database/schema';
|
||||
import { registerAndActivate } from './helpers/activate-user';
|
||||
|
||||
describe('Privileges (e2e)', () => {
|
||||
let app: INestApplication<App>;
|
||||
@@ -41,27 +42,20 @@ describe('Privileges (e2e)', () => {
|
||||
await app.init();
|
||||
db = app.get(DRIZZLE);
|
||||
|
||||
const adminReg = await request(app.getHttpServer())
|
||||
.post('/auth/register')
|
||||
.send({ username: adminUsername, password })
|
||||
.expect(201);
|
||||
adminAccessToken = (adminReg.body as { accessToken: string }).accessToken;
|
||||
|
||||
const admin = await registerAndActivate(app, db, adminUsername, password);
|
||||
adminAccessToken = admin.accessToken;
|
||||
adminUserId = admin.userId;
|
||||
const adminMe = await request(app.getHttpServer())
|
||||
.get('/auth/me')
|
||||
.set('Authorization', `Bearer ${adminAccessToken}`)
|
||||
.expect(200);
|
||||
adminUserId = (adminMe.body as { id: string }).id;
|
||||
expect(adminMe.body).toMatchObject({
|
||||
privilege: null,
|
||||
permissions: {},
|
||||
});
|
||||
|
||||
const otherReg = await request(app.getHttpServer())
|
||||
.post('/auth/register')
|
||||
.send({ username: otherUsername, password })
|
||||
.expect(201);
|
||||
otherAccessToken = (otherReg.body as { accessToken: string }).accessToken;
|
||||
const other = await registerAndActivate(app, db, otherUsername, password);
|
||||
otherAccessToken = other.accessToken;
|
||||
const otherMe = await request(app.getHttpServer())
|
||||
.get('/auth/me')
|
||||
.set('Authorization', `Bearer ${otherAccessToken}`)
|
||||
|
||||
Reference in New Issue
Block a user