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:
@@ -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]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user