mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-02-06 18:44:30 +00:00
Compare commits
2 Commits
users/sind
...
users/saks
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a20076200 | ||
|
|
4c9dea0913 |
@@ -38,7 +38,7 @@ export function queryIterator(databaseId: string, collection: Collection, query:
|
||||
let continuationToken: string;
|
||||
return {
|
||||
fetchNext: () => {
|
||||
return queryDocuments(databaseId, collection, false, query, continuationToken).then((response) => {
|
||||
return queryDocuments(databaseId, collection, false, query).then((response) => {
|
||||
continuationToken = response.continuationToken;
|
||||
const headers: { [key: string]: string | number } = {};
|
||||
response.headers.forEach((value, key) => {
|
||||
|
||||
@@ -250,8 +250,7 @@ class TreeNode {
|
||||
// Try three times to wait for the node to expand.
|
||||
for (let i = 0; i < RETRY_COUNT; i++) {
|
||||
try {
|
||||
// Use a longer timeout (30s) since expanding may require loading children from the server
|
||||
await tree.waitFor({ state: "visible", timeout: 30 * 1000 });
|
||||
await tree.waitFor({ state: "visible" });
|
||||
// The tree has expanded, let's get out of here
|
||||
return true;
|
||||
} catch {
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { setupCORSBypass } from "../CORSBypass";
|
||||
import { DataExplorer, QueryTab, TestAccount, CommandBarButton, Editor } from "../fx";
|
||||
import { serializeMongoToJson } from "../testData";
|
||||
|
||||
const databaseId = "test-e2etests-mongo-pagination";
|
||||
const collectionId = "test-coll-mongo-pagination";
|
||||
let explorer: DataExplorer = null!;
|
||||
|
||||
test.setTimeout(5 * 60 * 1000);
|
||||
|
||||
test.describe("Test Mongo Pagination", () => {
|
||||
let queryTab: QueryTab;
|
||||
let queryEditor: Editor;
|
||||
|
||||
test.beforeEach("Open query tab", async ({ page }) => {
|
||||
await setupCORSBypass(page);
|
||||
explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
|
||||
|
||||
const containerNode = await explorer.waitForContainerNode(databaseId, collectionId);
|
||||
await containerNode.expand();
|
||||
|
||||
const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, collectionId);
|
||||
await containerMenuNode.openContextMenu();
|
||||
await containerMenuNode.contextMenuItem("New Query").click();
|
||||
|
||||
queryTab = explorer.queryTab("tab0");
|
||||
queryEditor = queryTab.editor();
|
||||
await queryEditor.locator.waitFor({ timeout: 30 * 1000 });
|
||||
await queryTab.executeCTA.waitFor();
|
||||
await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click();
|
||||
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
||||
});
|
||||
|
||||
test("should execute a query and load more results", async ({ page }) => {
|
||||
const query = "{}";
|
||||
|
||||
await queryEditor.locator.click();
|
||||
await queryEditor.setText(query);
|
||||
|
||||
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
|
||||
await executeQueryButton.click();
|
||||
|
||||
// Wait for query execution to complete
|
||||
await expect(queryTab.resultsView).toBeVisible({ timeout: 60000 });
|
||||
await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 30000 });
|
||||
|
||||
// Get initial results
|
||||
const resultText = await queryTab.resultsEditor.text();
|
||||
|
||||
if (!resultText || resultText.trim() === "" || resultText.trim() === "[]") {
|
||||
throw new Error("Query returned no results - the collection appears to be empty");
|
||||
}
|
||||
|
||||
const resultData = serializeMongoToJson(resultText);
|
||||
|
||||
if (resultData.length === 0) {
|
||||
throw new Error("Parsed results contain 0 documents - collection is empty");
|
||||
}
|
||||
|
||||
if (resultData.length < 100) {
|
||||
expect(resultData.length).toBeGreaterThan(0);
|
||||
return;
|
||||
}
|
||||
|
||||
expect(resultData.length).toBe(100);
|
||||
|
||||
// Pagination test
|
||||
let totalPagesLoaded = 1;
|
||||
const maxLoadMoreAttempts = 10;
|
||||
|
||||
for (let loadMoreAttempts = 0; loadMoreAttempts < maxLoadMoreAttempts; loadMoreAttempts++) {
|
||||
const loadMoreButton = queryTab.resultsView.getByText("Load more");
|
||||
|
||||
try {
|
||||
await expect(loadMoreButton).toBeVisible({ timeout: 5000 });
|
||||
} catch {
|
||||
// Load more button not visible - pagination complete
|
||||
break;
|
||||
}
|
||||
|
||||
const beforeClickText = await queryTab.resultsEditor.text();
|
||||
const beforeClickHash = Buffer.from(beforeClickText || "")
|
||||
.toString("base64")
|
||||
.substring(0, 50);
|
||||
|
||||
await loadMoreButton.click();
|
||||
|
||||
// Wait for content to update
|
||||
let editorContentChanged = false;
|
||||
for (let waitAttempt = 1; waitAttempt <= 3; waitAttempt++) {
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
const currentEditorText = await queryTab.resultsEditor.text();
|
||||
const currentHash = Buffer.from(currentEditorText || "")
|
||||
.toString("base64")
|
||||
.substring(0, 50);
|
||||
|
||||
if (currentHash !== beforeClickHash) {
|
||||
editorContentChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (editorContentChanged) {
|
||||
totalPagesLoaded++;
|
||||
} else {
|
||||
// No content change detected, stop pagination
|
||||
break;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
}
|
||||
|
||||
// Final verification
|
||||
const finalIndicator = queryTab.resultsView.locator("text=/\\d+ - \\d+/");
|
||||
const finalIndicatorText = await finalIndicator.textContent();
|
||||
|
||||
if (finalIndicatorText) {
|
||||
const match = finalIndicatorText.match(/(\d+) - (\d+)/);
|
||||
if (match) {
|
||||
const totalDocuments = parseInt(match[2]);
|
||||
expect(totalDocuments).toBe(405);
|
||||
expect(totalPagesLoaded).toBe(5);
|
||||
} else {
|
||||
throw new Error(`Invalid results indicator format: ${finalIndicatorText}`);
|
||||
}
|
||||
} else {
|
||||
expect(totalPagesLoaded).toBe(5);
|
||||
}
|
||||
});
|
||||
});
|
||||
157
test/sql/scaleAndSettings/indexingPolicy.spec.ts
Normal file
157
test/sql/scaleAndSettings/indexingPolicy.spec.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { CommandBarButton, DataExplorer, Editor, ONE_MINUTE_MS, TestAccount } from "../../fx";
|
||||
import { createTestSQLContainer, TestContainerContext } from "../../testData";
|
||||
|
||||
test.describe("Indexing Policy under Scale & Settings", () => {
|
||||
let context: TestContainerContext = null!;
|
||||
let explorer: DataExplorer = null!;
|
||||
|
||||
// Helper function to get the indexing policy editor
|
||||
const getIndexingPolicyEditor = (): Editor => {
|
||||
const editorContainer = explorer.frame.locator(".settingsV2Editor");
|
||||
return new Editor(explorer.frame, editorContainer);
|
||||
};
|
||||
|
||||
test.beforeAll("Create Test Database & Open Indexing Policy tab", async ({ browser }) => {
|
||||
context = await createTestSQLContainer();
|
||||
const page = await browser.newPage();
|
||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||
|
||||
// Click Scale & Settings and open Indexing Policy tab
|
||||
await explorer.openScaleAndSettings(context);
|
||||
const indexingPolicyTab = explorer.frame.getByTestId("settings-tab-header/IndexingPolicyTab");
|
||||
await indexingPolicyTab.click();
|
||||
});
|
||||
|
||||
test.afterAll("Delete Test Database", async () => {
|
||||
await context?.dispose();
|
||||
});
|
||||
|
||||
test("Verify Indexing Policy tab is visible", async () => {
|
||||
const indexingPolicyTab = explorer.frame.getByTestId("settings-tab-header/IndexingPolicyTab");
|
||||
await expect(indexingPolicyTab).toBeVisible();
|
||||
});
|
||||
|
||||
test("Verify Indexing Policy editor is present", async () => {
|
||||
// The Monaco editor is rendered in a div with class settingsV2Editor
|
||||
const editorContainer = explorer.frame.locator(".settingsV2Editor");
|
||||
await expect(editorContainer).toBeVisible();
|
||||
|
||||
// Verify the editor has content (default indexing policy) using Editor helper
|
||||
const editor = getIndexingPolicyEditor();
|
||||
const editorContent = await editor.text();
|
||||
expect(editorContent).toBeTruthy();
|
||||
});
|
||||
|
||||
test("Update Indexing Policy - Change automatic to false", async () => {
|
||||
// Use helper function to get editor instance
|
||||
const editor = getIndexingPolicyEditor();
|
||||
|
||||
// Verify the Monaco editor is visible
|
||||
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
|
||||
await expect(editorElement).toBeVisible();
|
||||
|
||||
// Get current indexing policy content
|
||||
const currentContent = await editor.text();
|
||||
expect(currentContent).toBeTruthy();
|
||||
const indexingPolicy = JSON.parse(currentContent as string);
|
||||
|
||||
// Verify default policy structure
|
||||
expect(indexingPolicy).toHaveProperty("automatic");
|
||||
expect(indexingPolicy).toHaveProperty("indexingMode");
|
||||
|
||||
// Modify the indexing policy - change automatic to false
|
||||
indexingPolicy.automatic = false;
|
||||
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
|
||||
|
||||
// Set the new content in the editor
|
||||
await editor.setText(updatedContent);
|
||||
|
||||
// Verify the warning message appears for unsaved changes
|
||||
const warningMessage = explorer.frame.locator(".ms-MessageBar--warning");
|
||||
await expect(warningMessage).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Save the changes
|
||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||
|
||||
// Verify success message
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||
`Successfully updated container ${context.container.id}`,
|
||||
{
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
},
|
||||
);
|
||||
|
||||
// Verify warning message is no longer visible after save
|
||||
await expect(warningMessage).not.toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test("Update Indexing Policy - Change indexingMode to lazy", async () => {
|
||||
// Use helper function to get editor instance
|
||||
const editor = getIndexingPolicyEditor();
|
||||
|
||||
// Verify the Monaco editor is visible
|
||||
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
|
||||
await expect(editorElement).toBeVisible();
|
||||
|
||||
// Get current indexing policy content
|
||||
const currentContent = await editor.text();
|
||||
expect(currentContent).toBeTruthy();
|
||||
const indexingPolicy = JSON.parse(currentContent as string);
|
||||
|
||||
// Modify the indexing policy - change indexingMode to lazy
|
||||
indexingPolicy.indexingMode = "lazy";
|
||||
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
|
||||
|
||||
// Set the new content in the editor
|
||||
await editor.setText(updatedContent);
|
||||
|
||||
// Verify the warning message appears
|
||||
const warningMessage = explorer.frame.locator(".ms-MessageBar--warning");
|
||||
await expect(warningMessage).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Save the changes
|
||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||
|
||||
// Verify success message
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||
`Successfully updated container ${context.container.id}`,
|
||||
{
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("Update Indexing Policy - Revert automatic to true", async () => {
|
||||
// Use helper function to get editor instance
|
||||
const editor = getIndexingPolicyEditor();
|
||||
|
||||
// Verify the Monaco editor is visible
|
||||
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
|
||||
await expect(editorElement).toBeVisible();
|
||||
|
||||
// Get current indexing policy content
|
||||
const currentContent = await editor.text();
|
||||
expect(currentContent).toBeTruthy();
|
||||
const indexingPolicy = JSON.parse(currentContent as string);
|
||||
|
||||
// Revert the changes - set automatic back to true and indexingMode to consistent
|
||||
indexingPolicy.automatic = true;
|
||||
indexingPolicy.indexingMode = "consistent";
|
||||
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
|
||||
|
||||
// Set the new content in the editor
|
||||
await editor.setText(updatedContent);
|
||||
|
||||
// Save the changes
|
||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||
|
||||
// Verify success message
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||
`Successfully updated container ${context.container.id}`,
|
||||
{
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -29,7 +29,7 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Create database with shared manual throughput and verify Scale node in UI", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
test.setTimeout(120000); // 2 minutes timeout
|
||||
// Create database with shared manual throughput (400 RU/s)
|
||||
dbContext = await createTestDB({ throughput: 400 });
|
||||
|
||||
@@ -47,7 +47,6 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Add container to shared database without dedicated throughput", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
// Create database with shared manual throughput
|
||||
dbContext = await createTestDB({ throughput: 400 });
|
||||
|
||||
@@ -101,7 +100,6 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Scale shared database manual throughput", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
// Create database with shared manual throughput (400 RU/s)
|
||||
dbContext = await createTestDB({ throughput: 400 });
|
||||
|
||||
@@ -127,7 +125,6 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Scale shared database from manual to autoscale", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
// Create database with shared manual throughput (400 RU/s)
|
||||
dbContext = await createTestDB({ throughput: 400 });
|
||||
|
||||
@@ -162,7 +159,7 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Create database with shared autoscale throughput and verify Scale node in UI", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
test.setTimeout(120000); // 2 minutes timeout
|
||||
|
||||
// Create database with shared autoscale throughput (max 1000 RU/s)
|
||||
dbContext = await createTestDB({ maxThroughput: 1000 });
|
||||
@@ -181,7 +178,6 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Scale shared database autoscale throughput", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
// Create database with shared autoscale throughput (max 1000 RU/s)
|
||||
dbContext = await createTestDB({ maxThroughput: 1000 });
|
||||
|
||||
@@ -207,7 +203,6 @@ test.describe("Database with Shared Throughput", () => {
|
||||
});
|
||||
|
||||
test("Scale shared database from autoscale to manual", async () => {
|
||||
test.setTimeout(180000); // 3 minutes timeout
|
||||
// Create database with shared autoscale throughput (max 1000 RU/s)
|
||||
dbContext = await createTestDB({ maxThroughput: 1000 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user