1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00
Files
browser/libs/common/src/state-migrations/migrations/66-move-final-desktop-settings.spec.ts
Justin Baur ba3d21094e [PM-7541] Move Last Desktop Settings (#9310)
* Clone Initial Data In `runMigrator`

- When using test cases, mutating the input data causes problems.

* Migrate `minimizeOnCopy` & `browserIntegrationEnabled`

* Update From Main

* Move Fingerprint Setting

- No Migration Yet

* Add Fingerprint to Migrations

* Convert Messaging to `async`

* Switch to calling `Boolean` for Map Function

* Catch Errors

* Remove LogService
2024-06-06 14:26:17 -04:00

144 lines
3.4 KiB
TypeScript

import { runMigrator } from "../migration-helper.spec";
import { MoveFinalDesktopSettingsMigrator } from "./66-move-final-desktop-settings";
describe("MoveDesktopSettings", () => {
const sut = new MoveFinalDesktopSettingsMigrator(65, 66);
const cases: {
it: string;
preMigration: Record<string, unknown>;
postMigration: Record<string, unknown>;
}[] = [
{
it: "moves truthy values",
preMigration: {
global_account_accounts: {
user1: {},
otherUser: {},
},
user1: {
settings: {
minimizeOnCopyToClipboard: true,
},
},
otherUser: {
settings: {
random: "stuff",
},
},
global: {
enableBrowserIntegration: true,
enableBrowserIntegrationFingerprint: true,
},
},
postMigration: {
global_account_accounts: {
user1: {},
otherUser: {},
},
global: {},
user1: {
settings: {},
},
otherUser: {
settings: {
random: "stuff",
},
},
global_desktopSettings_browserIntegrationEnabled: true,
user_user1_desktopSettings_minimizeOnCopy: true,
global_desktopSettings_browserIntegrationFingerprintEnabled: true,
},
},
{
it: "moves falsey values",
preMigration: {
global_account_accounts: {
user1: {},
otherUser: {},
},
user1: {
settings: {
minimizeOnCopyToClipboard: false,
},
},
otherUser: {
settings: {
random: "stuff",
},
},
global: {
enableBrowserIntegration: false,
enableBrowserIntegrationFingerprint: false,
},
},
postMigration: {
global_account_accounts: {
user1: {},
otherUser: {},
},
global: {},
user1: {
settings: {},
},
otherUser: {
settings: {
random: "stuff",
},
},
global_desktopSettings_browserIntegrationEnabled: false,
user_user1_desktopSettings_minimizeOnCopy: false,
global_desktopSettings_browserIntegrationFingerprintEnabled: false,
},
},
{
it: "does not move non-existant values",
preMigration: {
global_account_accounts: {
user1: {},
otherUser: {},
},
user1: {
settings: {},
},
otherUser: {
settings: {
random: "stuff",
},
},
global: {},
},
postMigration: {
global_account_accounts: {
user1: {},
otherUser: {},
},
global: {},
user1: {
settings: {},
},
otherUser: {
settings: {
random: "stuff",
},
},
},
},
];
describe("migrate", () => {
it.each(cases)("$it", async ({ preMigration, postMigration }) => {
const actualOutput = await runMigrator(sut, preMigration, "migrate");
expect(actualOutput).toEqual(postMigration);
});
});
describe("rollback", () => {
it.each(cases)("$it", async ({ postMigration, preMigration }) => {
const actualOutput = await runMigrator(sut, postMigration, "rollback");
expect(actualOutput).toEqual(preMigration);
});
});
});