feat(api): seed dev admin + worker via admin createUser
This commit is contained in:
@@ -9,36 +9,31 @@ const SEED_NAMES = ['Leerrand', 'Frezen', 'Slijpen', 'Bekleden', 'Afwerken', 'Pr
|
||||
describe('seed', () => {
|
||||
it('seeds the reference activities idempotently', async () => {
|
||||
await seed();
|
||||
const first = await db
|
||||
.select()
|
||||
.from(activities)
|
||||
.where(inArray(activities.name, SEED_NAMES));
|
||||
const first = await db.select().from(activities).where(inArray(activities.name, SEED_NAMES));
|
||||
const countFirst = first.length;
|
||||
|
||||
await seed();
|
||||
const second = await db
|
||||
.select()
|
||||
.from(activities)
|
||||
.where(inArray(activities.name, SEED_NAMES));
|
||||
const second = await db.select().from(activities).where(inArray(activities.name, SEED_NAMES));
|
||||
|
||||
expect(second.length).toBe(countFirst);
|
||||
expect(countFirst).toBe(SEED_NAMES.length);
|
||||
|
||||
const printen = await db
|
||||
.select()
|
||||
.from(activities)
|
||||
.where(eq(activities.name, 'Printen'));
|
||||
const printen = await db.select().from(activities).where(eq(activities.name, 'Printen'));
|
||||
expect(printen).toHaveLength(1);
|
||||
expect(printen[0]?.insoleTypes).toEqual(['3D']);
|
||||
});
|
||||
|
||||
it('seeds the dev test account idempotently (and only once)', async () => {
|
||||
it('seeds the dev worker + dev admin idempotently with correct roles', async () => {
|
||||
await seed();
|
||||
const first = await db.select().from(user).where(eq(user.email, 'worker@solelog.local'));
|
||||
expect(first).toHaveLength(1);
|
||||
const w = await db.select().from(user).where(eq(user.email, 'worker@solelog.local'));
|
||||
const a = await db.select().from(user).where(eq(user.email, 'admin@solelog.local'));
|
||||
expect(w).toHaveLength(1);
|
||||
expect(a).toHaveLength(1);
|
||||
expect((a[0] as { role?: string }).role).toBe('admin');
|
||||
|
||||
await seed();
|
||||
const second = await db.select().from(user).where(eq(user.email, 'worker@solelog.local'));
|
||||
expect(second).toHaveLength(1);
|
||||
expect(await db.select().from(user).where(eq(user.email, 'admin@solelog.local'))).toHaveLength(
|
||||
1
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user