mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
test(server): assert the row exists before checking its stamped columns
findRow returns null for a missing row, and `row?.deleted_at` is then undefined, which `.not.toBeNull()` accepts. The converted soft delete, album sync and passkey counter checks would therefore pass if the row were removed outright. They now assert the row is there first, as the raw `.get()` reads they replace did by throwing on a missing row.
This commit is contained in:
@@ -460,7 +460,9 @@ describe('toggleStarred / softDeleteFile / restoreFile', () => {
|
|||||||
const file = await makeFile(trip.id, user.id);
|
const file = await makeFile(trip.id, user.id);
|
||||||
await svc.softDeleteFile(file.id);
|
await svc.softDeleteFile(file.id);
|
||||||
const row = await findRow(orm, TripFiles, { id: file.id });
|
const row = await findRow(orm, TripFiles, { id: file.id });
|
||||||
expect(row?.deleted_at).not.toBeNull();
|
// The row must still be there: a hard delete would leave findRow at null.
|
||||||
|
expect(row).not.toBeNull();
|
||||||
|
expect(row!.deleted_at).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FILE-SVC-021: restoreFile clears deleted_at and returns the formatted row', async () => {
|
it('FILE-SVC-021: restoreFile clears deleted_at and returns the formatted row', async () => {
|
||||||
|
|||||||
@@ -691,7 +691,8 @@ describe('updateSyncTimeForAlbumLink (MA9)', () => {
|
|||||||
await access.updateSyncTimeForAlbumLink(String(linkId));
|
await access.updateSyncTimeForAlbumLink(String(linkId));
|
||||||
|
|
||||||
const row = await findRow(orm, TripAlbumLinks, { id: linkId });
|
const row = await findRow(orm, TripAlbumLinks, { id: linkId });
|
||||||
expect(row?.last_synced_at).not.toBeNull();
|
expect(row).not.toBeNull();
|
||||||
|
expect(row!.last_synced_at).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('MEMACCESS-MA9-002: a non-canonical id is a silent no-op, matching a legacy UPDATE that matched zero rows', async () => {
|
it('MEMACCESS-MA9-002: a non-canonical id is a silent no-op, matching a legacy UPDATE that matched zero rows', async () => {
|
||||||
|
|||||||
@@ -666,8 +666,9 @@ describe('passkeyLoginVerify', () => {
|
|||||||
expect(decoded).toHaveProperty('pv');
|
expect(decoded).toHaveProperty('pv');
|
||||||
|
|
||||||
const credRow = (await findRow(orm, WebauthnCredentials, { id: cred.id }));
|
const credRow = (await findRow(orm, WebauthnCredentials, { id: cred.id }));
|
||||||
expect(credRow?.counter).toBe(6);
|
expect(credRow).not.toBeNull();
|
||||||
expect(credRow?.last_used_at).not.toBeNull();
|
expect(credRow!.counter).toBe(6);
|
||||||
|
expect(credRow!.last_used_at).not.toBeNull();
|
||||||
const userRow = await readUser(orm, user.id);
|
const userRow = await readUser(orm, user.id);
|
||||||
expect(userRow.last_login).not.toBeNull();
|
expect(userRow.last_login).not.toBeNull();
|
||||||
expect(userRow.login_count).toBe(1);
|
expect(userRow.login_count).toBe(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user