Onboarding

This commit is contained in:
2026-05-08 13:00:30 +02:00
parent d37b49f1f6
commit 9386ae1be7
37 changed files with 5606 additions and 2275 deletions

View File

@@ -0,0 +1,40 @@
jest.mock('../../server/lib/postgres', () => ({
get: jest.fn(),
run: jest.fn(),
}));
const { get, run } = require('../../server/lib/postgres');
const { deleteAccount, signUp } = require('../../server/lib/auth');
describe('server auth account deletion', () => {
beforeEach(() => {
jest.clearAllMocks();
get.mockResolvedValue(null);
run.mockResolvedValue({ lastId: null, changes: 1, rows: [] });
});
it('removes auth and billing rows so the same email can sign up again', async () => {
const email = 'same@example.com';
await signUp({}, email, 'First User', 'password-1');
await deleteAccount({}, 'usr_deleted');
await signUp({}, email, 'Second User', 'password-2');
const authDeletes = run.mock.calls.filter(([, sql]) => (
typeof sql === 'string' && sql.includes('DELETE FROM auth_users')
));
expect(authDeletes).toHaveLength(1);
const billingAccountDeletes = run.mock.calls.filter(([, sql]) => (
typeof sql === 'string' && sql.includes('DELETE FROM billing_accounts')
));
expect(billingAccountDeletes).toHaveLength(1);
const signupChecks = get.mock.calls.filter(([, sql], params) => (
typeof sql === 'string'
&& sql.includes('SELECT id FROM auth_users WHERE LOWER(email)')
&& params?.[0] === email
));
expect(signupChecks).toHaveLength(2);
});
});