mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-5956] Delete Unused State (#8439)
* Delete Unused State * Delete One More * Add Migration to Delete InstalledVersion * Update Error
This commit is contained in:
@@ -48,6 +48,7 @@ import { AccountServerConfigMigrator } from "./migrations/49-move-account-server
|
||||
import { AddKeyTypeToOrgKeysMigrator } from "./migrations/5-add-key-type-to-org-keys";
|
||||
import { KeyConnectorMigrator } from "./migrations/50-move-key-connector-to-state-provider";
|
||||
import { RememberedEmailMigrator } from "./migrations/51-move-remembered-email-to-state-providers";
|
||||
import { DeleteInstalledVersion } from "./migrations/52-delete-installed-version";
|
||||
import { RemoveLegacyEtmKeyMigrator } from "./migrations/6-remove-legacy-etm-key";
|
||||
import { MoveBiometricAutoPromptToAccount } from "./migrations/7-move-biometric-auto-prompt-to-account";
|
||||
import { MoveStateVersionMigrator } from "./migrations/8-move-state-version";
|
||||
@@ -55,7 +56,7 @@ import { MoveBrowserSettingsToGlobal } from "./migrations/9-move-browser-setting
|
||||
import { MinVersionMigrator } from "./migrations/min-version";
|
||||
|
||||
export const MIN_VERSION = 3;
|
||||
export const CURRENT_VERSION = 51;
|
||||
export const CURRENT_VERSION = 52;
|
||||
|
||||
export type MinVersion = typeof MIN_VERSION;
|
||||
|
||||
@@ -109,7 +110,8 @@ export function createMigrationBuilder() {
|
||||
.with(MoveDdgToStateProviderMigrator, 47, 48)
|
||||
.with(AccountServerConfigMigrator, 48, 49)
|
||||
.with(KeyConnectorMigrator, 49, 50)
|
||||
.with(RememberedEmailMigrator, 50, CURRENT_VERSION);
|
||||
.with(RememberedEmailMigrator, 50, 51)
|
||||
.with(DeleteInstalledVersion, 51, CURRENT_VERSION);
|
||||
}
|
||||
|
||||
export async function currentVersion(
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { runMigrator } from "../migration-helper.spec";
|
||||
|
||||
import { DeleteInstalledVersion } from "./52-delete-installed-version";
|
||||
|
||||
describe("DeleteInstalledVersion", () => {
|
||||
const sut = new DeleteInstalledVersion(51, 52);
|
||||
|
||||
describe("migrate", () => {
|
||||
it("can delete data if there", async () => {
|
||||
const output = await runMigrator(sut, {
|
||||
authenticatedAccounts: ["user1"],
|
||||
global: {
|
||||
installedVersion: "2024.1.1",
|
||||
},
|
||||
});
|
||||
|
||||
expect(output).toEqual({
|
||||
authenticatedAccounts: ["user1"],
|
||||
global: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("will run if installed version is not there", async () => {
|
||||
const output = await runMigrator(sut, {
|
||||
authenticatedAccounts: ["user1"],
|
||||
global: {},
|
||||
});
|
||||
|
||||
expect(output).toEqual({
|
||||
authenticatedAccounts: ["user1"],
|
||||
global: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { MigrationHelper } from "../migration-helper";
|
||||
import { IRREVERSIBLE, Migrator } from "../migrator";
|
||||
|
||||
type ExpectedGlobal = {
|
||||
installedVersion?: string;
|
||||
};
|
||||
|
||||
export class DeleteInstalledVersion extends Migrator<51, 52> {
|
||||
async migrate(helper: MigrationHelper): Promise<void> {
|
||||
const legacyGlobal = await helper.get<ExpectedGlobal>("global");
|
||||
if (legacyGlobal?.installedVersion != null) {
|
||||
delete legacyGlobal.installedVersion;
|
||||
await helper.set("global", legacyGlobal);
|
||||
}
|
||||
}
|
||||
rollback(helper: MigrationHelper): Promise<void> {
|
||||
throw IRREVERSIBLE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user