1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

[PM-18969] CSV importers should create nested collections (#14007)

This commit is contained in:
Vijay Oommen
2025-04-14 10:46:58 -05:00
committed by GitHub
parent f1a2acb0b9
commit 7e621be6cb
11 changed files with 303 additions and 35 deletions

View File

@@ -1,6 +1,9 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { testData as TestData } from "../spec-data/keeper-csv/testdata.csv";
import {
testData as TestData,
testDataMultiCollection,
} from "../spec-data/keeper-csv/testdata.csv";
import { KeeperCsvImporter } from "./keeper-csv-importer";
@@ -121,4 +124,32 @@ describe("Keeper CSV Importer", () => {
expect(result.collectionRelationships[1]).toEqual([1, 0]);
expect(result.collectionRelationships[2]).toEqual([2, 1]);
});
it("should create collections tree, with child collections and relationships", async () => {
importer.organizationId = Utils.newGuid();
const result = await importer.parse(testDataMultiCollection);
expect(result != null).toBe(true);
const collections = result.collections;
expect(collections).not.toBeNull();
expect(collections.length).toBe(3);
// collection with the cipher
const collections1 = collections.shift();
expect(collections1.name).toBe("Foo/Baz/Bar");
//second level collection
const collections2 = collections.shift();
expect(collections2.name).toBe("Foo/Baz");
//third level
const collections3 = collections.shift();
expect(collections3.name).toBe("Foo");
// [Cipher, Folder]
expect(result.collectionRelationships.length).toBe(3);
expect(result.collectionRelationships[0]).toEqual([0, 0]);
expect(result.collectionRelationships[1]).toEqual([1, 1]);
expect(result.collectionRelationships[2]).toEqual([2, 2]);
});
});