mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-07-21 21:07:23 +01:00
e-enable more tests.
This commit is contained in:
@@ -1,60 +1,60 @@
|
||||
// import { expect, test } from "@playwright/test";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||
// import { CosmosClient, PermissionMode } from "@azure/cosmos";
|
||||
// import {
|
||||
// DataExplorer,
|
||||
// TestAccount,
|
||||
// generateUniqueName,
|
||||
// getAccountName,
|
||||
// getAzureCLICredentials,
|
||||
// resourceGroupName,
|
||||
// subscriptionId,
|
||||
// } from "../fx";
|
||||
// import { getNoSqlRbacToken } from "../NoSqlTestSetup";
|
||||
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||
import { CosmosClient, PermissionMode } from "@azure/cosmos";
|
||||
import {
|
||||
DataExplorer,
|
||||
TestAccount,
|
||||
generateUniqueName,
|
||||
getAccountName,
|
||||
getAzureCLICredentials,
|
||||
resourceGroupName,
|
||||
subscriptionId,
|
||||
} from "../fx";
|
||||
import { getNoSqlRbacToken } from "../NoSqlTestSetup";
|
||||
|
||||
// test("SQL account using Resource token", async ({ page }) => {
|
||||
// test.skip();
|
||||
// const nosqlAccountRbacToken = getNoSqlRbacToken() ?? "";
|
||||
// test.skip(nosqlAccountRbacToken.length > 0, "Resource tokens not supported when using data plane RBAC.");
|
||||
test("SQL account using Resource token", async ({ page }) => {
|
||||
test.skip();
|
||||
const nosqlAccountRbacToken = getNoSqlRbacToken() ?? "";
|
||||
test.skip(nosqlAccountRbacToken.length > 0, "Resource tokens not supported when using data plane RBAC.");
|
||||
|
||||
// const credentials = getAzureCLICredentials();
|
||||
// const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
// const accountName = getAccountName(TestAccount.SQL);
|
||||
// const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||
// const keys = await armClient.databaseAccounts.listKeys(resourceGroupName, accountName);
|
||||
// const dbId = generateUniqueName("db");
|
||||
// const collectionId = "testcollection";
|
||||
// const client = new CosmosClient({
|
||||
// endpoint: account.documentEndpoint!,
|
||||
// key: keys.primaryMasterKey,
|
||||
// });
|
||||
// const { database } = await client.databases.createIfNotExists({ id: dbId });
|
||||
// const { container } = await database.containers.createIfNotExists({ id: collectionId });
|
||||
// const { user } = await database.users.upsert({ id: "testUser" });
|
||||
// const { resource: containerPermission } = await user.permissions.upsert({
|
||||
// id: "partitionLevelPermission",
|
||||
// permissionMode: PermissionMode.All,
|
||||
// resource: container.url,
|
||||
// });
|
||||
// await expect(containerPermission).toBeDefined();
|
||||
const credentials = getAzureCLICredentials();
|
||||
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
const accountName = getAccountName(TestAccount.SQL);
|
||||
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||
const keys = await armClient.databaseAccounts.listKeys(resourceGroupName, accountName);
|
||||
const dbId = generateUniqueName("db");
|
||||
const collectionId = "testcollection";
|
||||
const client = new CosmosClient({
|
||||
endpoint: account.documentEndpoint!,
|
||||
key: keys.primaryMasterKey,
|
||||
});
|
||||
const { database } = await client.databases.createIfNotExists({ id: dbId });
|
||||
const { container } = await database.containers.createIfNotExists({ id: collectionId });
|
||||
const { user } = await database.users.upsert({ id: "testUser" });
|
||||
const { resource: containerPermission } = await user.permissions.upsert({
|
||||
id: "partitionLevelPermission",
|
||||
permissionMode: PermissionMode.All,
|
||||
resource: container.url,
|
||||
});
|
||||
await expect(containerPermission).toBeDefined();
|
||||
|
||||
// const resourceTokenConnectionString = `AccountEndpoint=${account.documentEndpoint};DatabaseId=${
|
||||
// database.id
|
||||
// };CollectionId=${container.id};${containerPermission!._token}`;
|
||||
const resourceTokenConnectionString = `AccountEndpoint=${account.documentEndpoint};DatabaseId=${
|
||||
database.id
|
||||
};CollectionId=${container.id};${containerPermission!._token}`;
|
||||
|
||||
// await page.goto("https://localhost:1234/hostedExplorer.html");
|
||||
// const switchConnectionLink = page.getByTestId("Link:SwitchConnectionType");
|
||||
// await switchConnectionLink.waitFor();
|
||||
// await switchConnectionLink.click();
|
||||
// await page.getByPlaceholder("Please enter a connection string").fill(resourceTokenConnectionString);
|
||||
// await page.getByRole("button", { name: "Connect" }).click();
|
||||
await page.goto("https://localhost:1234/hostedExplorer.html");
|
||||
const switchConnectionLink = page.getByTestId("Link:SwitchConnectionType");
|
||||
await switchConnectionLink.waitFor();
|
||||
await switchConnectionLink.click();
|
||||
await page.getByPlaceholder("Please enter a connection string").fill(resourceTokenConnectionString);
|
||||
await page.getByRole("button", { name: "Connect" }).click();
|
||||
|
||||
// const explorer = await DataExplorer.waitForExplorer(page);
|
||||
const explorer = await DataExplorer.waitForExplorer(page);
|
||||
|
||||
// const collectionNode = explorer.treeNode(`${collectionId}`);
|
||||
// await collectionNode.element.waitFor();
|
||||
// await expect(collectionNode.element).toBeAttached();
|
||||
const collectionNode = explorer.treeNode(`${collectionId}`);
|
||||
await collectionNode.element.waitFor();
|
||||
await expect(collectionNode.element).toBeAttached();
|
||||
|
||||
// await database.delete();
|
||||
// });
|
||||
await database.delete();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user