mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
refactor(plugins): async DB-touching methods; transactions through UnitOfWork
This commit is contained in:
@@ -25,24 +25,24 @@ describe('AdminNotificationPreferencesController', () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('ADMINPREF-001 GET asks for the admin scope, not the user one', () => {
|
||||
it('ADMINPREF-001 GET asks for the admin scope, not the user one', async () => {
|
||||
const { c, prefs } = controller();
|
||||
expect(c.get(admin)).toEqual({ rows: [{ event: 'trip_reminder' }] });
|
||||
expect(await c.get(admin)).toEqual({ rows: [{ event: 'trip_reminder' }] });
|
||||
expect(prefs.getPreferencesMatrix).toHaveBeenCalledWith(1, 'admin', 'admin');
|
||||
});
|
||||
|
||||
it('ADMINPREF-002 PUT persists, then answers with the REFRESHED matrix', () => {
|
||||
it('ADMINPREF-002 PUT persists, then answers with the REFRESHED matrix', async () => {
|
||||
const { c, prefs } = controller();
|
||||
// The admin panel renders straight from this response, so returning the write
|
||||
// result instead of a fresh read would leave it showing stale rows.
|
||||
expect(c.set(admin, { trip_reminder: { email: true } } as never)).toEqual({ rows: [{ event: 'trip_reminder' }] });
|
||||
expect(await c.set(admin, { trip_reminder: { email: true } } as never)).toEqual({ rows: [{ event: 'trip_reminder' }] });
|
||||
expect(prefs.setAdminPreferences).toHaveBeenCalledWith(1, { trip_reminder: { email: true } });
|
||||
expect(prefs.getPreferencesMatrix).toHaveBeenCalledWith(1, 'admin', 'admin');
|
||||
});
|
||||
|
||||
it('ADMINPREF-003 the acting user drives the lookup, never a body field', () => {
|
||||
it('ADMINPREF-003 the acting user drives the lookup, never a body field', async () => {
|
||||
const { c, prefs } = controller();
|
||||
c.get({ id: 7, role: 'admin' } as User);
|
||||
await c.get({ id: 7, role: 'admin' } as User);
|
||||
expect(prefs.getPreferencesMatrix).toHaveBeenCalledWith(7, 'admin', 'admin');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user