import CogniteWellsClient from "src/client/cogniteWellsClient"; import { setupLoggedInClient } from "../testUtils"; import { IdentifierItems } from "src/model/identifierItems"; import { expectContainAll } from "./utils/expectContainAll"; let client: CogniteWellsClient; beforeAll(async () => { client = await setupLoggedInClient(); }); test("retrieve multiple wellbores", async () => { expect(client).not.toBe(undefined); const wellboreIds: IdentifierItems = { items: [ { assetExternalId: "VOLVE:15/9-F-15 A" }, { assetExternalId: "VOLVE:13/10-F-11 B" }, ], }; const actual = await client.wellbores.retrieveMultiple(wellboreIds); const actualIds = actual.items.map((wb) => wb.sources.map((source) => source.assetExternalId) ); const actualIdsFlattened = ([] as string[]).concat(...actualIds); expectContainAll(actualIdsFlattened, [ "VOLVE:15/9-F-15 A", "VOLVE:13/10-F-11 B", ]); }); test("retrieve empty list of wellbores", async () => { expect(client).not.toBe(undefined); const wellbores = await client.wellbores.retrieveMultiple({ items: [] }); expect(wellbores.items.length).toBe(0); }); test("retrieve multiple wellbores by wells", async () => { expect(client).not.toBe(undefined); const wellIds: IdentifierItems = { items: [ { assetExternalId: "VOLVE:15/9-F-15" }, { assetExternalId: "VOLVE:15/9-F-4" }, ], }; const wells = await client.wellbores.retrieveMultipleByWells(wellIds); expect(wells.items.length).not.toBe(0); wells.items.forEach((well) => expect(well.wellbores!.length).not.toBe(0)); }); test("set just name merge rules", async () => { expect(client).not.toBe(undefined); const current = await client.wellbores.mergeRules.retrieve(); const actual = await client.wellbores.mergeRules.set({ name: ["VOLVE", "EDM"], description: current.description, datum: ["EDM", "VOLVE"], parents: ["EDM", "VOLVE"], wellTops: ["EDM", "VOLVE"], }); expect(actual.name).toEqual(["VOLVE", "EDM"]); expect(actual.description).toEqual(current.description); expect(actual.datum).toEqual(["EDM", "VOLVE"]); expect(actual.parents).toEqual(["EDM", "VOLVE"]); expect(actual.wellTops).toEqual(["EDM", "VOLVE"]); }); test("set all rules using a list", async () => { expect(client).not.toBe(undefined); const actual = await client.wellbores.mergeRules.set(["EDM", "VOLVE"]); expect(actual.name).toEqual(["EDM", "VOLVE"]); expect(actual.description).toEqual(["EDM", "VOLVE"]); // Also test getting const retrievedNames = await client.wellbores.mergeRules.retrieve(); expect(retrievedNames.name).toEqual(["EDM", "VOLVE"]); expect(retrievedNames.description).toEqual(["EDM", "VOLVE"]); });