1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

remove archive date when soft deleting (#16794)

This commit is contained in:
Nick Krantz
2025-10-10 11:41:18 -05:00
committed by GitHub
parent 9c7d794cac
commit bc48164cb9
2 changed files with 23 additions and 0 deletions

View File

@@ -819,6 +819,28 @@ describe("Cipher Service", () => {
});
});
describe("softDelete", () => {
it("clears archivedDate when soft deleting", async () => {
const cipherId = "cipher-id-1" as CipherId;
const archivedCipher = {
...cipherData,
id: cipherId,
archivedDate: "2024-01-01T12:00:00.000Z",
} as CipherData;
const ciphers = { [cipherId]: archivedCipher } as Record<CipherId, CipherData>;
stateProvider.singleUser.getFake(mockUserId, ENCRYPTED_CIPHERS).nextState(ciphers);
await cipherService.softDelete(cipherId, mockUserId);
const result = await firstValueFrom(
stateProvider.singleUser.getFake(mockUserId, ENCRYPTED_CIPHERS).state$,
);
expect(result[cipherId].archivedDate).toBeNull();
expect(result[cipherId].deletedDate).toBeDefined();
});
});
describe("replace (no upsert)", () => {
// In order to set up initial state we need to manually update the encrypted state
// which will result in an emission. All tests will have this baseline emission.

View File

@@ -1412,6 +1412,7 @@ export class CipherService implements CipherServiceAbstraction {
return;
}
ciphers[cipherId].deletedDate = new Date().toISOString();
ciphers[cipherId].archivedDate = null;
};
if (typeof id === "string") {