diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e623886b4..981514009 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,6 +166,8 @@ jobs: PORTAL_RUNNER_RESOURCE_GROUP: ${{ secrets.PORTAL_RUNNER_RESOURCE_GROUP }} PORTAL_RUNNER_DATABASE_ACCOUNT: ${{ secrets.PORTAL_RUNNER_DATABASE_ACCOUNT }} PORTAL_RUNNER_DATABASE_ACCOUNT_KEY: ${{ secrets.PORTAL_RUNNER_DATABASE_ACCOUNT_KEY }} + PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT: ${{ secrets.PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT }} + PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT_KEY: ${{ secrets.PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT_KEY }} NOTEBOOKS_TEST_RUNNER_TENANT_ID: ${{ secrets.NOTEBOOKS_TEST_RUNNER_TENANT_ID }} NOTEBOOKS_TEST_RUNNER_CLIENT_ID: ${{ secrets.NOTEBOOKS_TEST_RUNNER_CLIENT_ID }} NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET: ${{ secrets.NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET }} diff --git a/test/mongo/openMongoAccount.spec.ts b/test/mongo/openMongoAccount.spec.ts new file mode 100644 index 000000000..f385b4c76 --- /dev/null +++ b/test/mongo/openMongoAccount.spec.ts @@ -0,0 +1,21 @@ +import { Frame } from "puppeteer"; +import { ApiKind } from "../../src/Contracts/DataModels"; +import { getTestExplorerFrame } from "../testExplorer/TestExplorerUtils"; + +jest.setTimeout(300000); + +let frame: Frame; + +describe("Mongo", () => { + it("Account opens", async () => { + try { + frame = await getTestExplorerFrame(ApiKind.MongoDB); + await frame.waitForSelector(".accordion"); + } catch (error) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const testName = (expect as any).getState().currentTestName; + await page.screenshot({ path: `Test Failed ${testName}.jpg` }); + throw error; + } + }); +}); diff --git a/test/selfServe/selfServeExample.spec.ts b/test/selfServe/selfServeExample.spec.ts index a2f460943..7519c6c2e 100644 --- a/test/selfServe/selfServeExample.spec.ts +++ b/test/selfServe/selfServeExample.spec.ts @@ -2,17 +2,22 @@ import { Frame } from "puppeteer"; import { TestExplorerParams } from "../testExplorer/TestExplorerParams"; import { getTestExplorerFrame } from "../testExplorer/TestExplorerUtils"; import { SelfServeType } from "../../src/SelfServe/SelfServeUtils"; +import { ApiKind } from "../../src/Contracts/DataModels"; jest.setTimeout(300000); let frame: Frame; describe("Self Serve", () => { - it.skip("Launch Self Serve Example", async () => { + it("Launch Self Serve Example", async () => { try { frame = await getTestExplorerFrame( + ApiKind.SQL, new Map([[TestExplorerParams.selfServeType, SelfServeType.example]]) ); + // wait for refresh RP call to end + await frame.waitFor(10000); + // id of the display element is in the format {PROPERTY_NAME}-{DISPLAY_NAME}-{DISPLAY_TYPE} await frame.waitForSelector("#description-text-display"); diff --git a/test/testExplorer/TestExplorer.ts b/test/testExplorer/TestExplorer.ts index 612ae2f64..e7bc37720 100644 --- a/test/testExplorer/TestExplorer.ts +++ b/test/testExplorer/TestExplorer.ts @@ -1,9 +1,9 @@ import "../../less/hostedexplorer.less"; import { TestExplorerParams } from "./TestExplorerParams"; -import { DatabaseAccountsGetResponse } from "@azure/arm-cosmosdb/esm/models"; import { CosmosDBManagementClient } from "@azure/arm-cosmosdb"; import * as msRest from "@azure/ms-rest-js"; import * as ViewModels from "../../src/Contracts/ViewModels"; +import { Capability, DatabaseAccount } from "../../src/Contracts/DataModels"; class CustomSigner implements msRest.ServiceClientCredentials { private token: string; @@ -22,9 +22,32 @@ const getDatabaseAccount = async ( notebooksAccountSubscriptonId: string, notebooksAccountResourceGroup: string, notebooksAccountName: string -): Promise => { +): Promise => { const client = new CosmosDBManagementClient(new CustomSigner(token), notebooksAccountSubscriptonId); - return client.databaseAccounts.get(notebooksAccountResourceGroup, notebooksAccountName); + const databaseAccountGetResponse = await client.databaseAccounts.get( + notebooksAccountResourceGroup, + notebooksAccountName + ); + + const databaseAccount: DatabaseAccount = { + id: databaseAccountGetResponse.id, + name: databaseAccountGetResponse.name, + location: databaseAccountGetResponse.location, + type: databaseAccountGetResponse.type, + kind: databaseAccountGetResponse.kind, + tags: databaseAccountGetResponse.tags, + properties: { + documentEndpoint: databaseAccountGetResponse.documentEndpoint, + tableEndpoint: undefined, + gremlinEndpoint: undefined, + cassandraEndpoint: undefined, + capabilities: databaseAccountGetResponse.capabilities.map((capability) => { + return { name: capability.name } as Capability; + }), + }, + }; + + return databaseAccount; }; const initTestExplorer = async (): Promise => { @@ -55,7 +78,7 @@ const initTestExplorer = async (): Promise => { subscriptionId: portalRunnerSubscripton, resourceGroup: portalRunnerResourceGroup, authorizationToken: `Bearer ${token}`, - features: {}, + features: { sampleFeature: "sampleFeatureValue" }, hasWriteAccess: true, csmEndpoint: "https://management.azure.com", dnsSuffix: "documents.azure.com", diff --git a/test/testExplorer/TestExplorerUtils.ts b/test/testExplorer/TestExplorerUtils.ts index f26bc2778..5f7dadd6c 100644 --- a/test/testExplorer/TestExplorerUtils.ts +++ b/test/testExplorer/TestExplorerUtils.ts @@ -1,18 +1,30 @@ import { Frame } from "puppeteer"; import { TestExplorerParams } from "./TestExplorerParams"; import { ClientSecretCredential } from "@azure/identity"; +import { ApiKind } from "../../src/Contracts/DataModels"; let testExplorerFrame: Frame; -export const getTestExplorerFrame = async (params?: Map): Promise => { +export const getTestExplorerFrame = async (apiKind?: ApiKind, params?: Map): Promise => { if (testExplorerFrame) { return testExplorerFrame; } + let portalRunnerDatabaseAccount: string; + let portalRunnerDatabaseAccountKey: string; + + switch (apiKind) { + case ApiKind.MongoDB: + portalRunnerDatabaseAccount = process.env.PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT; + portalRunnerDatabaseAccountKey = process.env.PORTAL_RUNNER_MONGO_DATABASE_ACCOUNT_KEY; + break; + default: + portalRunnerDatabaseAccount = process.env.PORTAL_RUNNER_DATABASE_ACCOUNT; + portalRunnerDatabaseAccountKey = process.env.PORTAL_RUNNER_DATABASE_ACCOUNT_KEY; + } + const notebooksTestRunnerTenantId = process.env.NOTEBOOKS_TEST_RUNNER_TENANT_ID; const notebooksTestRunnerClientId = process.env.NOTEBOOKS_TEST_RUNNER_CLIENT_ID; const notebooksTestRunnerClientSecret = process.env.NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET; - const portalRunnerDatabaseAccount = process.env.PORTAL_RUNNER_DATABASE_ACCOUNT; - const portalRunnerDatabaseAccountKey = process.env.PORTAL_RUNNER_DATABASE_ACCOUNT_KEY; const portalRunnerSubscripton = process.env.PORTAL_RUNNER_SUBSCRIPTION; const portalRunnerResourceGroup = process.env.PORTAL_RUNNER_RESOURCE_GROUP;