mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-28 13:21:42 +00:00
Compare commits
16 Commits
master
...
users/aisa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc43d3afbb | ||
|
|
6691974127 | ||
|
|
37a5663bad | ||
|
|
31c9574df4 | ||
|
|
2e8e02f75b | ||
|
|
8809ba6cd2 | ||
|
|
592f2cd7e6 | ||
|
|
d966f4f2a7 | ||
|
|
4801aae754 | ||
|
|
2a02112d87 | ||
|
|
bbfff77495 | ||
|
|
f695b42071 | ||
|
|
a8a96e22b4 | ||
|
|
a1b026544d | ||
|
|
a912233b33 | ||
|
|
487130f6e3 |
@@ -28,6 +28,7 @@ export async function deleteStoredProcedure(
|
|||||||
} else {
|
} else {
|
||||||
await client().database(databaseId).container(collectionId).scripts.storedProcedure(storedProcedureId).delete();
|
await client().database(databaseId).container(collectionId).scripts.storedProcedure(storedProcedureId).delete();
|
||||||
}
|
}
|
||||||
|
logConsoleProgress(`Successfully deleted stored procedure ${storedProcedureId}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "DeleteStoredProcedure", `Error while deleting stored procedure ${storedProcedureId}`);
|
handleError(error, "DeleteStoredProcedure", `Error while deleting stored procedure ${storedProcedureId}`);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export async function deleteUserDefinedFunction(databaseId: string, collectionId
|
|||||||
} else {
|
} else {
|
||||||
await client().database(databaseId).container(collectionId).scripts.userDefinedFunction(id).delete();
|
await client().database(databaseId).container(collectionId).scripts.userDefinedFunction(id).delete();
|
||||||
}
|
}
|
||||||
|
logConsoleProgress(`Successfully deleted user defined function ${id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "DeleteUserDefinedFunction", `Error while deleting user defined function ${id}`);
|
handleError(error, "DeleteUserDefinedFunction", `Error while deleting user defined function ${id}`);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -155,7 +155,12 @@ export class ComputedPropertiesComponent extends React.Component<
|
|||||||
</Link>
|
</Link>
|
||||||
  about how to define computed properties and how to use them.
|
  about how to define computed properties and how to use them.
|
||||||
</Text>
|
</Text>
|
||||||
<div className="settingsV2Editor" tabIndex={0} ref={this.computedPropertiesDiv}></div>
|
<div
|
||||||
|
className="settingsV2Editor"
|
||||||
|
tabIndex={0}
|
||||||
|
ref={this.computedPropertiesDiv}
|
||||||
|
data-test="computed-properties-editor"
|
||||||
|
></div>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,8 +302,8 @@ export class SubSettingsComponent extends React.Component<SubSettingsComponentPr
|
|||||||
);
|
);
|
||||||
|
|
||||||
private geoSpatialConfigTypeChoiceGroupOptions: IChoiceGroupOption[] = [
|
private geoSpatialConfigTypeChoiceGroupOptions: IChoiceGroupOption[] = [
|
||||||
{ key: GeospatialConfigType.Geography, text: "Geography" },
|
{ key: GeospatialConfigType.Geography, text: "Geography", ariaLabel: "geography-option" },
|
||||||
{ key: GeospatialConfigType.Geometry, text: "Geometry" },
|
{ key: GeospatialConfigType.Geometry, text: "Geometry", ariaLabel: "geometry-option" },
|
||||||
];
|
];
|
||||||
|
|
||||||
private getGeoSpatialComponent = (): JSX.Element => (
|
private getGeoSpatialComponent = (): JSX.Element => (
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ exports[`ComputedPropertiesComponent renders 1`] = `
|
|||||||
</Text>
|
</Text>
|
||||||
<div
|
<div
|
||||||
className="settingsV2Editor"
|
className="settingsV2Editor"
|
||||||
|
data-test="computed-properties-editor"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -167,10 +167,12 @@ exports[`SubSettingsComponent analyticalTimeToLive hidden 1`] = `
|
|||||||
options={
|
options={
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geography-option",
|
||||||
"key": "Geography",
|
"key": "Geography",
|
||||||
"text": "Geography",
|
"text": "Geography",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geometry-option",
|
||||||
"key": "Geometry",
|
"key": "Geometry",
|
||||||
"text": "Geometry",
|
"text": "Geometry",
|
||||||
},
|
},
|
||||||
@@ -652,10 +654,12 @@ exports[`SubSettingsComponent analyticalTimeToLiveSeconds hidden 1`] = `
|
|||||||
options={
|
options={
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geography-option",
|
||||||
"key": "Geography",
|
"key": "Geography",
|
||||||
"text": "Geography",
|
"text": "Geography",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geometry-option",
|
||||||
"key": "Geometry",
|
"key": "Geometry",
|
||||||
"text": "Geometry",
|
"text": "Geometry",
|
||||||
},
|
},
|
||||||
@@ -1224,10 +1228,12 @@ exports[`SubSettingsComponent changeFeedPolicy hidden 1`] = `
|
|||||||
options={
|
options={
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geography-option",
|
||||||
"key": "Geography",
|
"key": "Geography",
|
||||||
"text": "Geography",
|
"text": "Geography",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geometry-option",
|
||||||
"key": "Geometry",
|
"key": "Geometry",
|
||||||
"text": "Geometry",
|
"text": "Geometry",
|
||||||
},
|
},
|
||||||
@@ -1760,10 +1766,12 @@ exports[`SubSettingsComponent renders 1`] = `
|
|||||||
options={
|
options={
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geography-option",
|
||||||
"key": "Geography",
|
"key": "Geography",
|
||||||
"text": "Geography",
|
"text": "Geography",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geometry-option",
|
||||||
"key": "Geometry",
|
"key": "Geometry",
|
||||||
"text": "Geometry",
|
"text": "Geometry",
|
||||||
},
|
},
|
||||||
@@ -2330,10 +2338,12 @@ exports[`SubSettingsComponent timeToLiveSeconds hidden 1`] = `
|
|||||||
options={
|
options={
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geography-option",
|
||||||
"key": "Geography",
|
"key": "Geography",
|
||||||
"text": "Geography",
|
"text": "Geography",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"ariaLabel": "geometry-option",
|
||||||
"key": "Geometry",
|
"key": "Geometry",
|
||||||
"text": "Geometry",
|
"text": "Geometry",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ export const UploadItemsPane: FunctionComponent<UploadItemsPaneProps> = ({ onUpl
|
|||||||
tooltip="Select one or more JSON files to upload. Each file can contain a single JSON document or an array of JSON documents. The combined size of all files in an individual upload operation must be less than 2 MB. You can perform multiple upload operations for larger data sets."
|
tooltip="Select one or more JSON files to upload. Each file can contain a single JSON document or an array of JSON documents. The combined size of all files in an individual upload operation must be less than 2 MB. You can perform multiple upload operations for larger data sets."
|
||||||
/>
|
/>
|
||||||
{uploadFileData?.length > 0 && (
|
{uploadFileData?.length > 0 && (
|
||||||
<div className="fileUploadSummaryContainer">
|
<div className="fileUploadSummaryContainer" data-test="file-upload-status">
|
||||||
<b style={{ color: "var(--colorNeutralForeground1)" }}>File upload status</b>
|
<b style={{ color: "var(--colorNeutralForeground1)" }}>File upload status</b>
|
||||||
<DetailsList
|
<DetailsList
|
||||||
items={uploadFileData}
|
items={uploadFileData}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Resource, StoredProcedureDefinition } from "@azure/cosmos";
|
import { Resource, StoredProcedureDefinition } from "@azure/cosmos";
|
||||||
import { Pivot, PivotItem } from "@fluentui/react";
|
import { Pivot, PivotItem } from "@fluentui/react";
|
||||||
import { KeyboardAction } from "KeyboardShortcuts";
|
import { KeyboardAction } from "KeyboardShortcuts";
|
||||||
|
import { logConsoleInfo } from "Utils/NotificationConsoleUtils";
|
||||||
import { ValidCosmosDbIdDescription, ValidCosmosDbIdInputPattern } from "Utils/ValidationUtils";
|
import { ValidCosmosDbIdDescription, ValidCosmosDbIdInputPattern } from "Utils/ValidationUtils";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ExecuteQueryIcon from "../../../../images/ExecuteQuery.svg";
|
import ExecuteQueryIcon from "../../../../images/ExecuteQuery.svg";
|
||||||
@@ -435,7 +436,7 @@ export default class StoredProcedureTabComponent extends React.Component<
|
|||||||
});
|
});
|
||||||
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
||||||
}, 100);
|
}, 100);
|
||||||
|
logConsoleInfo(`Sucessfully created stored procedure ${createdResource.id}`);
|
||||||
return createdResource;
|
return createdResource;
|
||||||
},
|
},
|
||||||
(createError) => {
|
(createError) => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { UserDefinedFunctionDefinition } from "@azure/cosmos";
|
|||||||
import { Label, TextField } from "@fluentui/react";
|
import { Label, TextField } from "@fluentui/react";
|
||||||
import { FluentProvider, webDarkTheme, webLightTheme } from "@fluentui/react-components";
|
import { FluentProvider, webDarkTheme, webLightTheme } from "@fluentui/react-components";
|
||||||
import { KeyboardAction } from "KeyboardShortcuts";
|
import { KeyboardAction } from "KeyboardShortcuts";
|
||||||
|
import { logConsoleInfo } from "Utils/NotificationConsoleUtils";
|
||||||
import { ValidCosmosDbIdDescription, ValidCosmosDbIdInputPattern } from "Utils/ValidationUtils";
|
import { ValidCosmosDbIdDescription, ValidCosmosDbIdInputPattern } from "Utils/ValidationUtils";
|
||||||
import { useThemeStore } from "hooks/useTheme";
|
import { useThemeStore } from "hooks/useTheme";
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
@@ -170,6 +171,7 @@ export default class UserDefinedFunctionTabContent extends Component<
|
|||||||
startKey,
|
startKey,
|
||||||
);
|
);
|
||||||
this.props.editorState(ViewModels.ScriptEditorState.existingNoEdits);
|
this.props.editorState(ViewModels.ScriptEditorState.existingNoEdits);
|
||||||
|
logConsoleInfo(`Sucessfully created user defined function ${createdResource.id}`);
|
||||||
}
|
}
|
||||||
} catch (createError) {
|
} catch (createError) {
|
||||||
this.props.isExecutionError(true);
|
this.props.isExecutionError(true);
|
||||||
|
|||||||
@@ -325,7 +325,9 @@ type PanelOpenOptions = {
|
|||||||
|
|
||||||
export enum CommandBarButton {
|
export enum CommandBarButton {
|
||||||
Save = "Save",
|
Save = "Save",
|
||||||
|
Execute = "Execute",
|
||||||
ExecuteQuery = "Execute Query",
|
ExecuteQuery = "Execute Query",
|
||||||
|
UploadItem = "Upload Item",
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper class that provides locator methods for DataExplorer components, on top of a Frame */
|
/** Helper class that provides locator methods for DataExplorer components, on top of a Frame */
|
||||||
|
|||||||
@@ -1,7 +1,17 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
|
||||||
import { DataExplorer, DocumentsTab, TestAccount } from "../fx";
|
import { existsSync, unlinkSync, writeFileSync } from "fs";
|
||||||
import { retry, setPartitionKeys } from "../testData";
|
import path from "path";
|
||||||
|
import { CommandBarButton, DataExplorer, DocumentsTab, ONE_MINUTE_MS, TestAccount } from "../fx";
|
||||||
|
import {
|
||||||
|
createTestSQLContainer,
|
||||||
|
itemsPerPartition,
|
||||||
|
partitionCount,
|
||||||
|
retry,
|
||||||
|
setPartitionKeys,
|
||||||
|
TestContainerContext,
|
||||||
|
TestData,
|
||||||
|
} from "../testData";
|
||||||
import { documentTestCases } from "./testCases";
|
import { documentTestCases } from "./testCases";
|
||||||
|
|
||||||
let explorer: DataExplorer = null!;
|
let explorer: DataExplorer = null!;
|
||||||
@@ -95,3 +105,108 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test.describe.serial("Upload Item", () => {
|
||||||
|
let context: TestContainerContext = null!;
|
||||||
|
const uploadDocumentFilePath: string = path.join(__dirname, "uploadDocument.json");
|
||||||
|
|
||||||
|
test.beforeEach("Create Test Database and Open documents tab", async ({ page }) => {
|
||||||
|
context = await createTestSQLContainer();
|
||||||
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
|
|
||||||
|
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
|
||||||
|
await containerNode.expand();
|
||||||
|
|
||||||
|
const containerMenuNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id);
|
||||||
|
await containerMenuNode.element.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterEach("Delete Test Database and uploadDocument.json", async () => {
|
||||||
|
if (existsSync(uploadDocumentFilePath)) {
|
||||||
|
unlinkSync(uploadDocumentFilePath);
|
||||||
|
}
|
||||||
|
await context?.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("upload document", async () => {
|
||||||
|
// Create file to upload
|
||||||
|
const TestDataJsonString: string = JSON.stringify(TestData, null, 2);
|
||||||
|
writeFileSync(uploadDocumentFilePath, TestDataJsonString);
|
||||||
|
|
||||||
|
const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem);
|
||||||
|
await uploadItemCommandBar.click();
|
||||||
|
|
||||||
|
// Select file to upload
|
||||||
|
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
|
||||||
|
|
||||||
|
const uploadButton = explorer.frame.getByTestId("Panel/OkButton");
|
||||||
|
await uploadButton.click();
|
||||||
|
|
||||||
|
// Verify upload success message
|
||||||
|
const fileUploadStatusExpected: string = `${partitionCount * itemsPerPartition} created, 0 throttled, 0 errors`;
|
||||||
|
const fileUploadStatus = explorer.frame.getByTestId("file-upload-status");
|
||||||
|
await expect(fileUploadStatus).toContainText(fileUploadStatusExpected, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("upload same document twice", async () => {
|
||||||
|
// Create file to upload
|
||||||
|
const TestDataJsonString: string = JSON.stringify(TestData, null, 2);
|
||||||
|
writeFileSync(uploadDocumentFilePath, TestDataJsonString);
|
||||||
|
|
||||||
|
const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem);
|
||||||
|
await uploadItemCommandBar.click();
|
||||||
|
|
||||||
|
// Select file to upload
|
||||||
|
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
|
||||||
|
|
||||||
|
const uploadButton = explorer.frame.getByTestId("Panel/OkButton");
|
||||||
|
await uploadButton.click();
|
||||||
|
|
||||||
|
// Verify upload success message
|
||||||
|
const fileUploadStatusExpected: string = `${partitionCount * itemsPerPartition} created, 0 throttled, 0 errors`;
|
||||||
|
const fileUploadStatus = explorer.frame.getByTestId("file-upload-status");
|
||||||
|
await expect(fileUploadStatus).toContainText(fileUploadStatusExpected, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select file to upload again
|
||||||
|
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
|
||||||
|
await uploadButton.click();
|
||||||
|
|
||||||
|
// Verify upload failure message
|
||||||
|
const errorIcon = explorer.frame.getByRole("img", { name: "error" });
|
||||||
|
await expect(errorIcon).toBeVisible({ timeout: ONE_MINUTE_MS });
|
||||||
|
await expect(fileUploadStatus).toContainText(
|
||||||
|
`0 created, 0 throttled, ${partitionCount * itemsPerPartition} errors`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("upload invalid json", async () => {
|
||||||
|
// Create file to upload
|
||||||
|
let TestDataJsonString: string = JSON.stringify(TestData, null, 2);
|
||||||
|
// Remove the first '[' so that it becomes invalid json
|
||||||
|
TestDataJsonString = TestDataJsonString.substring(1);
|
||||||
|
writeFileSync(uploadDocumentFilePath, TestDataJsonString);
|
||||||
|
|
||||||
|
const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem);
|
||||||
|
await uploadItemCommandBar.click();
|
||||||
|
|
||||||
|
// Select file to upload
|
||||||
|
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
|
||||||
|
|
||||||
|
const uploadButton = explorer.frame.getByTestId("Panel/OkButton");
|
||||||
|
await uploadButton.click();
|
||||||
|
|
||||||
|
// Verify upload failure message
|
||||||
|
const fileUploadStatusExpected: string = "Unexpected non-whitespace character after JSON";
|
||||||
|
const fileUploadErrorList = explorer.frame.getByLabel("error list");
|
||||||
|
await expect(fileUploadErrorList).toContainText(fileUploadStatusExpected, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
103
test/sql/scaleAndSettings/computedProperties.spec.ts
Normal file
103
test/sql/scaleAndSettings/computedProperties.spec.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import { expect, test } from "@playwright/test";
|
||||||
|
import * as DataModels from "../../../src/Contracts/DataModels";
|
||||||
|
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx";
|
||||||
|
import { createTestSQLContainer, TestContainerContext } from "../../testData";
|
||||||
|
|
||||||
|
test.describe("Computed Properties", () => {
|
||||||
|
let context: TestContainerContext = null!;
|
||||||
|
let explorer: DataExplorer = null!;
|
||||||
|
|
||||||
|
test.beforeAll("Create Test Database", async () => {
|
||||||
|
context = await createTestSQLContainer(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => {
|
||||||
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
|
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
|
||||||
|
await containerNode.expand();
|
||||||
|
|
||||||
|
// Click Scale & Settings and open Settings tab
|
||||||
|
await explorer.openScaleAndSettings(context);
|
||||||
|
const computedPropertiesTab = explorer.frame.getByTestId("settings-tab-header/ComputedPropertiesTab");
|
||||||
|
await computedPropertiesTab.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll("Delete Test Database", async () => {
|
||||||
|
await context?.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Add valid computed property", async ({ page }) => {
|
||||||
|
await clearComputedPropertiesTextBoxContent({ page });
|
||||||
|
|
||||||
|
// Create computed property
|
||||||
|
const computedProperties: DataModels.ComputedProperties = [
|
||||||
|
{
|
||||||
|
name: "cp_lowerName",
|
||||||
|
query: "SELECT VALUE LOWER(c.name) FROM c",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const computedPropertiesString: string = JSON.stringify(computedProperties);
|
||||||
|
await page.keyboard.type(computedPropertiesString);
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||||
|
await expect(saveButton).toBeEnabled();
|
||||||
|
await saveButton.click();
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(`Successfully updated container ${context.container.id}`, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Add computed property with invalid query", async ({ page }) => {
|
||||||
|
await clearComputedPropertiesTextBoxContent({ page });
|
||||||
|
|
||||||
|
// Create computed property with no VALUE keyword in query
|
||||||
|
const computedProperties: DataModels.ComputedProperties = [
|
||||||
|
{
|
||||||
|
name: "cp_lowerName",
|
||||||
|
query: "SELECT LOWER(c.name) FROM c",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const computedPropertiesString: string = JSON.stringify(computedProperties);
|
||||||
|
await page.keyboard.type(computedPropertiesString);
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||||
|
await expect(saveButton).toBeEnabled();
|
||||||
|
await saveButton.click();
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(`Failed to update container ${context.container.id}`, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Add computed property with invalid json", async ({ page }) => {
|
||||||
|
await clearComputedPropertiesTextBoxContent({ page });
|
||||||
|
|
||||||
|
// Create computed property with no VALUE keyword in query
|
||||||
|
const computedProperties: DataModels.ComputedProperties = [
|
||||||
|
{
|
||||||
|
name: "cp_lowerName",
|
||||||
|
query: "SELECT LOWER(c.name) FROM c",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const computedPropertiesString: string = JSON.stringify(computedProperties);
|
||||||
|
await page.keyboard.type(computedPropertiesString + "]");
|
||||||
|
|
||||||
|
// Save button should remain disabled due to invalid json
|
||||||
|
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||||
|
await expect(saveButton).toBeDisabled();
|
||||||
|
});
|
||||||
|
|
||||||
|
const clearComputedPropertiesTextBoxContent = async ({ page }): Promise<void> => {
|
||||||
|
// Get computed properties text box
|
||||||
|
const computedPropertiesTextBox = explorer.frame.getByRole("textbox", { name: "Computed properties" });
|
||||||
|
await computedPropertiesTextBox.waitFor();
|
||||||
|
const computedPropertiesEditor = explorer.frame.getByTestId("computed-properties-editor");
|
||||||
|
await computedPropertiesEditor.click();
|
||||||
|
|
||||||
|
// Clear existing content
|
||||||
|
const isMac: boolean = process.platform === "darwin";
|
||||||
|
await page.keyboard.press(isMac ? "Meta+A" : "Control+A");
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -15,7 +15,7 @@ test.describe("Settings under Scale & Settings", () => {
|
|||||||
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
|
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
|
||||||
await containerNode.expand();
|
await containerNode.expand();
|
||||||
|
|
||||||
// Click Scale & Settings and open Scale tab
|
// Click Scale & Settings and open Settings tab
|
||||||
await explorer.openScaleAndSettings(context);
|
await explorer.openScaleAndSettings(context);
|
||||||
const settingsTab = explorer.frame.getByTestId("settings-tab-header/SubSettingsTab");
|
const settingsTab = explorer.frame.getByTestId("settings-tab-header/SubSettingsTab");
|
||||||
await settingsTab.click();
|
await settingsTab.click();
|
||||||
@@ -25,46 +25,86 @@ test.describe("Settings under Scale & Settings", () => {
|
|||||||
await context?.dispose();
|
await context?.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Update TTL to On (no default)", async () => {
|
test.describe("Set TTL", () => {
|
||||||
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
test("Update TTL to On (no default)", async () => {
|
||||||
await ttlOnNoDefaultRadioButton.click();
|
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
||||||
|
await ttlOnNoDefaultRadioButton.click();
|
||||||
|
|
||||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||||
await expect(explorer.getConsoleMessage()).toContainText(`Successfully updated container ${context.container.id}`, {
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
timeout: ONE_MINUTE_MS,
|
`Successfully updated container ${context.container.id}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Update TTL to On (with user entry)", async () => {
|
||||||
|
const ttlOnRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-option" });
|
||||||
|
await ttlOnRadioButton.click();
|
||||||
|
|
||||||
|
// Enter TTL seconds
|
||||||
|
const ttlInput = explorer.frame.getByTestId("ttl-input");
|
||||||
|
await ttlInput.fill("30000");
|
||||||
|
|
||||||
|
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
|
`Successfully updated container ${context.container.id}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Update TTL to Off", async () => {
|
||||||
|
// By default TTL is set to off so we need to first set it to On
|
||||||
|
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
||||||
|
await ttlOnNoDefaultRadioButton.click();
|
||||||
|
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
|
`Successfully updated container ${context.container.id}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set it to Off
|
||||||
|
const ttlOffRadioButton = explorer.frame.getByRole("radio", { name: "ttl-off-option" });
|
||||||
|
await ttlOffRadioButton.click();
|
||||||
|
|
||||||
|
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
|
`Successfully updated container ${context.container.id}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Update TTL to On (with user entry)", async () => {
|
test.describe("Set Geospatial Config", () => {
|
||||||
const ttlOnRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-option" });
|
test("Set Geospatial Config to Geometry then Geography", async () => {
|
||||||
await ttlOnRadioButton.click();
|
const geometryRadioButton = explorer.frame.getByRole("radio", { name: "geometry-option" });
|
||||||
|
await geometryRadioButton.click();
|
||||||
|
|
||||||
// Enter TTL seconds
|
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||||
const ttlInput = explorer.frame.getByTestId("ttl-input");
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
await ttlInput.fill("30000");
|
`Successfully updated container ${context.container.id}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
const geographyRadioButton = explorer.frame.getByRole("radio", { name: "geography-option" });
|
||||||
await expect(explorer.getConsoleMessage()).toContainText(`Successfully updated container ${context.container.id}`, {
|
await geographyRadioButton.click();
|
||||||
timeout: ONE_MINUTE_MS,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Update TTL to Off", async () => {
|
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||||
// By default TTL is set to off so we need to first set it to On
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
`Successfully updated container ${context.container.id}`,
|
||||||
await ttlOnNoDefaultRadioButton.click();
|
{
|
||||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
timeout: ONE_MINUTE_MS,
|
||||||
await expect(explorer.getConsoleMessage()).toContainText(`Successfully updated container ${context.container.id}`, {
|
},
|
||||||
timeout: ONE_MINUTE_MS,
|
);
|
||||||
});
|
|
||||||
|
|
||||||
// Set it to Off
|
|
||||||
const ttlOffRadioButton = explorer.frame.getByRole("radio", { name: "ttl-off-option" });
|
|
||||||
await ttlOffRadioButton.click();
|
|
||||||
|
|
||||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
|
||||||
await expect(explorer.getConsoleMessage()).toContainText(`Successfully updated container ${context.container.id}`, {
|
|
||||||
timeout: ONE_MINUTE_MS,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
75
test/sql/scripts/storedProcedure.spec.ts
Normal file
75
test/sql/scripts/storedProcedure.spec.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx";
|
||||||
|
import { createTestSQLContainer, TestContainerContext } from "../../testData";
|
||||||
|
|
||||||
|
test.describe("Stored Procedures", () => {
|
||||||
|
let context: TestContainerContext = null!;
|
||||||
|
let explorer: DataExplorer = null!;
|
||||||
|
|
||||||
|
test.beforeAll("Create Test Database", async () => {
|
||||||
|
context = await createTestSQLContainer(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeEach("Open container", async ({ page }) => {
|
||||||
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll("Delete Test Database", async () => {
|
||||||
|
await context?.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Add, execute, and delete stored procedure", async () => {
|
||||||
|
// Open container context menu and click New Stored Procedure
|
||||||
|
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
|
||||||
|
await containerNode.openContextMenu();
|
||||||
|
await containerNode.contextMenuItem("New Stored Procedure").click();
|
||||||
|
|
||||||
|
// Type stored procedure id and use stock procedure
|
||||||
|
const storedProcedureIdTextBox = explorer.frame.getByLabel("Stored procedure id");
|
||||||
|
await storedProcedureIdTextBox.isVisible();
|
||||||
|
const storedProcedureName = "stored-procedure-1";
|
||||||
|
await storedProcedureIdTextBox.fill(storedProcedureName);
|
||||||
|
|
||||||
|
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||||
|
await expect(saveButton).toBeEnabled();
|
||||||
|
await saveButton.click();
|
||||||
|
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
|
`Sucessfully created stored procedure ${storedProcedureName}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Execute stored procedure
|
||||||
|
const executeButton = explorer.commandBarButton(CommandBarButton.Execute);
|
||||||
|
await executeButton.click();
|
||||||
|
const executeSidePanelButton = explorer.frame.getByTestId("Panel/OkButton");
|
||||||
|
await executeSidePanelButton.click();
|
||||||
|
|
||||||
|
const executeStoredProcedureResult = explorer.frame.getByLabel("Execute stored procedure result");
|
||||||
|
await expect(executeStoredProcedureResult).toBeVisible();
|
||||||
|
|
||||||
|
// Delete stored procedure
|
||||||
|
await containerNode.expand();
|
||||||
|
const storedProceduresNode = await explorer.waitForNode(
|
||||||
|
`${context.database.id}/${context.container.id}/Stored Procedures`,
|
||||||
|
);
|
||||||
|
await storedProceduresNode.expand();
|
||||||
|
const storedProcedureNode = await explorer.waitForNode(
|
||||||
|
`${context.database.id}/${context.container.id}/Stored Procedures/${storedProcedureName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await storedProcedureNode.openContextMenu();
|
||||||
|
await storedProcedureNode.contextMenuItem("Delete Stored Procedure").click();
|
||||||
|
const deleteStoredProcedureButton = explorer.frame.getByTestId("DialogButton:Delete");
|
||||||
|
await deleteStoredProcedureButton.click();
|
||||||
|
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(
|
||||||
|
`Successfully deleted stored procedure ${storedProcedureName}`,
|
||||||
|
{
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
74
test/sql/scripts/userDefinedFunction.spec.ts
Normal file
74
test/sql/scripts/userDefinedFunction.spec.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx";
|
||||||
|
import { createTestSQLContainer, TestContainerContext } from "../../testData";
|
||||||
|
|
||||||
|
test.describe("User Defined Functions", () => {
|
||||||
|
let context: TestContainerContext = null!;
|
||||||
|
let explorer: DataExplorer = null!;
|
||||||
|
const udfBody = `function extractDocumentId(doc) {
|
||||||
|
return {
|
||||||
|
id: doc.id
|
||||||
|
};
|
||||||
|
}`;
|
||||||
|
|
||||||
|
test.beforeAll("Create Test Database", async () => {
|
||||||
|
context = await createTestSQLContainer(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeEach("Open container", async ({ page }) => {
|
||||||
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll("Delete Test Database", async () => {
|
||||||
|
await context?.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Add, execute, and delete user defined function", async ({ page }) => {
|
||||||
|
// Open container context menu and click New UDF
|
||||||
|
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
|
||||||
|
await containerNode.openContextMenu();
|
||||||
|
await containerNode.contextMenuItem("New UDF").click();
|
||||||
|
|
||||||
|
// Assign UDF id
|
||||||
|
const udfIdTextBox = explorer.frame.getByLabel("User Defined Function Id");
|
||||||
|
const udfName: string = "extractDocumentId";
|
||||||
|
await udfIdTextBox.fill(udfName);
|
||||||
|
|
||||||
|
// Create UDF body that extracts the document id from a document
|
||||||
|
const udfBodyTextArea = explorer.frame.getByTestId("EditorReact/Host/Loaded");
|
||||||
|
await udfBodyTextArea.click();
|
||||||
|
|
||||||
|
// Clear existing content
|
||||||
|
const isMac: boolean = process.platform === "darwin";
|
||||||
|
await page.keyboard.press(isMac ? "Meta+A" : "Control+A");
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
|
||||||
|
await page.keyboard.type(udfBody);
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||||
|
await expect(saveButton).toBeEnabled();
|
||||||
|
await saveButton.click();
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(`Sucessfully created user defined function ${udfName}`, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Delete UDF
|
||||||
|
await containerNode.expand();
|
||||||
|
const udfsNode = await explorer.waitForNode(
|
||||||
|
`${context.database.id}/${context.container.id}/User Defined Functions`,
|
||||||
|
);
|
||||||
|
await udfsNode.expand();
|
||||||
|
const udfNode = await explorer.waitForNode(
|
||||||
|
`${context.database.id}/${context.container.id}/User Defined Functions/${udfName}`,
|
||||||
|
);
|
||||||
|
await udfNode.openContextMenu();
|
||||||
|
await udfNode.contextMenuItem("Delete User Defined Function").click();
|
||||||
|
const deleteUserDefinedFunctionButton = explorer.frame.getByTestId("DialogButton:Delete");
|
||||||
|
await deleteUserDefinedFunctionButton.click();
|
||||||
|
|
||||||
|
await expect(explorer.getConsoleMessage()).toContainText(`Successfully deleted user defined function ${udfName}`, {
|
||||||
|
timeout: ONE_MINUTE_MS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -37,27 +37,35 @@ export interface PartitionKey {
|
|||||||
value: string | null;
|
value: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const partitionCount = 4;
|
export const partitionCount = 4;
|
||||||
|
|
||||||
// If we increase this number, we need to split bulk creates into multiple batches.
|
// If we increase this number, we need to split bulk creates into multiple batches.
|
||||||
// Bulk operations are limited to 100 items per partition.
|
// Bulk operations are limited to 100 items per partition.
|
||||||
const itemsPerPartition = 100;
|
export const itemsPerPartition = 100;
|
||||||
|
|
||||||
function createTestItems(): TestItem[] {
|
function createTestItems(): TestItem[] {
|
||||||
const items: TestItem[] = [];
|
const items: TestItem[] = [];
|
||||||
for (let i = 0; i < partitionCount; i++) {
|
for (let i = 0; i < partitionCount; i++) {
|
||||||
for (let j = 0; j < itemsPerPartition; j++) {
|
for (let j = 0; j < itemsPerPartition; j++) {
|
||||||
const id = crypto.randomBytes(32).toString("base64");
|
const id = createSafeRandomString(32);
|
||||||
items.push({
|
items.push({
|
||||||
id,
|
id,
|
||||||
partitionKey: `partition_${i}`,
|
partitionKey: `partition_${i}`,
|
||||||
randomData: crypto.randomBytes(32).toString("base64"),
|
randomData: createSafeRandomString(32),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Document IDs cannot contain '/', '\', or '#'
|
||||||
|
function createSafeRandomString(byteLength: number): string {
|
||||||
|
return crypto
|
||||||
|
.randomBytes(byteLength)
|
||||||
|
.toString("base64")
|
||||||
|
.replace(/[/\\#]/g, "_");
|
||||||
|
}
|
||||||
|
|
||||||
export const TestData: TestItem[] = createTestItems();
|
export const TestData: TestItem[] = createTestItems();
|
||||||
|
|
||||||
export class TestContainerContext {
|
export class TestContainerContext {
|
||||||
|
|||||||
Reference in New Issue
Block a user