mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-08 03:57:31 +00:00
stored procedure playwright test
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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) => {
|
||||||
|
|||||||
@@ -325,6 +325,7 @@ type PanelOpenOptions = {
|
|||||||
|
|
||||||
export enum CommandBarButton {
|
export enum CommandBarButton {
|
||||||
Save = "Save",
|
Save = "Save",
|
||||||
|
Execute = "Execute",
|
||||||
ExecuteQuery = "Execute Query",
|
ExecuteQuery = "Execute Query",
|
||||||
UploadItem = "Upload Item",
|
UploadItem = "Upload Item",
|
||||||
}
|
}
|
||||||
|
|||||||
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,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -60,7 +60,10 @@ function createTestItems(): TestItem[] {
|
|||||||
|
|
||||||
// Document IDs cannot contain '/', '\', or '#'
|
// Document IDs cannot contain '/', '\', or '#'
|
||||||
function createSafeRandomString(byteLength: number): string {
|
function createSafeRandomString(byteLength: number): string {
|
||||||
return crypto.randomBytes(byteLength).toString("base64").replace(/[\\#]/g, "_");
|
return crypto
|
||||||
|
.randomBytes(byteLength)
|
||||||
|
.toString("base64")
|
||||||
|
.replace(/[/\\#]/g, "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TestData: TestItem[] = createTestItems();
|
export const TestData: TestItem[] = createTestItems();
|
||||||
|
|||||||
Reference in New Issue
Block a user