2021-05-07 21:38:24 +02:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration34 from './034';
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('migration #34', function () {
|
|
|
|
it('should update the version metadata', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {
|
|
|
|
version: 33,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.meta, {
|
2020-11-03 00:41:28 +01:00
|
|
|
version: 34,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should set migratedPrivacyMode & privacyMode if featureFlags.privacyMode was false', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: false,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
|
|
|
assert.deepEqual(newStorage.data.PreferencesController, {
|
2020-11-03 00:41:28 +01:00
|
|
|
migratedPrivacyMode: true,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
done();
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if migratedPrivacyMode is already set to true', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
migratedPrivacyMode: true,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if migratedPrivacyMode is already set to false', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
migratedPrivacyMode: false,
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should NOT change any state if featureFlags.privacyMode is already true', function (done) {
|
2019-08-01 18:33:20 +02:00
|
|
|
const oldStorage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
featureFlags: {
|
|
|
|
privacyMode: true,
|
2019-08-01 18:33:20 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-08-01 18:33:20 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migration34
|
|
|
|
.migrate(oldStorage)
|
2019-08-01 18:33:20 +02:00
|
|
|
.then((newStorage) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.deepEqual(newStorage.data, oldStorage.data);
|
|
|
|
done();
|
2019-08-01 18:33:20 +02:00
|
|
|
})
|
2021-02-04 19:15:23 +01:00
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|