Compare commits

..

2 Commits

Author SHA1 Message Date
Asier Isayas
3586fcbde5 Merge branch 'master' of https://github.com/Azure/cosmos-explorer into users/aisayas/test-playwright 2026-02-02 07:59:08 -08:00
Asier Isayas
2da6627137 test 2026-01-30 09:52:16 -08:00
5 changed files with 5 additions and 142 deletions

View File

@@ -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) => {

View File

@@ -35,6 +35,7 @@ export async function fetchSubscriptions(accessToken: string = ""): Promise<Subs
(sub) => sub.state === "Enabled" || sub.state === "Warned" || sub.state === "PastDue",
);
subscriptions = [...subscriptions, ...validSubscriptions];
console.log("test")
}
return subscriptions.sort((a, b) => a.displayName.localeCompare(b.displayName));
}

View File

@@ -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 {

View File

@@ -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);
}
});
});

View File

@@ -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 });