"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
const core_common_1 = require("@itwin/core-common");
const core_frontend_1 = require("@itwin/core-frontend");
const frontend_1 = require("@itwin/oidc-signin-tool/lib/cjs/frontend");
const TestContext_1 = require("../setup/TestContext");
const expect = chai.expect;
chai.use(chaiAsPromised);
describe("Basic Scenarios", async () => {
    let testContext;
    before(async () => {
        testContext = await TestContext_1.TestContext.instance();
        const accessToken = testContext.serviceAuthToken;
        core_frontend_1.IModelApp.authorizationClient = new frontend_1.TestFrontendAuthorizationClient(accessToken);
    });
    async function openIModelAndQueryPage(iTwinId, iModelId) {
        const iModel = await core_frontend_1.CheckpointConnection.openRemote(iTwinId, iModelId);
        expect(iModel).to.exist;
        expect(iModel.elements).to.exist;
        const elements = iModel.elements;
        const elementProps = await elements.getProps(elements.rootSubjectId);
        expect(elementProps).to.exist;
        expect(elementProps.length).to.equal(1);
    }
    it("should successfully open a new IModel with changesets for read and Get Properties for an Element TestCase:819342", async () => {
        const iTwinId = testContext.iTwinId;
        const iModelId = testContext.iModelWithChangesets.iModelId;
        await openIModelAndQueryPage(iTwinId, iModelId);
    });
    it("should open iModel and Execute Query TestCase:819343", async () => {
        const iModel = await testContext.iModelWithChangesets.getConnection();
        const rows = [];
        for await (const row of iModel.createQueryReader("SELECT ECInstanceId AS id FROM BisCore.Element", undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames, limit: { count: 10 } }))
            rows.push(row);
        expect(rows).not.to.be.empty;
    });
});
//# sourceMappingURL=BasicScenarios.test.js.map