feat: replace tenants with organization management

This commit is contained in:
2026-07-10 21:27:26 +08:00
parent 8ed1682b90
commit 8f0991a51f
49 changed files with 1292 additions and 698 deletions

View File

@@ -0,0 +1,30 @@
import { BadRequestException } from '@nestjs/common';
import { Repository } from 'typeorm';
import { OrganizationsService } from './organizations.service';
import { Organization } from '../entities/organization.entity';
describe('OrganizationsService — host organization rules', () => {
let repo: jest.Mocked<
Pick<Repository<Organization>, 'findOne' | 'find' | 'count' | 'create' | 'save' | 'update'>
>;
let service: OrganizationsService;
beforeEach(() => {
repo = {
findOne: jest.fn(),
find: jest.fn(),
count: jest.fn(),
create: jest.fn(),
save: jest.fn(),
update: jest.fn(),
} as any;
service = new OrganizationsService(repo as Repository<Organization>);
});
it('does not allow the host organization to be archived', async () => {
repo.findOne.mockResolvedValue({ id: 1, name: '本机构', isHost: true } as Organization);
await expect(service.remove(1)).rejects.toBeInstanceOf(BadRequestException);
expect(repo.update).not.toHaveBeenCalled();
});
});