mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-29 22:02:01 +00:00
Compare commits
1 Commits
master
...
users/aisa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9e81441b6 |
1
Untitled-1.txt
Normal file
1
Untitled-1.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.
|
||||||
@@ -187,7 +187,7 @@ export const PartitionKeyComponent: React.FC<PartitionKeyComponentProps> = ({
|
|||||||
<Text styles={textSubHeadingStyle}>Current {partitionKeyName.toLowerCase()}</Text>
|
<Text styles={textSubHeadingStyle}>Current {partitionKeyName.toLowerCase()}</Text>
|
||||||
<Text styles={textSubHeadingStyle}>Partitioning</Text>
|
<Text styles={textSubHeadingStyle}>Partitioning</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack tokens={{ childrenGap: 5 }} data-test="partition-key-values">
|
<Stack tokens={{ childrenGap: 5 }}>
|
||||||
<Text styles={textSubHeadingStyle1}>{partitionKeyValue}</Text>
|
<Text styles={textSubHeadingStyle1}>{partitionKeyValue}</Text>
|
||||||
<Text styles={textSubHeadingStyle1}>
|
<Text styles={textSubHeadingStyle1}>
|
||||||
{isHierarchicalPartitionedContainer() ? "Hierarchical" : "Non-hierarchical"}
|
{isHierarchicalPartitionedContainer() ? "Hierarchical" : "Non-hierarchical"}
|
||||||
@@ -199,7 +199,6 @@ export const PartitionKeyComponent: React.FC<PartitionKeyComponentProps> = ({
|
|||||||
{!isReadOnly && (
|
{!isReadOnly && (
|
||||||
<>
|
<>
|
||||||
<MessageBar
|
<MessageBar
|
||||||
data-test="partition-key-warning"
|
|
||||||
messageBarType={MessageBarType.warning}
|
messageBarType={MessageBarType.warning}
|
||||||
messageBarIconProps={{ iconName: "WarningSolid", className: "messageBarWarningIcon" }}
|
messageBarIconProps={{ iconName: "WarningSolid", className: "messageBarWarningIcon" }}
|
||||||
styles={darkThemeMessageBarStyles}
|
styles={darkThemeMessageBarStyles}
|
||||||
@@ -221,7 +220,6 @@ export const PartitionKeyComponent: React.FC<PartitionKeyComponentProps> = ({
|
|||||||
</Text>
|
</Text>
|
||||||
{configContext.platform !== Platform.Emulator && (
|
{configContext.platform !== Platform.Emulator && (
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
data-test="change-partition-key-button"
|
|
||||||
styles={{ root: { width: "fit-content" } }}
|
styles={{ root: { width: "fit-content" } }}
|
||||||
text="Change"
|
text="Change"
|
||||||
onClick={startPartitionkeyChangeWorkflow}
|
onClick={startPartitionkeyChangeWorkflow}
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ exports[`PartitionKeyComponent renders default component and matches snapshot 1`
|
|||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
data-test="partition-key-values"
|
|
||||||
tokens={
|
tokens={
|
||||||
{
|
{
|
||||||
"childrenGap": 5,
|
"childrenGap": 5,
|
||||||
@@ -109,7 +108,6 @@ exports[`PartitionKeyComponent renders default component and matches snapshot 1`
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<StyledMessageBar
|
<StyledMessageBar
|
||||||
data-test="partition-key-warning"
|
|
||||||
messageBarIconProps={
|
messageBarIconProps={
|
||||||
{
|
{
|
||||||
"className": "messageBarWarningIcon",
|
"className": "messageBarWarningIcon",
|
||||||
@@ -162,7 +160,6 @@ exports[`PartitionKeyComponent renders default component and matches snapshot 1`
|
|||||||
To change the partition key, a new destination container must be created or an existing destination container selected. Data will then be copied to the destination container.
|
To change the partition key, a new destination container must be created or an existing destination container selected. Data will then be copied to the destination container.
|
||||||
</Text>
|
</Text>
|
||||||
<CustomizedPrimaryButton
|
<CustomizedPrimaryButton
|
||||||
data-test="change-partition-key-button"
|
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
styles={
|
styles={
|
||||||
{
|
{
|
||||||
@@ -240,7 +237,6 @@ exports[`PartitionKeyComponent renders read-only component and matches snapshot
|
|||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
data-test="partition-key-values"
|
|
||||||
tokens={
|
tokens={
|
||||||
{
|
{
|
||||||
"childrenGap": 5,
|
"childrenGap": 5,
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</Stack>
|
</Stack>
|
||||||
{createNewContainer ? (
|
{createNewContainer ? (
|
||||||
<Stack data-test="create-new-container-form">
|
<Stack>
|
||||||
<MessageBar>All configurations except for unique keys will be copied from the source container</MessageBar>
|
<MessageBar>All configurations except for unique keys will be copied from the source container</MessageBar>
|
||||||
<Stack className="panelGroupSpacing">
|
<Stack className="panelGroupSpacing">
|
||||||
<Stack horizontal>
|
<Stack horizontal>
|
||||||
@@ -230,7 +230,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
</TooltipHost>
|
</TooltipHost>
|
||||||
</Stack>
|
</Stack>
|
||||||
<input
|
<input
|
||||||
data-test="new-container-id-input"
|
|
||||||
name="collectionId"
|
name="collectionId"
|
||||||
id="collectionId"
|
id="collectionId"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -272,7 +271,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
data-test="new-container-partition-key-input"
|
|
||||||
id="addCollection-partitionKeyValue"
|
id="addCollection-partitionKeyValue"
|
||||||
aria-required
|
aria-required
|
||||||
required
|
required
|
||||||
@@ -306,7 +304,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
type="text"
|
type="text"
|
||||||
id="addCollection-partitionKeyValue"
|
id="addCollection-partitionKeyValue"
|
||||||
key={`addCollection-partitionKeyValue_${index}`}
|
key={`addCollection-partitionKeyValue_${index}`}
|
||||||
data-test={`new-container-sub-partition-key-input-${index}`}
|
|
||||||
aria-required
|
aria-required
|
||||||
required
|
required
|
||||||
size={40}
|
size={40}
|
||||||
@@ -330,8 +327,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
data-test={`remove-sub-partition-key-button-${index}`}
|
|
||||||
ariaLabel="Remove hierarchical partition key"
|
|
||||||
iconProps={{ iconName: "Delete" }}
|
iconProps={{ iconName: "Delete" }}
|
||||||
style={{ height: 27 }}
|
style={{ height: 27 }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -344,7 +339,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
})}
|
})}
|
||||||
<Stack className="panelGroupSpacing">
|
<Stack className="panelGroupSpacing">
|
||||||
<DefaultButton
|
<DefaultButton
|
||||||
data-test="add-sub-partition-key-button"
|
|
||||||
styles={{ root: { padding: 0, width: 200, height: 30 }, label: { fontSize: 12 } }}
|
styles={{ root: { padding: 0, width: 200, height: 30 }, label: { fontSize: 12 } }}
|
||||||
disabled={subPartitionKeys.length >= Constants.BackendDefaults.maxNumMultiHashPartition}
|
disabled={subPartitionKeys.length >= Constants.BackendDefaults.maxNumMultiHashPartition}
|
||||||
onClick={() => setSubPartitionKeys([...subPartitionKeys, ""])}
|
onClick={() => setSubPartitionKeys([...subPartitionKeys, ""])}
|
||||||
@@ -352,11 +346,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
Add hierarchical partition key
|
Add hierarchical partition key
|
||||||
</DefaultButton>
|
</DefaultButton>
|
||||||
{subPartitionKeys.length > 0 && (
|
{subPartitionKeys.length > 0 && (
|
||||||
<Text
|
<Text variant="small" style={{ color: "var(--colorNeutralForeground1)" }}>
|
||||||
data-test="hierarchical-partitioning-info-text"
|
|
||||||
variant="small"
|
|
||||||
style={{ color: "var(--colorNeutralForeground1)" }}
|
|
||||||
>
|
|
||||||
<Icon iconName="InfoSolid" className="removeIcon" tabIndex={0} /> This feature allows you to
|
<Icon iconName="InfoSolid" className="removeIcon" tabIndex={0} /> This feature allows you to
|
||||||
partition your data with up to three levels of keys for better data distribution. Requires .NET V3,
|
partition your data with up to three levels of keys for better data distribution. Requires .NET V3,
|
||||||
Java V4 SDK, or preview JavaScript V3 SDK.{" "}
|
Java V4 SDK, or preview JavaScript V3 SDK.{" "}
|
||||||
@@ -369,7 +359,7 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Stack data-test="use-existing-container-form">
|
<Stack>
|
||||||
<Stack horizontal>
|
<Stack horizontal>
|
||||||
<span className="mandatoryStar">* </span>
|
<span className="mandatoryStar">* </span>
|
||||||
<Text className="panelTextBold" variant="small">
|
<Text className="panelTextBold" variant="small">
|
||||||
@@ -400,7 +390,6 @@ export const ChangePartitionKeyPane: React.FC<ChangePartitionKeyPaneProps> = ({
|
|||||||
}}
|
}}
|
||||||
defaultSelectedKey={targetCollectionId}
|
defaultSelectedKey={targetCollectionId}
|
||||||
responsiveMode={999}
|
responsiveMode={999}
|
||||||
ariaLabel="Existing Containers"
|
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -125,10 +125,7 @@ const App = (): JSX.Element => {
|
|||||||
<KeyboardShortcutRoot>
|
<KeyboardShortcutRoot>
|
||||||
<div className="flexContainer" aria-hidden="false">
|
<div className="flexContainer" aria-hidden="false">
|
||||||
{userContext.features.enableContainerCopy && userContext.apiType === "SQL" ? (
|
{userContext.features.enableContainerCopy && userContext.apiType === "SQL" ? (
|
||||||
<>
|
<ContainerCopyPanel explorer={explorer} />
|
||||||
<ContainerCopyPanel explorer={explorer} />
|
|
||||||
<SidePanel />
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
<DivExplorer explorer={explorer} />
|
<DivExplorer explorer={explorer} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -470,15 +470,6 @@ export class DataExplorer {
|
|||||||
return this.frame.getByTestId("notification-console/header-status");
|
return this.frame.getByTestId("notification-console/header-status");
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDropdownItemByName(name: string, ariaLabel?: string): Promise<Locator> {
|
|
||||||
const dropdownItemsWrapper = this.frame.locator("div.ms-Dropdown-items");
|
|
||||||
if (ariaLabel) {
|
|
||||||
expect(await dropdownItemsWrapper.getAttribute("aria-label")).toEqual(ariaLabel);
|
|
||||||
}
|
|
||||||
const containerDropdownItems = dropdownItemsWrapper.locator("button.ms-Dropdown-item[role='option']");
|
|
||||||
return containerDropdownItems.filter({ hasText: name });
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Waits for the Data Explorer app to load */
|
/** Waits for the Data Explorer app to load */
|
||||||
static async waitForExplorer(page: Page) {
|
static async waitForExplorer(page: Page) {
|
||||||
const iframeElement = await page.getByTestId("DataExplorerFrame").elementHandle();
|
const iframeElement = await page.getByTestId("DataExplorerFrame").elementHandle();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ let queryTab: QueryTab = null!;
|
|||||||
let queryEditor: Editor = null!;
|
let queryEditor: Editor = null!;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer({ includeTestData: true });
|
context = await createTestSQLContainer(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open new query tab", async ({ page }) => {
|
test.beforeEach("Open new query tab", async ({ page }) => {
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
import { expect, Page, test } from "@playwright/test";
|
|
||||||
import { DataExplorer, TestAccount } from "../../fx";
|
|
||||||
import { createTestSQLContainer, TestContainerContext } from "../../testData";
|
|
||||||
|
|
||||||
test.describe("Change Partition Key", () => {
|
|
||||||
let pageInstance: Page;
|
|
||||||
let context: TestContainerContext = null!;
|
|
||||||
let explorer: DataExplorer = null!;
|
|
||||||
const newPartitionKeyPath = "/newPartitionKey";
|
|
||||||
const newContainerId = "testcontainer_1";
|
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
|
||||||
context = await createTestSQLContainer();
|
|
||||||
});
|
|
||||||
|
|
||||||
test.beforeEach("Open container settings", async ({ page }) => {
|
|
||||||
pageInstance = page;
|
|
||||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
|
||||||
|
|
||||||
// Click Scale & Settings and open Partition Key tab
|
|
||||||
await explorer.openScaleAndSettings(context);
|
|
||||||
const PartitionKeyTab = explorer.frame.getByTestId("settings-tab-header/PartitionKeyTab");
|
|
||||||
await PartitionKeyTab.click();
|
|
||||||
});
|
|
||||||
|
|
||||||
test.afterAll("Delete Test Database", async () => {
|
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Change partition key path", async () => {
|
|
||||||
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
|
|
||||||
await expect(explorer.frame.getByText("Change partition key")).toBeVisible();
|
|
||||||
await expect(explorer.frame.getByText(/To safeguard the integrity of/)).toBeVisible();
|
|
||||||
await expect(explorer.frame.getByText(/To change the partition key/)).toBeVisible();
|
|
||||||
|
|
||||||
const changePartitionKeyButton = explorer.frame.getByTestId("change-partition-key-button");
|
|
||||||
expect(changePartitionKeyButton).toBeVisible();
|
|
||||||
await changePartitionKeyButton.click();
|
|
||||||
|
|
||||||
// Fill out new partition key form in the panel
|
|
||||||
const changePkPanel = explorer.frame.getByTestId(`Panel:Change partition key`);
|
|
||||||
await expect(changePkPanel.getByText(context.database.id)).toBeVisible();
|
|
||||||
await expect(explorer.frame.getByRole("heading", { name: "Change partition key" })).toBeVisible();
|
|
||||||
await expect(explorer.frame.getByText(/When changing a container/)).toBeVisible();
|
|
||||||
|
|
||||||
// Try to switch to new container
|
|
||||||
await expect(changePkPanel.getByText("New container")).toBeVisible();
|
|
||||||
await expect(changePkPanel.getByText("Existing container")).toBeVisible();
|
|
||||||
await expect(changePkPanel.getByTestId("new-container-id-input")).toBeVisible();
|
|
||||||
|
|
||||||
changePkPanel.getByTestId("new-container-id-input").fill(newContainerId);
|
|
||||||
await expect(changePkPanel.getByTestId("new-container-partition-key-input")).toBeVisible();
|
|
||||||
changePkPanel.getByTestId("new-container-partition-key-input").fill(newPartitionKeyPath);
|
|
||||||
|
|
||||||
await expect(changePkPanel.getByTestId("add-sub-partition-key-button")).toBeVisible();
|
|
||||||
changePkPanel.getByTestId("add-sub-partition-key-button").click();
|
|
||||||
await expect(changePkPanel.getByTestId("new-container-sub-partition-key-input-0")).toBeVisible();
|
|
||||||
await expect(changePkPanel.getByTestId("remove-sub-partition-key-button-0")).toBeVisible();
|
|
||||||
await expect(changePkPanel.getByTestId("hierarchical-partitioning-info-text")).toBeVisible();
|
|
||||||
changePkPanel.getByTestId("new-container-sub-partition-key-input-0").fill("/customerId");
|
|
||||||
|
|
||||||
await changePkPanel.getByTestId("Panel/OkButton").click();
|
|
||||||
|
|
||||||
await pageInstance.waitForLoadState("networkidle");
|
|
||||||
await expect(changePkPanel).not.toBeVisible({ timeout: 60 * 1000 });
|
|
||||||
|
|
||||||
// Verify partition key change job
|
|
||||||
const jobText = explorer.frame.getByText(/Partition key change job/);
|
|
||||||
await expect(jobText).toBeVisible();
|
|
||||||
await expect(explorer.frame.locator(".ms-ProgressIndicator-itemName")).toContainText("Portal_testcontainer_1");
|
|
||||||
|
|
||||||
const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription");
|
|
||||||
await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 30 * 1000 });
|
|
||||||
|
|
||||||
const newContainerNode = await explorer.waitForContainerNode(context.database.id, newContainerId);
|
|
||||||
expect(newContainerNode).not.toBeNull();
|
|
||||||
|
|
||||||
// Now try to switch to existing container
|
|
||||||
await changePartitionKeyButton.click();
|
|
||||||
await changePkPanel.getByText("Existing container").click();
|
|
||||||
await changePkPanel.getByLabel("Use existing container").check();
|
|
||||||
await changePkPanel.getByText("Choose an existing container").click();
|
|
||||||
|
|
||||||
const containerDropdownItem = await explorer.getDropdownItemByName(newContainerId, "Existing Containers");
|
|
||||||
await containerDropdownItem.click();
|
|
||||||
|
|
||||||
await changePkPanel.getByTestId("Panel/OkButton").click();
|
|
||||||
await explorer.frame.getByRole("button", { name: "Cancel" }).click();
|
|
||||||
|
|
||||||
// Dismiss overlay if it appears
|
|
||||||
const overlayFrame = explorer.frame.locator("#webpack-dev-server-client-overlay").first();
|
|
||||||
if (await overlayFrame.count()) {
|
|
||||||
await overlayFrame.contentFrame().getByLabel("Dismiss").click();
|
|
||||||
}
|
|
||||||
const cancelledJobRow = explorer.frame.getByTestId("Tab:tab0");
|
|
||||||
await expect(cancelledJobRow.getByText("Cancelled")).toBeVisible({ timeout: 30 * 1000 });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -14,7 +14,7 @@ test.describe("Autoscale and Manual throughput", () => {
|
|||||||
let explorer: DataExplorer = null!;
|
let explorer: DataExplorer = null!;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer({ includeTestData: true });
|
context = await createTestSQLContainer(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open container settings", async ({ page }) => {
|
test.beforeEach("Open container settings", async ({ page }) => {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ test.describe("Settings under Scale & Settings", () => {
|
|||||||
let explorer: DataExplorer = null!;
|
let explorer: DataExplorer = null!;
|
||||||
|
|
||||||
test.beforeAll("Create Test Database", async () => {
|
test.beforeAll("Create Test Database", async () => {
|
||||||
context = await createTestSQLContainer({ includeTestData: true });
|
context = await createTestSQLContainer(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => {
|
test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => {
|
||||||
|
|||||||
@@ -74,18 +74,8 @@ export class TestContainerContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type createTestSqlContainerConfig = {
|
export async function createTestSQLContainer(includeTestData?: boolean) {
|
||||||
includeTestData?: boolean;
|
const databaseId = generateUniqueName("db");
|
||||||
partitionKey?: string;
|
|
||||||
databaseName?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function createTestSQLContainer({
|
|
||||||
includeTestData = false,
|
|
||||||
partitionKey = "/partitionKey",
|
|
||||||
databaseName = "",
|
|
||||||
}: createTestSqlContainerConfig = {}) {
|
|
||||||
const databaseId = databaseName ? databaseName : generateUniqueName("db");
|
|
||||||
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
|
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
|
||||||
const credentials = getAzureCLICredentials();
|
const credentials = getAzureCLICredentials();
|
||||||
const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials);
|
const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials);
|
||||||
@@ -114,7 +104,7 @@ export async function createTestSQLContainer({
|
|||||||
try {
|
try {
|
||||||
const { container } = await database.containers.createIfNotExists({
|
const { container } = await database.containers.createIfNotExists({
|
||||||
id: containerId,
|
id: containerId,
|
||||||
partitionKey,
|
partitionKey: "/partitionKey",
|
||||||
});
|
});
|
||||||
if (includeTestData) {
|
if (includeTestData) {
|
||||||
const batchCount = TestData.length / 100;
|
const batchCount = TestData.length / 100;
|
||||||
|
|||||||
Reference in New Issue
Block a user