dynamic locations

This commit is contained in:
2026-11-11 14:10:01 +03:30
parent 5e3bd02243
commit 658a8a74cc
18 changed files with 454 additions and 111 deletions
@@ -0,0 +1,38 @@
import { SEED_FANAVARAN_CLIENT_PROFILES } from "src/core/config/fanavaran-client.config";
import { FanavaranClientConfigService } from "./fanavaran-client-config.service";
describe("Moallem attachment file type", () => {
it("seeds file type 17 for Moallem and retains the other tenant file types", () => {
expect(
SEED_FANAVARAN_CLIENT_PROFILES.moallem.defaults.ClaimFileTypeId,
).toBe(17);
expect(
SEED_FANAVARAN_CLIENT_PROFILES.parsian.defaults.ClaimFileTypeId,
).toBe(63);
expect(
SEED_FANAVARAN_CLIENT_PROFILES.tejaratno.defaults.ClaimFileTypeId,
).toBe(23);
});
it("migrates only Moallem's old shared default on existing installations", async () => {
const service = Object.create(
FanavaranClientConfigService.prototype,
) as any;
service.configModel = {
updateOne: jest.fn().mockResolvedValue({ modifiedCount: 1 }),
findOne: jest.fn().mockReturnValue({
select: () => ({
lean: () => ({ exec: async () => ({ _id: "existing" }) }),
}),
}),
create: jest.fn(),
};
await service.seedMissingProfiles();
expect(service.configModel.updateOne).toHaveBeenCalledTimes(1);
expect(service.configModel.updateOne).toHaveBeenCalledWith(
{ key: "moallem", "defaults.ClaimFileTypeId": 23 },
{ $set: { "defaults.ClaimFileTypeId": 17 } },
);
expect(service.configModel.create).not.toHaveBeenCalled();
});
});