import { CogniteWellsClient } from "src"; import { NptItems } from "src/model/nptItems"; import { setupLoggedInClient } from "../testUtils"; import { expectContainAll, expectNotContainAny, } from "./utils/expectContainAll"; let client: CogniteWellsClient; beforeAll(async () => { client = await setupLoggedInClient(); }); test("get list of npt events", async () => { expect(client).not.toBe(undefined); const nptEvents = await client.npt.list({}); const actualExternalIds = nptEvents.items.map( (npt) => npt.source.eventExternalId ); expectContainAll(actualExternalIds, [ "in_well1-A", "in_well1-A_2", "in_well1-D", "in_well2", "in_well3", ]); const actualWellmatchIds = nptEvents.items.map( (npt) => npt.wellboreMatchingId ); expect(actualWellmatchIds).not.toContain(""); expectContainAll(actualWellmatchIds, [ "15/9-F-15 A", "15/9-F-15 D", "13/10-F-11 T2", ]); }); test("filter npt events by measured depth", async () => { expect(client).not.toBe(undefined); const nptEvents = await client.npt.list({ filter: { measuredDepth: { min: 5.0, max: 15.0, unit: "meter" } }, }); const actual = nptEvents.items.map((npt) => npt.source.eventExternalId); expectContainAll(actual, ["in_well1-A", "in_well1-D"]); expectNotContainAny(actual, ["in_well1-A_2", "in_well2", "in_well3"]); }); test("filter npt events by measured depth (inches)", async () => { expect(client).not.toBe(undefined); const nptEvents = await client.npt.list({ filter: { measuredDepth: { min: 590.0, max: 984.0, unit: "inch" } }, }); const actual = nptEvents.items.map((npt) => npt.source.eventExternalId); expectContainAll(actual, ["in_well1-A_2", "in_well1-D"]); expectNotContainAny(actual, ["in_well1-A", "in_well2", "in_well3"]); }); test("filter npt events by duration", async () => { expect(client).not.toBe(undefined); const nptEvents: NptItems = await client.npt.list({ filter: { duration: { unit: "hour", min: 3.0, max: 10.5 } }, }); const actual = nptEvents.items.map((npt) => npt.source.eventExternalId); expectContainAll(actual, [ "in_well1-A_2", "in_well1-D", "in_well2", "in_well3", ]); }); test("filter npt events by npt code", async () => { expect(client).not.toBe(undefined); const nptEvents = await client.npt.list({ filter: { nptCode: { oneOf: ["TESTCODE3"] } }, }); const actual = nptEvents.items.map((npt) => npt.source.eventExternalId); expectContainAll(actual, ["in_well1-D", "in_well2"]); expectNotContainAny(actual, ["in_well1-A", "in_well1-A_2", "in_well3"]); }); test("list npt events with pagination", async () => { expect(client).not.toBe(undefined); const firstGet = await client.npt.list({ limit: 2 }); expect(firstGet.items.length).toBe(2); expect(firstGet.nextCursor).not.toBeUndefined(); const secondGet = await client.npt.list({ limit: 3, cursor: firstGet.nextCursor, }); expect(secondGet.items.length).toBe(3); const actual = firstGet.items .concat(secondGet.items) .map((it) => it.source.eventExternalId); expectContainAll(actual, [ "in_well1-A", "in_well1-A_2", "in_well1-D", "in_well2", "in_well3", ]); }); test("aggregate npt events", async () => { expect(client).not.toBe(undefined); const aggregates = await client.npt.aggregate({ filter: { wellboreIds: [{ matchingId: "13/10-F-11 T2" }], }, groupBy: ["npt code"], }); expect(aggregates.items.length).toBe(1); const aggregate = aggregates.items[0]; expect(aggregate.wellboreMatchingId).toBe("13/10-F-11 T2"); });