mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
118 lines
2.3 KiB
TypeScript
118 lines
2.3 KiB
TypeScript
// Copyright 2026 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import { assert } from 'chai';
|
|
|
|
import type { WritableDB } from '../../sql/Interface.std.js';
|
|
import {
|
|
createDB,
|
|
getTableData,
|
|
insertData,
|
|
updateToVersion,
|
|
} from './helpers.node.js';
|
|
|
|
describe('SQL/updateToSchemaVersion1680', () => {
|
|
let db: WritableDB;
|
|
|
|
beforeEach(() => {
|
|
db = createDB();
|
|
updateToVersion(db, 1670);
|
|
});
|
|
|
|
afterEach(() => {
|
|
db.close();
|
|
});
|
|
|
|
it('nulls empty string columns', () => {
|
|
insertData(db, 'conversations', [
|
|
{
|
|
id: 'c1',
|
|
e164: '',
|
|
name: '',
|
|
profileName: '',
|
|
profileFamilyName: '',
|
|
expireTimerVersion: 1,
|
|
json: {},
|
|
},
|
|
]);
|
|
|
|
updateToVersion(db, 1680);
|
|
|
|
assert.deepStrictEqual(getTableData(db, 'conversations'), [
|
|
{
|
|
id: 'c1',
|
|
expireTimerVersion: 1,
|
|
json: {},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('leaves non-empty columns untouched', () => {
|
|
insertData(db, 'conversations', [
|
|
{
|
|
id: 'c1',
|
|
e164: 'abc',
|
|
name: 'def',
|
|
profileName: 'ghi',
|
|
profileFamilyName: 'jkl',
|
|
expireTimerVersion: 1,
|
|
json: {},
|
|
},
|
|
]);
|
|
|
|
updateToVersion(db, 1680);
|
|
|
|
assert.deepStrictEqual(getTableData(db, 'conversations'), [
|
|
{
|
|
id: 'c1',
|
|
e164: 'abc',
|
|
name: 'def',
|
|
profileName: 'ghi',
|
|
profileFamilyName: 'jkl',
|
|
expireTimerVersion: 1,
|
|
json: {},
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('nulls empty json keys', () => {
|
|
insertData(db, 'conversations', [
|
|
{
|
|
id: 'c1',
|
|
expireTimerVersion: 1,
|
|
json: {
|
|
e164: '',
|
|
name: '',
|
|
profileName: '',
|
|
profileFamilyName: '',
|
|
systemGivenName: '',
|
|
systemFamilyName: '',
|
|
systemNickname: '',
|
|
nicknameGivenName: null,
|
|
nicknameFamilyName: '',
|
|
username: '',
|
|
|
|
// Not on the list of the affected keys
|
|
accessKey: '',
|
|
|
|
// Not a string
|
|
hideStory: true,
|
|
},
|
|
},
|
|
]);
|
|
|
|
updateToVersion(db, 1680);
|
|
|
|
assert.deepStrictEqual(getTableData(db, 'conversations'), [
|
|
{
|
|
id: 'c1',
|
|
expireTimerVersion: 1,
|
|
json: {
|
|
accessKey: '',
|
|
hideStory: true,
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
});
|