fix(settings): keep Steam ID as string and store the new token

Number("76561198005679788") is 76561198005679790 in JavaScript, so the wrong
Steam ID was saved. The Steam ID now stays a 17-digit string. Theme and
language saves no longer send steamId 0. After a save the new token from Auth
replaces the old one.

Add Vitest and run it in CI.
This commit is contained in:
lobo committed 2026-09-24 08:57:03 +02:00
1 parent 2c1f22f4b4
commit 44e23de6d6
6 files changed
+343 -22

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import {describe, expect, it} from 'vitest';
import {registrationSchema, settingsSchema} from './validation.js';
const settings = (steamId) => ({useDarkTheme: true, language: 'de', steamId});
describe('steamId validation', () => {
it('keeps a SteamID64 as the exact string', () => {
// Number('76561198005679788') is 76561198005679790
expect(settingsSchema.parse(settings('76561198005679788')).steamId).toBe('76561198005679788');
});
it('trims whitespace', () => {
expect(settingsSchema.parse(settings(' 76561198005679788 ')).steamId).toBe('76561198005679788');
});
it.each(['', '12345', '7656119800567978x', '765611980056797880'])('rejects %j', (steamId) => {
expect(settingsSchema.safeParse(settings(steamId)).success).toBe(false);
});
it('keeps the exact string on registration', () => {
const result = registrationSchema.parse({
email: 'a@b.de',
password: 'password1',
passwordConfirmation: 'password1',
inviteCode: 'code',
steamId: '76561198005679788',
});
expect(result.steamId).toBe('76561198005679788');
});
});